@vm75/inditrans 0.3.5 → 0.3.6
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 +4 -0
- package/README.md +42 -29
- 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/utf8.d.ts +2 -2
- package/package.json +2 -2
- package/dist/src/IndiTrans.d.ts +0 -11
- package/dist/src/TranslitOptions.js +0 -14
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,45 +2,58 @@
|
|
|
2
2
|
|
|
3
3
|
An experimental transliterator library for some [Indic/Brahmi](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
8
|
|
|
9
9
|
References:
|
|
10
|
+
|
|
10
11
|
- [inditrans on Github](https://github.com/vm75/inditrans)
|
|
11
|
-
- [inditrans
|
|
12
|
+
- [inditrans for Flutter](https://pub.dev/packages/inditrans)
|
|
13
|
+
- [inditrans for nodejs](https://www.npmjs.com/package/@vm75/inditrans)
|
|
12
14
|
|
|
13
15
|
## Supported scripts
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
|
|
17
|
+
- Brahmi scripts:
|
|
18
|
+
- assamese
|
|
19
|
+
- bengali
|
|
20
|
+
- devanagari
|
|
21
|
+
- gujarati
|
|
22
|
+
- gurmukhi
|
|
23
|
+
- kannada
|
|
24
|
+
- malayalam
|
|
25
|
+
- oriya
|
|
26
|
+
- sinhala
|
|
27
|
+
- tamil
|
|
28
|
+
- telugu
|
|
29
|
+
- Roman scripts
|
|
30
|
+
- iast (https://en.wikipedia.org/wiki/International_Alphabet_of_Sanskrit_Transliteration)
|
|
31
|
+
- ipa (https://en.wikipedia.org/wiki/International_Phonetic_Alphabet)
|
|
32
|
+
- iso 15919 (https://en.wikipedia.org/wiki/ISO_15919)
|
|
33
|
+
- itrans (https://en.wikipedia.org/wiki/ITRANS)
|
|
34
|
+
- readablelatin (easy to read latin script)
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
npm install @vm75/inditrans
|
|
40
|
+
```
|
|
30
41
|
|
|
31
42
|
## Usage example
|
|
32
|
-
```dart
|
|
33
|
-
import 'package:inditrans/inditrans.dart' as inditrans;
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
```javascript
|
|
45
|
+
import * as inditrans from 'inditrans';
|
|
46
|
+
|
|
47
|
+
async function test() {
|
|
36
48
|
// Init needs to complete before Inditrans could be used
|
|
37
|
-
await
|
|
49
|
+
await indiTrans.init();
|
|
38
50
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
result = inditrans.transliterate(
|
|
52
|
+
"श्री॒ गु॒रु॒भ्यो नमः॒ । ह॒रिः॒ ओ३म् ॥",
|
|
53
|
+
inditrans.Script.devanagari,
|
|
54
|
+
inditrans.Script.tamil,
|
|
55
|
+
inditrans.Option.IgnoreVedicAccents + inditrans.Option.TamilSuperscripted
|
|
56
|
+
);
|
|
44
57
|
...
|
|
45
58
|
}
|
|
46
59
|
```
|
|
@@ -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/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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vm75/inditrans",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "An experimental transliterator library for some Indic scripts.",
|
|
5
5
|
"main": "./dist/src/index.js",
|
|
6
6
|
"author": "VM75",
|
|
@@ -23,7 +23,7 @@
|
|
|
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
25
|
"prepack": "yarn clean && yarn build",
|
|
26
|
-
"
|
|
26
|
+
"pub": "yarn test && npm publish --access=public"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/jest": "^27.0.2",
|
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
|