@vm75/inditrans 0.5.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,12 +1,15 @@
1
1
  # inditrans
2
2
 
3
- A functional transliterator library for most common [Indic/Brahmic](https://en.wikipedia.org/wiki/Brahmic_scripts) scripts.
3
+ A functional transliterator library for the most common [Indic/Brahmic](https://en.wikipedia.org/wiki/Brahmic_scripts) scripts.
4
4
 
5
5
  - No dependencies and no server needed. Uses wasm for near native performance.
6
6
  - Supports ITRANS toggle transliteration with ## and skipping XML tags
7
7
  - Special handling for scripts like Tamil, Malayalam, Gurmukhi, etc. Tuned for reability.
8
8
  - Supports [vedic accents](https://en.wikipedia.org/wiki/Vedic_accent) for vedic scriptures.
9
9
 
10
+ <!-- - [Demo](http://vm75.github.io/inditrans/example/) -->
11
+ - [Changelog](CHANGELOG.md)
12
+
10
13
  References:
11
14
 
12
15
  - [inditrans on Github](https://github.com/vm75/inditrans)
@@ -1,13 +1,22 @@
1
1
  "use strict";
2
+ // GENERATED CODE - DO NOT MODIFY BY HAND
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.Option = void 0;
5
+ /// Transliteration options
6
+ /// Flags to control transliteration
4
7
  var Option;
5
8
  (function (Option) {
9
+ /// No options (default)
6
10
  Option[Option["None"] = 0] = "None";
11
+ /// Use traditional Tamil consonants only
7
12
  Option[Option["TamilTraditional"] = 1] = "TamilTraditional";
13
+ /// Use superscripted Tamil consonants
8
14
  Option[Option["TamilSuperscripted"] = 2] = "TamilSuperscripted";
15
+ /// Force ASCII numerals in transliterated text
9
16
  Option[Option["ASCIINumerals"] = 4] = "ASCIINumerals";
17
+ /// Ignore Vedic accents in transliterated text
10
18
  Option[Option["IgnoreVedicAccents"] = 8] = "IgnoreVedicAccents";
19
+ /// Retain special markers which are used to identify non-standard chars
11
20
  Option[Option["RetainSpecialMarkers"] = 16] = "RetainSpecialMarkers";
12
21
  })(Option = exports.Option || (exports.Option = {}));
13
22
  //# sourceMappingURL=Option.js.map
@@ -1,19 +1,31 @@
1
1
  export declare enum Script {
2
2
  assamese = "assamese",
3
+ bangla = "bangla",
3
4
  bengali = "bengali",
5
+ burmese = "burmese",
4
6
  devanagari = "devanagari",
5
- readablelatin = "readablelatin",
6
7
  gujarati = "gujarati",
7
8
  gurmukhi = "gurmukhi",
9
+ hindi = "hindi",
8
10
  iast = "iast",
9
11
  indic = "indic",
10
12
  ipa = "ipa",
11
13
  iso = "iso",
12
14
  itrans = "itrans",
13
15
  kannada = "kannada",
16
+ khmer = "khmer",
14
17
  malayalam = "malayalam",
18
+ odia = "odia",
15
19
  oriya = "oriya",
20
+ punjabi = "punjabi",
21
+ readableLatin = "readableLatin",
22
+ sanskrit = "sanskrit",
16
23
  sinhala = "sinhala",
17
24
  tamil = "tamil",
18
- telugu = "telugu"
25
+ tamilExtended = "tamilExtended",
26
+ telugu = "telugu",
27
+ thai = "thai",
28
+ tibetan = "tibetan",
29
+ titus = "titus",
30
+ wx = "wx"
19
31
  }
@@ -1,24 +1,38 @@
1
1
  "use strict";
2
+ // GENERATED CODE - DO NOT MODIFY BY HAND
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.Script = void 0;
5
+ /// Supported scripts
4
6
  var Script;
5
7
  (function (Script) {
6
8
  Script["assamese"] = "assamese";
9
+ Script["bangla"] = "bangla";
7
10
  Script["bengali"] = "bengali";
11
+ Script["burmese"] = "burmese";
8
12
  Script["devanagari"] = "devanagari";
9
- Script["readablelatin"] = "readablelatin";
10
13
  Script["gujarati"] = "gujarati";
11
14
  Script["gurmukhi"] = "gurmukhi";
15
+ Script["hindi"] = "hindi";
12
16
  Script["iast"] = "iast";
13
17
  Script["indic"] = "indic";
14
18
  Script["ipa"] = "ipa";
15
19
  Script["iso"] = "iso";
16
20
  Script["itrans"] = "itrans";
17
21
  Script["kannada"] = "kannada";
22
+ Script["khmer"] = "khmer";
18
23
  Script["malayalam"] = "malayalam";
24
+ Script["odia"] = "odia";
19
25
  Script["oriya"] = "oriya";
26
+ Script["punjabi"] = "punjabi";
27
+ Script["readableLatin"] = "readableLatin";
28
+ Script["sanskrit"] = "sanskrit";
20
29
  Script["sinhala"] = "sinhala";
21
30
  Script["tamil"] = "tamil";
31
+ Script["tamilExtended"] = "tamilExtended";
22
32
  Script["telugu"] = "telugu";
33
+ Script["thai"] = "thai";
34
+ Script["tibetan"] = "tibetan";
35
+ Script["titus"] = "titus";
36
+ Script["wx"] = "wx";
23
37
  })(Script = exports.Script || (exports.Script = {}));
24
38
  //# sourceMappingURL=Script.js.map
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vm75/inditrans",
3
- "version": "0.5.0",
4
- "description": "A functional transliterator library for most common Indic/Brahmic scripts.",
3
+ "version": "0.7.0",
4
+ "description": "A functional transliterator library for the most common Indic/Brahmic scripts.",
5
5
  "main": "./dist/src/index.js",
6
6
  "author": "VM75",
7
7
  "license": "MIT",
@@ -9,10 +9,15 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/vm75/inditrans"
11
11
  },
12
+ "bugs": {
13
+ "url": "https://github.com/vm75/inditrans/issues"
14
+ },
15
+ "homepage": "https://github.com/vm75/inditrans",
12
16
  "files": [
13
17
  "dist/src/*.ts",
14
18
  "dist/src/*.js",
15
- "dist/src/*.wasm"
19
+ "dist/src/*.wasm",
20
+ "test/"
16
21
  ],
17
22
  "types": "./dist/src/index.d.ts",
18
23
  "scripts": {
@@ -42,6 +47,7 @@
42
47
  },
43
48
  "keywords": [
44
49
  "Transliterate",
50
+ "Transliterator",
45
51
  "Indian",
46
52
  "Indian language",
47
53
  "Indian script",
@@ -67,5 +73,9 @@
67
73
  "ITRANS",
68
74
  "IPA",
69
75
  "TITUS"
76
+ ],
77
+ "precommit": [
78
+ "lint",
79
+ "test"
70
80
  ]
71
81
  }
@@ -0,0 +1,24 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+
4
+ <head>
5
+ <meta charset="utf-8">
6
+ <title>inditrans Test</title>
7
+ <div>
8
+ <button class="mybutton">Run inditrans</button>
9
+ <span id="content"></span>
10
+ </div>
11
+
12
+ <script type="module" defer>
13
+ import { Inditrans } from 'inditrans_wasm.js';
14
+ Inditrans().then(inditrans => {
15
+ document.querySelector('.mybutton')
16
+ .addEventListener('click', function () {
17
+ var out = inditrans.transliterate("श्री॒ गु॒रु॒भ्यो नमः॒ । ह॒रिः॒ ओ३म् ॥", "devanagari", "tamil", "");
18
+ document.querySelector('#content').innerHTML = out;
19
+ });
20
+ })
21
+ </script>
22
+ </head>
23
+
24
+ </html>
package/test/tests.ts ADDED
@@ -0,0 +1,85 @@
1
+ import * as inditrans from '../src';
2
+ import Tests from './test-cases.json';
3
+
4
+ function getOptionsMap(): Map<string, inditrans.Option> {
5
+ const map = new Map<string, inditrans.Option>();
6
+ const optionStrings = Object.values(inditrans.Option).filter((value) =>
7
+ isNaN(Number(value))
8
+ ) as string[];
9
+ const optionValue = Object.values(inditrans.Option).filter(
10
+ (value) => !isNaN(Number(value))
11
+ ) as inditrans.Option[];
12
+ for (let i = 0; i < optionStrings.length; i++) {
13
+ map.set(optionStrings[i], optionValue[i]);
14
+ }
15
+ return map;
16
+ }
17
+
18
+ function getOptions(options: string): inditrans.Option {
19
+ const optionsMap = getOptionsMap();
20
+ let result = inditrans.Option.None;
21
+ options.split(' ').forEach((option) => {
22
+ result += optionsMap.get(option) || 0;
23
+ });
24
+
25
+ return result;
26
+ }
27
+
28
+ class TestData {
29
+ description: string;
30
+ text: string;
31
+ fromScript: string;
32
+ toScript: string;
33
+ options: string;
34
+ expected: string;
35
+
36
+ constructor(
37
+ description: string,
38
+ text: string,
39
+ fromScript: string,
40
+ toScript: string,
41
+ options: string,
42
+ expected: string
43
+ ) {
44
+ this.description = description;
45
+ this.text = text;
46
+ this.fromScript = fromScript;
47
+ this.toScript = toScript;
48
+ this.options = options;
49
+ this.expected = expected;
50
+ }
51
+ }
52
+
53
+ const testData = [];
54
+
55
+ for (const input of Tests) {
56
+ for (const target of input.targets) {
57
+ testData.push(
58
+ new TestData(
59
+ input.description,
60
+ input.text,
61
+ input.script,
62
+ target.script,
63
+ target.options || '',
64
+ target.text
65
+ )
66
+ );
67
+ }
68
+ }
69
+
70
+ beforeAll(async () => {
71
+ await inditrans.init();
72
+ });
73
+
74
+ test.each(testData)(
75
+ '$description',
76
+ ({ text, fromScript, toScript, options, expected }) => {
77
+ const result = inditrans.transliterate(
78
+ text,
79
+ <inditrans.Script>fromScript,
80
+ <inditrans.Script>toScript,
81
+ getOptions(options)
82
+ );
83
+ expect(result).toBe(expected);
84
+ }
85
+ );
package/CHANGELOG.md DELETED
@@ -1,123 +0,0 @@
1
- ## 0.5.0
2
-
3
- - Added support for Gurmukhi adhak
4
-
5
- ## 0.4.6
6
-
7
- - Fixed Zero Width Joiner and Non-Joiner
8
-
9
- ## 0.4.5
10
-
11
- - Support compound alternates and Malayalam Chillus
12
-
13
- ## 0.4.4
14
-
15
- - Fixed ITRANS and unit tests
16
-
17
- ## 0.4.3
18
-
19
- - added support for xml tag skip
20
-
21
- ## 0.4.2
22
-
23
- - Added case insensitive support for iast, iso and ipa. Added support for extended latin chars with composition
24
-
25
- ## 0.4.1
26
-
27
- - Split symbols, Zero Width chars and Vedic symbols
28
-
29
- ## 0.4.0
30
-
31
- - Lot of refactoring.
32
-
33
- ## 0.3.6
34
-
35
- - Refactored nodejs interface. Updated readme.
36
-
37
- ## 0.3.5
38
-
39
- - Fixed wasm, tests and nodejs support
40
-
41
- ## 0.3.4
42
-
43
- - Fixed some corner case
44
-
45
- ## 0.3.3
46
-
47
- - Added support for Tamil prefix
48
-
49
- ## 0.3.2
50
-
51
- - Renamed indicroman to readablelatin
52
-
53
- ## 0.3.1
54
-
55
- - Improved Tamil transliteration based on rules
56
-
57
- ## 0.2.0
58
-
59
- - Fixed Sinhara symbols
60
-
61
- ## 0.1.9
62
-
63
- - modified easyroman and renamed to readablelatin
64
-
65
- ## 0.1.8
66
-
67
- - Made InferAnuswara automatic. Fixed Diacritic for Vowels.
68
-
69
- ## 0.1.7
70
-
71
- - fixed bug for indic
72
-
73
- ## 0.1.6
74
-
75
- - exported indic, added 2 scripts, fixed roman
76
-
77
- ## 0.1.5
78
-
79
- - Added fromString to Script enum
80
-
81
- ## 0.1.4
82
-
83
- - re-publish from correct branch.
84
-
85
- ## 0.1.3
86
-
87
- - Fixed build error
88
-
89
- ## 0.1.2
90
-
91
- - Added option to use ASCII numerals
92
-
93
- ## 0.1.1
94
-
95
- - fixed inferAnuswara for consonants after ma
96
-
97
- ## 0.1.0
98
-
99
- - Removed unnecessary Inditrans class. Added helpful scripts.
100
-
101
- ## 0.0.6
102
-
103
- - fixed example.
104
-
105
- ## 0.0.5
106
-
107
- - fixed android build issue.
108
-
109
- ## 0.0.4
110
-
111
- - removed unnecessary code and files.
112
-
113
- ## 0.0.3
114
-
115
- - Added comments and fixed formatting and example.
116
-
117
- ## 0.0.2
118
-
119
- - Fixed ffi_lib for non-web
120
-
121
- ## 0.0.1
122
-
123
- - Initial release