@vm75/inditrans 0.3.5 → 0.4.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 +9 -1
- package/README.md +44 -30
- package/dist/src/Inditrans.d.ts +12 -0
- package/dist/src/{IndiTrans.js → Inditrans.js} +7 -7
- package/dist/src/{IndiTransModule.d.ts → InditransModule.d.ts} +1 -1
- package/dist/src/{IndiTransModule.js → InditransModule.js} +1 -1
- package/dist/src/{TranslitOptions.d.ts → Option.d.ts} +1 -1
- package/dist/src/Option.js +14 -0
- package/dist/src/Script.d.ts +19 -0
- package/dist/src/Script.js +24 -0
- package/dist/src/index.d.ts +7 -3
- package/dist/src/index.js +19 -5
- package/dist/src/inditrans.wasm +0 -0
- package/dist/src/utf8.d.ts +2 -2
- package/package.json +29 -5
- package/dist/src/IndiTrans.d.ts +0 -11
- package/dist/src/TranslitOptions.js +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 0.4.0
|
|
2
|
+
|
|
3
|
+
- Lot of refactoring.
|
|
4
|
+
|
|
5
|
+
## 0.3.6
|
|
6
|
+
|
|
7
|
+
- Refactored nodejs interface. Updated readme.
|
|
8
|
+
|
|
1
9
|
## 0.3.5
|
|
2
10
|
|
|
3
11
|
- Fixed wasm, tests and nodejs support
|
|
@@ -28,7 +36,7 @@
|
|
|
28
36
|
|
|
29
37
|
## 0.1.8
|
|
30
38
|
|
|
31
|
-
- Made InferAnuswara automatic. Fixed
|
|
39
|
+
- Made InferAnuswara automatic. Fixed Diacritic for Vowels.
|
|
32
40
|
|
|
33
41
|
## 0.1.7
|
|
34
42
|
|
package/README.md
CHANGED
|
@@ -1,46 +1,60 @@
|
|
|
1
1
|
# inditrans
|
|
2
2
|
|
|
3
|
-
An experimental transliterator library for some [Indic/
|
|
3
|
+
An experimental transliterator library for some [Indic/Indic](https://en.wikipedia.org/wiki/Brahmic_scripts) scripts.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
- Self-contained and performant. Uses wasm.
|
|
6
|
+
- Supports [vedic accents](https://en.wikipedia.org/wiki/Vedic_accent). Useful for vedic scriptures.
|
|
7
|
+
- Smart transliteration to and from Tamil. Supports tamil superscript.
|
|
8
|
+
- Very small footprint (< 80kb uncompressed).
|
|
8
9
|
|
|
9
10
|
References:
|
|
11
|
+
|
|
10
12
|
- [inditrans on Github](https://github.com/vm75/inditrans)
|
|
11
|
-
- [inditrans
|
|
13
|
+
- [inditrans for Flutter](https://pub.dev/packages/inditrans)
|
|
14
|
+
- [inditrans for nodejs](https://www.npmjs.com/package/@vm75/inditrans)
|
|
12
15
|
|
|
13
16
|
## Supported scripts
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
|
|
18
|
+
- Indic/Brahmic scripts:
|
|
19
|
+
- assamese
|
|
20
|
+
- bengali
|
|
21
|
+
- devanagari
|
|
22
|
+
- gujarati
|
|
23
|
+
- gurmukhi
|
|
24
|
+
- kannada
|
|
25
|
+
- malayalam
|
|
26
|
+
- oriya
|
|
27
|
+
- sinhala
|
|
28
|
+
- tamil
|
|
29
|
+
- telugu
|
|
30
|
+
- Latin/Roman scripts
|
|
31
|
+
- iast (https://en.wikipedia.org/wiki/International_Alphabet_of_Sanskrit_Transliteration)
|
|
32
|
+
- ipa (https://en.wikipedia.org/wiki/International_Phonetic_Alphabet)
|
|
33
|
+
- iso 15919 (https://en.wikipedia.org/wiki/ISO_15919)
|
|
34
|
+
- itrans (https://en.wikipedia.org/wiki/ITRANS)
|
|
35
|
+
- readablelatin (easy to read in Latin alphabets with some customizations)
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
npm install @vm75/inditrans
|
|
41
|
+
```
|
|
30
42
|
|
|
31
43
|
## Usage example
|
|
32
|
-
```dart
|
|
33
|
-
import 'package:inditrans/inditrans.dart' as inditrans;
|
|
34
44
|
|
|
35
|
-
|
|
45
|
+
```javascript
|
|
46
|
+
import * as inditrans from 'inditrans';
|
|
47
|
+
|
|
48
|
+
async function test() {
|
|
36
49
|
// Init needs to complete before Inditrans could be used
|
|
37
|
-
await
|
|
50
|
+
await indiTrans.init();
|
|
38
51
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
52
|
+
result = inditrans.transliterate(
|
|
53
|
+
"श्री॒ गु॒रु॒भ्यो नमः॒ । ह॒रिः॒ ओ३म् ॥",
|
|
54
|
+
inditrans.Script.devanagari,
|
|
55
|
+
inditrans.Script.tamil,
|
|
56
|
+
inditrans.Option.IgnoreVedicAccents + inditrans.Option.TamilSuperscripted
|
|
57
|
+
);
|
|
44
58
|
...
|
|
45
59
|
}
|
|
46
60
|
```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Option } from './Option';
|
|
2
|
+
import { Script } from './Script';
|
|
3
|
+
export declare class Inditrans {
|
|
4
|
+
static instance: Promise<Inditrans>;
|
|
5
|
+
private static _init;
|
|
6
|
+
private module;
|
|
7
|
+
private memory;
|
|
8
|
+
private constructor();
|
|
9
|
+
private utf82ToString;
|
|
10
|
+
private stringToUtf8;
|
|
11
|
+
transliterate(text: string, from: Script, to: Script, options: Option): string;
|
|
12
|
+
}
|
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.Inditrans = void 0;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
class
|
|
9
|
-
static instance =
|
|
8
|
+
class Inditrans {
|
|
9
|
+
static instance = Inditrans._init();
|
|
10
10
|
static async _init() {
|
|
11
11
|
const { instance } = await WebAssembly.instantiate(fs_1.default.readFileSync(`${__dirname}/inditrans.wasm`));
|
|
12
|
-
return new
|
|
12
|
+
return new Inditrans(instance.exports);
|
|
13
13
|
}
|
|
14
14
|
module;
|
|
15
15
|
memory;
|
|
@@ -44,7 +44,7 @@ class IndiTrans {
|
|
|
44
44
|
return ret;
|
|
45
45
|
}
|
|
46
46
|
transliterate(text, from, to, options) {
|
|
47
|
-
const pointers = [text, from, to].map((str) => this.stringToUtf8(str));
|
|
47
|
+
const pointers = [text, from, to].map((str) => this.stringToUtf8(str.toString()));
|
|
48
48
|
const resultPtr = this.module.transliterate(pointers[0], pointers[1], pointers[2], options);
|
|
49
49
|
let result = '';
|
|
50
50
|
if (resultPtr !== 0) {
|
|
@@ -55,5 +55,5 @@ class IndiTrans {
|
|
|
55
55
|
return result;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
exports.
|
|
59
|
-
//# sourceMappingURL=
|
|
58
|
+
exports.Inditrans = Inditrans;
|
|
59
|
+
//# sourceMappingURL=Inditrans.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Option = void 0;
|
|
4
|
+
var Option;
|
|
5
|
+
(function (Option) {
|
|
6
|
+
Option[Option["None"] = 0] = "None";
|
|
7
|
+
Option[Option["IgnoreVedicAccents"] = 1] = "IgnoreVedicAccents";
|
|
8
|
+
Option[Option["IgnoreQuotedMarkers"] = 2] = "IgnoreQuotedMarkers";
|
|
9
|
+
Option[Option["TamilTraditional"] = 4] = "TamilTraditional";
|
|
10
|
+
Option[Option["TamilSuperscripted"] = 8] = "TamilSuperscripted";
|
|
11
|
+
Option[Option["RetainZeroWidthChars"] = 16] = "RetainZeroWidthChars";
|
|
12
|
+
Option[Option["ASCIINumerals"] = 32] = "ASCIINumerals";
|
|
13
|
+
})(Option = exports.Option || (exports.Option = {}));
|
|
14
|
+
//# sourceMappingURL=Option.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare enum Script {
|
|
2
|
+
assamese = "assamese",
|
|
3
|
+
bengali = "bengali",
|
|
4
|
+
devanagari = "devanagari",
|
|
5
|
+
readablelatin = "readablelatin",
|
|
6
|
+
gujarati = "gujarati",
|
|
7
|
+
gurmukhi = "gurmukhi",
|
|
8
|
+
iast = "iast",
|
|
9
|
+
indic = "indic",
|
|
10
|
+
ipa = "ipa",
|
|
11
|
+
iso = "iso",
|
|
12
|
+
itrans = "itrans",
|
|
13
|
+
kannada = "kannada",
|
|
14
|
+
malayalam = "malayalam",
|
|
15
|
+
oriya = "oriya",
|
|
16
|
+
sinhala = "sinhala",
|
|
17
|
+
tamil = "tamil",
|
|
18
|
+
telugu = "telugu"
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Script = void 0;
|
|
4
|
+
var Script;
|
|
5
|
+
(function (Script) {
|
|
6
|
+
Script["assamese"] = "assamese";
|
|
7
|
+
Script["bengali"] = "bengali";
|
|
8
|
+
Script["devanagari"] = "devanagari";
|
|
9
|
+
Script["readablelatin"] = "readablelatin";
|
|
10
|
+
Script["gujarati"] = "gujarati";
|
|
11
|
+
Script["gurmukhi"] = "gurmukhi";
|
|
12
|
+
Script["iast"] = "iast";
|
|
13
|
+
Script["indic"] = "indic";
|
|
14
|
+
Script["ipa"] = "ipa";
|
|
15
|
+
Script["iso"] = "iso";
|
|
16
|
+
Script["itrans"] = "itrans";
|
|
17
|
+
Script["kannada"] = "kannada";
|
|
18
|
+
Script["malayalam"] = "malayalam";
|
|
19
|
+
Script["oriya"] = "oriya";
|
|
20
|
+
Script["sinhala"] = "sinhala";
|
|
21
|
+
Script["tamil"] = "tamil";
|
|
22
|
+
Script["telugu"] = "telugu";
|
|
23
|
+
})(Script = exports.Script || (exports.Script = {}));
|
|
24
|
+
//# sourceMappingURL=Script.js.map
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { Option } from './Option';
|
|
2
|
+
import { Script } from './Script';
|
|
3
|
+
export { Option, Script };
|
|
4
|
+
export declare function init(): Promise<void>;
|
|
5
|
+
export declare function transliterate(text: string, from: Script, to: Script, options: Option): string;
|
|
6
|
+
declare const _default: (typeof Option | typeof Script | typeof init | typeof transliterate)[];
|
|
7
|
+
export default _default;
|
package/dist/src/index.js
CHANGED
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
exports.transliterate = exports.init = exports.Script = exports.Option = void 0;
|
|
4
|
+
const Inditrans_1 = require("./Inditrans");
|
|
5
|
+
const Option_1 = require("./Option");
|
|
6
|
+
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return Option_1.Option; } });
|
|
7
|
+
const Script_1 = require("./Script");
|
|
8
|
+
Object.defineProperty(exports, "Script", { enumerable: true, get: function () { return Script_1.Script; } });
|
|
9
|
+
let inditrans = null;
|
|
10
|
+
async function init() {
|
|
11
|
+
inditrans = await Inditrans_1.Inditrans.instance;
|
|
12
|
+
}
|
|
13
|
+
exports.init = init;
|
|
14
|
+
function transliterate(text, from, to, options) {
|
|
15
|
+
if (!inditrans) {
|
|
16
|
+
throw new Error('Inditrans not initialized');
|
|
17
|
+
}
|
|
18
|
+
return inditrans.transliterate(text, from, to, options);
|
|
19
|
+
}
|
|
20
|
+
exports.transliterate = transliterate;
|
|
21
|
+
exports.default = [Option_1.Option, Script_1.Script, init, transliterate];
|
|
8
22
|
//# sourceMappingURL=index.js.map
|
package/dist/src/inditrans.wasm
CHANGED
|
Binary file
|
package/dist/src/utf8.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InditransModule } from './InditransModule';
|
|
2
2
|
export declare class Codec {
|
|
3
3
|
private module;
|
|
4
4
|
private memory;
|
|
5
|
-
constructor(module:
|
|
5
|
+
constructor(module: InditransModule);
|
|
6
6
|
private stringToNativeArray;
|
|
7
7
|
private nativeArrayToString;
|
|
8
8
|
private stringToUtf82;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vm75/inditrans",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "An experimental transliterator library for some Indic scripts.",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "An experimental transliterator library for some Indic/Brahmic scripts.",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"author": "VM75",
|
|
7
7
|
"license": "MIT",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"watch": "tsc --watch",
|
|
23
23
|
"test": "yarn build && yarn jest --config jestconfig.json",
|
|
24
24
|
"copy-files": "shx mkdir -p dist/src && shx cp -f src/inditrans.wasm dist/src/",
|
|
25
|
-
"prepack": "yarn clean && yarn
|
|
26
|
-
"
|
|
25
|
+
"prepack": "yarn clean && yarn test",
|
|
26
|
+
"pub": "npm publish --access=public"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/jest": "^27.0.2",
|
|
@@ -39,5 +39,29 @@
|
|
|
39
39
|
"ts-jest": "^27.0.5",
|
|
40
40
|
"ts-node": "^10.9.1",
|
|
41
41
|
"typescript": "^4.5.4"
|
|
42
|
-
}
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"transliterator",
|
|
45
|
+
"transliteration",
|
|
46
|
+
"indian",
|
|
47
|
+
"indian language",
|
|
48
|
+
"indian script",
|
|
49
|
+
"devanagari",
|
|
50
|
+
"tamil",
|
|
51
|
+
"sanskrit",
|
|
52
|
+
"telugu",
|
|
53
|
+
"kannada",
|
|
54
|
+
"malayalam",
|
|
55
|
+
"bengali",
|
|
56
|
+
"gurmukhi",
|
|
57
|
+
"gujarati",
|
|
58
|
+
"oriya",
|
|
59
|
+
"brahmic",
|
|
60
|
+
"vedic accents",
|
|
61
|
+
"wasm",
|
|
62
|
+
"ISO 15919",
|
|
63
|
+
"IAST",
|
|
64
|
+
"ITRANS",
|
|
65
|
+
"IPA"
|
|
66
|
+
]
|
|
43
67
|
}
|
package/dist/src/IndiTrans.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { TranslitOptions } from './TranslitOptions';
|
|
2
|
-
export declare class IndiTrans {
|
|
3
|
-
static instance: Promise<IndiTrans>;
|
|
4
|
-
private static _init;
|
|
5
|
-
private module;
|
|
6
|
-
private memory;
|
|
7
|
-
private constructor();
|
|
8
|
-
private utf82ToString;
|
|
9
|
-
private stringToUtf8;
|
|
10
|
-
transliterate(text: string, from: string, to: string, options: TranslitOptions): string;
|
|
11
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TranslitOptions = void 0;
|
|
4
|
-
var TranslitOptions;
|
|
5
|
-
(function (TranslitOptions) {
|
|
6
|
-
TranslitOptions[TranslitOptions["None"] = 0] = "None";
|
|
7
|
-
TranslitOptions[TranslitOptions["IgnoreVedicAccents"] = 1] = "IgnoreVedicAccents";
|
|
8
|
-
TranslitOptions[TranslitOptions["IgnoreQuotedMarkers"] = 2] = "IgnoreQuotedMarkers";
|
|
9
|
-
TranslitOptions[TranslitOptions["TamilTraditional"] = 4] = "TamilTraditional";
|
|
10
|
-
TranslitOptions[TranslitOptions["TamilSuperscripted"] = 8] = "TamilSuperscripted";
|
|
11
|
-
TranslitOptions[TranslitOptions["RetainZeroWidthChars"] = 16] = "RetainZeroWidthChars";
|
|
12
|
-
TranslitOptions[TranslitOptions["ASCIINumerals"] = 32] = "ASCIINumerals";
|
|
13
|
-
})(TranslitOptions = exports.TranslitOptions || (exports.TranslitOptions = {}));
|
|
14
|
-
//# sourceMappingURL=TranslitOptions.js.map
|