@vm75/inditrans 0.4.5 → 0.6.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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.6.0
2
+
3
+ - Refactoring and constants generation
4
+
5
+ ## 0.5.0
6
+
7
+ - Added support for Gurmukhi adhak
8
+
9
+ ## 0.4.6
10
+
11
+ - Fixed Zero Width Joiner and Non-Joiner
12
+
1
13
  ## 0.4.5
2
14
 
3
15
  - Support compound alternates and Malayalam Chillus
package/README.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # inditrans
2
2
 
3
- An experimental transliterator library for some [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
- - Uses wasm for near native performance.
6
- - No dependencies and no server needed.
7
- - Supports [vedic accents](https://en.wikipedia.org/wiki/Vedic_accent). Useful for vedic scriptures.
8
- - Smart transliteration to and from Tamil. Supports tamil superscript.
9
- - Very small footprint (< 80kb uncompressed).
10
- - Supports ITRANS toggle transliteration with ## and skipping HTML tags
5
+ - No dependencies and no server needed. Uses wasm for near native performance.
6
+ - Supports ITRANS toggle transliteration with ## and skipping XML tags
7
+ - Special handling for scripts like Tamil, Malayalam, Gurmukhi, etc. Tuned for reability.
8
+ - Supports [vedic accents](https://en.wikipedia.org/wiki/Vedic_accent) for vedic scriptures.
9
+
10
+ <!-- - [Demo](http://vm75.github.io/inditrans/example/) -->
11
+ - [Changelog](CHANGELOG.md)
11
12
 
12
13
  References:
13
14
 
@@ -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,30 @@
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
- indic = "indic",
10
11
  ipa = "ipa",
11
12
  iso = "iso",
12
13
  itrans = "itrans",
13
14
  kannada = "kannada",
15
+ khmer = "khmer",
14
16
  malayalam = "malayalam",
17
+ odia = "odia",
15
18
  oriya = "oriya",
19
+ punjabi = "punjabi",
20
+ readableLatin = "readableLatin",
21
+ sanskrit = "sanskrit",
16
22
  sinhala = "sinhala",
17
23
  tamil = "tamil",
18
- telugu = "telugu"
24
+ tamilExtended = "tamilExtended",
25
+ telugu = "telugu",
26
+ thai = "thai",
27
+ tibetan = "tibetan",
28
+ titus = "titus",
29
+ wx = "wx"
19
30
  }
@@ -1,24 +1,37 @@
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
- Script["indic"] = "indic";
14
17
  Script["ipa"] = "ipa";
15
18
  Script["iso"] = "iso";
16
19
  Script["itrans"] = "itrans";
17
20
  Script["kannada"] = "kannada";
21
+ Script["khmer"] = "khmer";
18
22
  Script["malayalam"] = "malayalam";
23
+ Script["odia"] = "odia";
19
24
  Script["oriya"] = "oriya";
25
+ Script["punjabi"] = "punjabi";
26
+ Script["readableLatin"] = "readableLatin";
27
+ Script["sanskrit"] = "sanskrit";
20
28
  Script["sinhala"] = "sinhala";
21
29
  Script["tamil"] = "tamil";
30
+ Script["tamilExtended"] = "tamilExtended";
22
31
  Script["telugu"] = "telugu";
32
+ Script["thai"] = "thai";
33
+ Script["tibetan"] = "tibetan";
34
+ Script["titus"] = "titus";
35
+ Script["wx"] = "wx";
23
36
  })(Script = exports.Script || (exports.Script = {}));
24
37
  //# sourceMappingURL=Script.js.map
Binary file
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vm75/inditrans",
3
- "version": "0.4.5",
4
- "description": "An experimental transliterator library for some Indic/Brahmic scripts.",
3
+ "version": "0.6.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
+ );