nko-kit 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +118 -2
- package/dist/chars.d.ts +38 -0
- package/dist/chars.js +97 -0
- package/dist/cjs/chars.d.ts +38 -0
- package/dist/cjs/chars.js +100 -0
- package/dist/cjs/index.d.ts +5 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/search.d.ts +13 -0
- package/dist/cjs/search.js +33 -0
- package/dist/cjs/text.d.ts +36 -0
- package/dist/cjs/text.js +132 -0
- package/dist/cjs/toLatin.d.ts +31 -0
- package/dist/cjs/toLatin.js +128 -0
- package/dist/cjs/toNko.d.ts +48 -0
- package/dist/cjs/toNko.js +246 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +4 -0
- package/dist/search.d.ts +13 -0
- package/dist/search.js +30 -0
- package/dist/text.d.ts +36 -0
- package/dist/text.js +121 -0
- package/dist/toLatin.d.ts +31 -0
- package/dist/toLatin.js +124 -0
- package/dist/toNko.d.ts +48 -0
- package/dist/toNko.js +242 -0
- package/package.json +58 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hamed Domo Ouologuem
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,119 @@
|
|
|
1
|
-
#
|
|
1
|
+
# nko-kit ߒߞߏ
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/MomoOuologuem/nko-kit/actions/workflows/ci.yml) [](https://www.npmjs.com/package/nko-kit)
|
|
4
|
+
|
|
5
|
+
Boîte à outils TypeScript pour le N'Ko et le bambara : passer du N'Ko à l'alphabet latin et inversement, gérer les tons, les chiffres et l'affichage de droite à gauche. Zéro dépendance.
|
|
6
|
+
|
|
7
|
+
*A TypeScript toolkit for N'Ko and Bambara: N'Ko ↔ Latin transliteration, tones, digits and right-to-left display. Zero dependencies. [English below](#english).*
|
|
8
|
+
|
|
9
|
+
> ⚠️ **Version 0.2, à relire par des personnes qui écrivent le N'Ko.** Les tables de correspondance viennent du standard Unicode et des notes du W3C. Si vous voyez une erreur, [ouvrez une issue](https://github.com/MomoOuologuem/nko-kit/issues) : c'est la contribution la plus utile.
|
|
10
|
+
|
|
11
|
+
## Pourquoi
|
|
12
|
+
|
|
13
|
+
Le N'Ko est très utilisé en ligne, notamment dans les groupes WhatsApp et Telegram, mais les développeurs ont peu d'outils pour le manipuler. `nko-kit` veut rendre le N'Ko aussi simple à gérer dans une application que l'alphabet latin.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install nko-kit
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Le paquet se charge avec `import` (ESM) comme avec `require` (CommonJS) et n'utilise aucune API propre à Node.
|
|
22
|
+
|
|
23
|
+
## Utilisation
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import {
|
|
27
|
+
toLatin, toNko, toNkoDetailed, isNko, toNkoDigits, isolateRtl, searchKey, textDirection,
|
|
28
|
+
} from "nko-kit";
|
|
29
|
+
// ou, en CommonJS : const { toLatin } = require("nko-kit");
|
|
30
|
+
|
|
31
|
+
toLatin("ߒߞߏ"); // "nko"
|
|
32
|
+
toLatin("ߓߡߊߣߊ߲ߞߊ߲"); // "bamanankan" (la voyelle non répétée est restituée)
|
|
33
|
+
toLatin("ߓߊ߰", { tones: "accents" }); // "bàa"
|
|
34
|
+
|
|
35
|
+
toNko("bá"); // "ߓߊ߫"
|
|
36
|
+
toNko("bolo", { elideVowels: true }); // "ߓߟߏ" (voyelle non répétée)
|
|
37
|
+
toNko("sèbèn", { legacyLatin: true }); // comme toNko("sɛbɛn")
|
|
38
|
+
toNkoDetailed("bamanankan");
|
|
39
|
+
// { text: "ߓߊߡߊߣߊ߲ߞߊ߲", missingTones: 4, warnings: [] }
|
|
40
|
+
|
|
41
|
+
searchKey("ߓߡߊߣߊ߲ߞߊ߲"); // "bamanankan"
|
|
42
|
+
searchKey("Bámànànkàn"); // "bamanankan" : même clé dans les deux écritures
|
|
43
|
+
textDirection("ߒߞߏ"); // "rtl"
|
|
44
|
+
|
|
45
|
+
isNko("ߒߞߏ"); // true
|
|
46
|
+
toNkoDigits("1949"); // "߁߉߄߉"
|
|
47
|
+
isolateRtl("ߒߞߏ"); // texte entouré d'isolats RTL pour l'affichage
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Ce qu'il faut savoir
|
|
51
|
+
|
|
52
|
+
**Les tons.** Le N'Ko note obligatoirement les tons, alors que le bambara en alphabet latin ne les écrit presque jamais. `toNko` ne peut donc pas deviner les tons : il convertit ceux qui sont écrits avec des accents (á haut, à bas, ǎ montant, â descendant) et compte les autres dans `missingTones`, pour qu'une personne les complète.
|
|
53
|
+
|
|
54
|
+
**La voyelle non répétée.** En N'Ko, quand deux syllabes qui se suivent ont la même voyelle, on n'écrit la voyelle qu'une fois : ߓߡߊߣߊ߲ se lit « bamanan ». `toLatin` restitue cette voyelle. `toNko` écrit toutes les voyelles par défaut. Avec `elideVowels: true`, il applique la règle telle que la décrivent les notes de r12a : « bolo » donne ߓߟߏ, mais « fafa » garde ses deux voyelles, car les deux consonnes sont identiques. Là où la source ne dit rien (tons différents, voyelles nasales ou longues), il garde la voyelle. Sans tons, il signale par un avertissement que les deux tons pourraient différer.
|
|
55
|
+
|
|
56
|
+
**Les lettres à plusieurs lectures.** Certaines lettres se lisent différemment selon le dialecte. Par exemple, ߜ sert pour *jɛ́*, *gɛ̀lɛn* et *woló* en bambara. `toLatinDetailed` renvoie un avertissement dans ce cas.
|
|
57
|
+
|
|
58
|
+
**L'ancienne orthographe.** Des textes plus anciens écrivent è pour ɛ et ò pour ɔ. Avec `legacyLatin: true`, `toNko` les lit ainsi. L'accent grave sur e et o ne marque alors plus un ton bas.
|
|
59
|
+
|
|
60
|
+
**La recherche.** `searchKey` donne la même clé à un mot, qu'il soit écrit en N'Ko ou en latin, avec ou sans tons, avec ɛ, ɔ, ɲ ou avec e, o, ny. Comparez la clé de la recherche à celle du texte, jamais les textes eux-mêmes.
|
|
61
|
+
|
|
62
|
+
**L'affichage.** `textDirection` indique si un texte se lit de droite à gauche, comme `dir="auto"` en HTML : utile pour aligner une bulle de discussion. Les chiffres N'Ko s'écrivent eux aussi de droite à gauche. `isolateRtl` empêche un mot en N'Ko de bousculer la phrase en français qui l'entoure.
|
|
63
|
+
|
|
64
|
+
## API
|
|
65
|
+
|
|
66
|
+
| Fonction | Rôle |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `toLatin(texte, options?)` | N'Ko → latin. `tones: "none"` (défaut) ou `"accents"` |
|
|
69
|
+
| `toLatinDetailed(texte, options?)` | Pareil, avec la liste des avertissements |
|
|
70
|
+
| `toNko(texte, options?)` | Latin → N'Ko, mode assisté. Options `elideVowels`, `legacyLatin`, `digits` |
|
|
71
|
+
| `toNkoDetailed(texte, options?)` | Pareil, avec `missingTones` et les avertissements |
|
|
72
|
+
| `searchKey(texte)` | Clé de recherche commune au N'Ko et au latin |
|
|
73
|
+
| `textDirection(texte)` | `"rtl"`, `"ltr"` ou `"neutral"`, d'après le premier caractère fort |
|
|
74
|
+
| `isNko(texte)`, `containsNko(texte)` | Détection du N'Ko |
|
|
75
|
+
| `stripTones(texte)`, `stripDiacritics(texte)` | Retire les tons (et la nasalisation), utile pour la recherche |
|
|
76
|
+
| `normalizeNko(texte)` | Remet les signes combinés dans l'ordre canonique |
|
|
77
|
+
| `toLatinDigits`, `toNkoDigits` | Chiffres N'Ko ↔ 0-9 |
|
|
78
|
+
| `isolateRtl(texte)` | Affichage correct du N'Ko au milieu d'un texte en français |
|
|
79
|
+
|
|
80
|
+
## Feuille de route
|
|
81
|
+
|
|
82
|
+
- [ ] Relecture complète des tables par des personnes qui écrivent le N'Ko
|
|
83
|
+
- [x] Appliquer la règle de la voyelle non répétée dans `toNko` (option `elideVowels`, à faire valider)
|
|
84
|
+
- [ ] Composant React de clavier N'Ko
|
|
85
|
+
- [ ] Dictionnaire de tons pour les mots courants (licence des sources à vérifier)
|
|
86
|
+
- [ ] Prise en charge du maninka et du dioula
|
|
87
|
+
|
|
88
|
+
Les changements de chaque version sont décrits dans [CHANGELOG.md](CHANGELOG.md).
|
|
89
|
+
|
|
90
|
+
## Contribuer
|
|
91
|
+
|
|
92
|
+
Les contributions sont les bienvenues, surtout de la part des personnes qui lisent et écrivent le N'Ko. Voir [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
93
|
+
|
|
94
|
+
## Sources
|
|
95
|
+
|
|
96
|
+
- [Tableau Unicode du bloc N'Ko (U+07C0–U+07FF)](https://unicode.org/charts/PDF/U07C0.pdf)
|
|
97
|
+
- [Notes sur l'orthographe N'Ko, r12a / W3C](https://r12a.github.io/scripts/nkoo/nqo.html)
|
|
98
|
+
- [Notes sur l'orthographe bambara en alphabet latin, r12a](https://r12a.github.io/scripts/latn/bm)
|
|
99
|
+
- [N'Ko Script Resources, W3C](https://www.w3.org/International/afrlreq/nko/)
|
|
100
|
+
- [Bambara's Latin Alphabet, An ka taa](https://kalan.ankataa.com/bambara-beg/grammar-i/bambaras-latin-alphabet) (ancienne orthographe è, ò)
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## English
|
|
105
|
+
|
|
106
|
+
`nko-kit` is a zero-dependency TypeScript toolkit for N'Ko and Bambara.
|
|
107
|
+
|
|
108
|
+
- `toLatin` converts N'Ko to Latin Bambara, restoring the vowel N'Ko does not repeat (ߓߡߊߣߊ߲ → *bamanan*), with tones dropped or written as accents.
|
|
109
|
+
- `toNko` converts Latin Bambara to N'Ko in **assisted mode**: Latin Bambara rarely writes tones, so tones given as accents are converted and the others are counted in `missingTones` for a human to add.
|
|
110
|
+
- `toNko` options: `elideVowels` drops a repeated vowel the N'Ko way ("bolo" → ߓߟߏ), `legacyLatin` reads the older spellings è and ò as ɛ and ɔ.
|
|
111
|
+
- `searchKey` gives the same search key to N'Ko and Latin spellings, with or without tones; `textDirection` tells whether a text runs right-to-left, like `dir="auto"`.
|
|
112
|
+
- Helpers for detection, tone stripping, digits and RTL isolation.
|
|
113
|
+
- Works with `import` (ESM) and `require` (CommonJS).
|
|
114
|
+
|
|
115
|
+
This is version 0.2. The tables come from the Unicode standard and W3C notes and **need review by fluent N'Ko writers**. Issues and pull requests are very welcome.
|
|
116
|
+
|
|
117
|
+
## Licence
|
|
118
|
+
|
|
119
|
+
MIT © Hamed Domo Ouologuem
|
package/dist/chars.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N'Ko characters (Unicode block U+07C0–U+07FF) and their Latin
|
|
3
|
+
* correspondences in the Bambara (Bamanankan) orthography.
|
|
4
|
+
*
|
|
5
|
+
* Sources: Unicode code chart U+07C0, W3C N'Ko notes (r12a).
|
|
6
|
+
* The Latin values follow the official Malian orthography.
|
|
7
|
+
* Every row should be checked by fluent N'Ko writers: open an issue
|
|
8
|
+
* if something is wrong.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NKO_RANGE_START = 1984;
|
|
11
|
+
export declare const NKO_RANGE_END = 2047;
|
|
12
|
+
/** Vowels: N'Ko → Latin. */
|
|
13
|
+
export declare const VOWELS: Readonly<Record<string, string>>;
|
|
14
|
+
/** Consonants: N'Ko → Latin. */
|
|
15
|
+
export declare const CONSONANTS: Readonly<Record<string, string>>;
|
|
16
|
+
/** Syllabic nasal ߒ (n'ko, "I"). */
|
|
17
|
+
export declare const SYLLABIC_N = "\u07D2";
|
|
18
|
+
/** Dagbasinna ߑ: explicitly marks the absence of a vowel. */
|
|
19
|
+
export declare const DAGBASINNA = "\u07D1";
|
|
20
|
+
/** Letters whose Latin reading depends on dialect or context. */
|
|
21
|
+
export declare const AMBIGUOUS_LETTERS: ReadonlySet<string>;
|
|
22
|
+
export type Tone = "high" | "low" | "rising" | "falling";
|
|
23
|
+
export interface ToneMark {
|
|
24
|
+
tone: Tone;
|
|
25
|
+
long: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Combining tone marks. A vowel with no mark is short and falling. */
|
|
28
|
+
export declare const TONE_MARKS: Readonly<Record<string, ToneMark>>;
|
|
29
|
+
/** Combining nasalization mark ߲. */
|
|
30
|
+
export declare const NASALIZATION = "\u07F2";
|
|
31
|
+
/** Combining double dot above ߳ (used for borrowed sounds). */
|
|
32
|
+
export declare const DOUBLE_DOT_ABOVE = "\u07F3";
|
|
33
|
+
/** Punctuation and symbols: N'Ko → Latin. */
|
|
34
|
+
export declare const PUNCTUATION: Readonly<Record<string, string>>;
|
|
35
|
+
/** Characters that carry no Latin equivalent and are dropped. */
|
|
36
|
+
export declare const DROPPED: ReadonlySet<string>;
|
|
37
|
+
/** Latin combining accents used to write tones. */
|
|
38
|
+
export declare const LATIN_TONE_ACCENTS: Readonly<Record<Tone, string>>;
|
package/dist/chars.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N'Ko characters (Unicode block U+07C0–U+07FF) and their Latin
|
|
3
|
+
* correspondences in the Bambara (Bamanankan) orthography.
|
|
4
|
+
*
|
|
5
|
+
* Sources: Unicode code chart U+07C0, W3C N'Ko notes (r12a).
|
|
6
|
+
* The Latin values follow the official Malian orthography.
|
|
7
|
+
* Every row should be checked by fluent N'Ko writers: open an issue
|
|
8
|
+
* if something is wrong.
|
|
9
|
+
*/
|
|
10
|
+
export const NKO_RANGE_START = 0x07c0;
|
|
11
|
+
export const NKO_RANGE_END = 0x07ff;
|
|
12
|
+
/** Vowels: N'Ko → Latin. */
|
|
13
|
+
export const VOWELS = {
|
|
14
|
+
"\u07CA": "a", // ߊ
|
|
15
|
+
"\u07CB": "e", // ߋ
|
|
16
|
+
"\u07CC": "i", // ߌ
|
|
17
|
+
"\u07CD": "ɛ", // ߍ
|
|
18
|
+
"\u07CE": "u", // ߎ
|
|
19
|
+
"\u07CF": "o", // ߏ
|
|
20
|
+
"\u07D0": "ɔ", // ߐ
|
|
21
|
+
};
|
|
22
|
+
/** Consonants: N'Ko → Latin. */
|
|
23
|
+
export const CONSONANTS = {
|
|
24
|
+
"\u07D3": "b", // ߓ
|
|
25
|
+
"\u07D4": "p", // ߔ
|
|
26
|
+
"\u07D5": "t", // ߕ
|
|
27
|
+
"\u07D6": "j", // ߖ
|
|
28
|
+
"\u07D7": "c", // ߗ
|
|
29
|
+
"\u07D8": "d", // ߘ
|
|
30
|
+
"\u07D9": "r", // ߙ
|
|
31
|
+
"\u07DA": "rr", // ߚ
|
|
32
|
+
"\u07DB": "s", // ߛ
|
|
33
|
+
"\u07DC": "g", // ߜ (gb in Maninka; read g in Bambara)
|
|
34
|
+
"\u07DD": "f", // ߝ
|
|
35
|
+
"\u07DE": "k", // ߞ
|
|
36
|
+
"\u07DF": "l", // ߟ
|
|
37
|
+
"\u07E0": "n", // ߠ na woloso
|
|
38
|
+
"\u07E1": "m", // ߡ
|
|
39
|
+
"\u07E2": "ɲ", // ߢ
|
|
40
|
+
"\u07E3": "n", // ߣ
|
|
41
|
+
"\u07E4": "h", // ߤ
|
|
42
|
+
"\u07E5": "w", // ߥ
|
|
43
|
+
"\u07E6": "y", // ߦ
|
|
44
|
+
"\u07E7": "ɲ", // ߧ nya woloso
|
|
45
|
+
"\u07E8": "j", // ߨ jona ja (rare)
|
|
46
|
+
"\u07E9": "c", // ߩ jona cha (rare)
|
|
47
|
+
"\u07EA": "r", // ߪ jona ra (rare)
|
|
48
|
+
};
|
|
49
|
+
/** Syllabic nasal ߒ (n'ko, "I"). */
|
|
50
|
+
export const SYLLABIC_N = "\u07D2";
|
|
51
|
+
/** Dagbasinna ߑ: explicitly marks the absence of a vowel. */
|
|
52
|
+
export const DAGBASINNA = "\u07D1";
|
|
53
|
+
/** Letters whose Latin reading depends on dialect or context. */
|
|
54
|
+
export const AMBIGUOUS_LETTERS = new Set([
|
|
55
|
+
"\u07DC", // ߜ g / gb / w (e.g. jɛ́, gɛ̀lɛn, woló share it)
|
|
56
|
+
"\u07E8",
|
|
57
|
+
"\u07E9",
|
|
58
|
+
"\u07EA",
|
|
59
|
+
]);
|
|
60
|
+
/** Combining tone marks. A vowel with no mark is short and falling. */
|
|
61
|
+
export const TONE_MARKS = {
|
|
62
|
+
"\u07EB": { tone: "high", long: false }, // ߫
|
|
63
|
+
"\u07EC": { tone: "low", long: false }, // ߬
|
|
64
|
+
"\u07ED": { tone: "rising", long: false }, // ߭
|
|
65
|
+
"\u07EE": { tone: "falling", long: true }, // ߮
|
|
66
|
+
"\u07EF": { tone: "high", long: true }, // ߯
|
|
67
|
+
"\u07F0": { tone: "low", long: true }, // ߰
|
|
68
|
+
"\u07F1": { tone: "rising", long: true }, // ߱
|
|
69
|
+
};
|
|
70
|
+
/** Combining nasalization mark ߲. */
|
|
71
|
+
export const NASALIZATION = "\u07F2";
|
|
72
|
+
/** Combining double dot above ߳ (used for borrowed sounds). */
|
|
73
|
+
export const DOUBLE_DOT_ABOVE = "\u07F3";
|
|
74
|
+
/** Punctuation and symbols: N'Ko → Latin. */
|
|
75
|
+
export const PUNCTUATION = {
|
|
76
|
+
"\u07F4": "'", // ߴ high tone apostrophe
|
|
77
|
+
"\u07F5": "'", // ߵ low tone apostrophe
|
|
78
|
+
"\u07F8": ",", // ߸ comma
|
|
79
|
+
"\u07F9": "!", // ߹ exclamation mark
|
|
80
|
+
"\u060C": ",", // ، Arabic comma, used in N'Ko text
|
|
81
|
+
"\u061B": ";", // ؛ Arabic semicolon
|
|
82
|
+
"\u061F": "?", // ؟ Arabic question mark
|
|
83
|
+
"\u2E1C": "«", // ⸜ left low paraphrase bracket
|
|
84
|
+
"\u2E1D": "»", // ⸝ right low paraphrase bracket
|
|
85
|
+
};
|
|
86
|
+
/** Characters that carry no Latin equivalent and are dropped. */
|
|
87
|
+
export const DROPPED = new Set([
|
|
88
|
+
"\u07FA", // ߺ lajanyalan (elongation)
|
|
89
|
+
"\u07FD", // ߽ dantayalan
|
|
90
|
+
]);
|
|
91
|
+
/** Latin combining accents used to write tones. */
|
|
92
|
+
export const LATIN_TONE_ACCENTS = {
|
|
93
|
+
high: "\u0301", // á
|
|
94
|
+
low: "\u0300", // à
|
|
95
|
+
rising: "\u030C", // ǎ
|
|
96
|
+
falling: "\u0302", // â
|
|
97
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* N'Ko characters (Unicode block U+07C0–U+07FF) and their Latin
|
|
3
|
+
* correspondences in the Bambara (Bamanankan) orthography.
|
|
4
|
+
*
|
|
5
|
+
* Sources: Unicode code chart U+07C0, W3C N'Ko notes (r12a).
|
|
6
|
+
* The Latin values follow the official Malian orthography.
|
|
7
|
+
* Every row should be checked by fluent N'Ko writers: open an issue
|
|
8
|
+
* if something is wrong.
|
|
9
|
+
*/
|
|
10
|
+
export declare const NKO_RANGE_START = 1984;
|
|
11
|
+
export declare const NKO_RANGE_END = 2047;
|
|
12
|
+
/** Vowels: N'Ko → Latin. */
|
|
13
|
+
export declare const VOWELS: Readonly<Record<string, string>>;
|
|
14
|
+
/** Consonants: N'Ko → Latin. */
|
|
15
|
+
export declare const CONSONANTS: Readonly<Record<string, string>>;
|
|
16
|
+
/** Syllabic nasal ߒ (n'ko, "I"). */
|
|
17
|
+
export declare const SYLLABIC_N = "\u07D2";
|
|
18
|
+
/** Dagbasinna ߑ: explicitly marks the absence of a vowel. */
|
|
19
|
+
export declare const DAGBASINNA = "\u07D1";
|
|
20
|
+
/** Letters whose Latin reading depends on dialect or context. */
|
|
21
|
+
export declare const AMBIGUOUS_LETTERS: ReadonlySet<string>;
|
|
22
|
+
export type Tone = "high" | "low" | "rising" | "falling";
|
|
23
|
+
export interface ToneMark {
|
|
24
|
+
tone: Tone;
|
|
25
|
+
long: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Combining tone marks. A vowel with no mark is short and falling. */
|
|
28
|
+
export declare const TONE_MARKS: Readonly<Record<string, ToneMark>>;
|
|
29
|
+
/** Combining nasalization mark ߲. */
|
|
30
|
+
export declare const NASALIZATION = "\u07F2";
|
|
31
|
+
/** Combining double dot above ߳ (used for borrowed sounds). */
|
|
32
|
+
export declare const DOUBLE_DOT_ABOVE = "\u07F3";
|
|
33
|
+
/** Punctuation and symbols: N'Ko → Latin. */
|
|
34
|
+
export declare const PUNCTUATION: Readonly<Record<string, string>>;
|
|
35
|
+
/** Characters that carry no Latin equivalent and are dropped. */
|
|
36
|
+
export declare const DROPPED: ReadonlySet<string>;
|
|
37
|
+
/** Latin combining accents used to write tones. */
|
|
38
|
+
export declare const LATIN_TONE_ACCENTS: Readonly<Record<Tone, string>>;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* N'Ko characters (Unicode block U+07C0–U+07FF) and their Latin
|
|
4
|
+
* correspondences in the Bambara (Bamanankan) orthography.
|
|
5
|
+
*
|
|
6
|
+
* Sources: Unicode code chart U+07C0, W3C N'Ko notes (r12a).
|
|
7
|
+
* The Latin values follow the official Malian orthography.
|
|
8
|
+
* Every row should be checked by fluent N'Ko writers: open an issue
|
|
9
|
+
* if something is wrong.
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.LATIN_TONE_ACCENTS = exports.DROPPED = exports.PUNCTUATION = exports.DOUBLE_DOT_ABOVE = exports.NASALIZATION = exports.TONE_MARKS = exports.AMBIGUOUS_LETTERS = exports.DAGBASINNA = exports.SYLLABIC_N = exports.CONSONANTS = exports.VOWELS = exports.NKO_RANGE_END = exports.NKO_RANGE_START = void 0;
|
|
13
|
+
exports.NKO_RANGE_START = 0x07c0;
|
|
14
|
+
exports.NKO_RANGE_END = 0x07ff;
|
|
15
|
+
/** Vowels: N'Ko → Latin. */
|
|
16
|
+
exports.VOWELS = {
|
|
17
|
+
"\u07CA": "a", // ߊ
|
|
18
|
+
"\u07CB": "e", // ߋ
|
|
19
|
+
"\u07CC": "i", // ߌ
|
|
20
|
+
"\u07CD": "ɛ", // ߍ
|
|
21
|
+
"\u07CE": "u", // ߎ
|
|
22
|
+
"\u07CF": "o", // ߏ
|
|
23
|
+
"\u07D0": "ɔ", // ߐ
|
|
24
|
+
};
|
|
25
|
+
/** Consonants: N'Ko → Latin. */
|
|
26
|
+
exports.CONSONANTS = {
|
|
27
|
+
"\u07D3": "b", // ߓ
|
|
28
|
+
"\u07D4": "p", // ߔ
|
|
29
|
+
"\u07D5": "t", // ߕ
|
|
30
|
+
"\u07D6": "j", // ߖ
|
|
31
|
+
"\u07D7": "c", // ߗ
|
|
32
|
+
"\u07D8": "d", // ߘ
|
|
33
|
+
"\u07D9": "r", // ߙ
|
|
34
|
+
"\u07DA": "rr", // ߚ
|
|
35
|
+
"\u07DB": "s", // ߛ
|
|
36
|
+
"\u07DC": "g", // ߜ (gb in Maninka; read g in Bambara)
|
|
37
|
+
"\u07DD": "f", // ߝ
|
|
38
|
+
"\u07DE": "k", // ߞ
|
|
39
|
+
"\u07DF": "l", // ߟ
|
|
40
|
+
"\u07E0": "n", // ߠ na woloso
|
|
41
|
+
"\u07E1": "m", // ߡ
|
|
42
|
+
"\u07E2": "ɲ", // ߢ
|
|
43
|
+
"\u07E3": "n", // ߣ
|
|
44
|
+
"\u07E4": "h", // ߤ
|
|
45
|
+
"\u07E5": "w", // ߥ
|
|
46
|
+
"\u07E6": "y", // ߦ
|
|
47
|
+
"\u07E7": "ɲ", // ߧ nya woloso
|
|
48
|
+
"\u07E8": "j", // ߨ jona ja (rare)
|
|
49
|
+
"\u07E9": "c", // ߩ jona cha (rare)
|
|
50
|
+
"\u07EA": "r", // ߪ jona ra (rare)
|
|
51
|
+
};
|
|
52
|
+
/** Syllabic nasal ߒ (n'ko, "I"). */
|
|
53
|
+
exports.SYLLABIC_N = "\u07D2";
|
|
54
|
+
/** Dagbasinna ߑ: explicitly marks the absence of a vowel. */
|
|
55
|
+
exports.DAGBASINNA = "\u07D1";
|
|
56
|
+
/** Letters whose Latin reading depends on dialect or context. */
|
|
57
|
+
exports.AMBIGUOUS_LETTERS = new Set([
|
|
58
|
+
"\u07DC", // ߜ g / gb / w (e.g. jɛ́, gɛ̀lɛn, woló share it)
|
|
59
|
+
"\u07E8",
|
|
60
|
+
"\u07E9",
|
|
61
|
+
"\u07EA",
|
|
62
|
+
]);
|
|
63
|
+
/** Combining tone marks. A vowel with no mark is short and falling. */
|
|
64
|
+
exports.TONE_MARKS = {
|
|
65
|
+
"\u07EB": { tone: "high", long: false }, // ߫
|
|
66
|
+
"\u07EC": { tone: "low", long: false }, // ߬
|
|
67
|
+
"\u07ED": { tone: "rising", long: false }, // ߭
|
|
68
|
+
"\u07EE": { tone: "falling", long: true }, // ߮
|
|
69
|
+
"\u07EF": { tone: "high", long: true }, // ߯
|
|
70
|
+
"\u07F0": { tone: "low", long: true }, // ߰
|
|
71
|
+
"\u07F1": { tone: "rising", long: true }, // ߱
|
|
72
|
+
};
|
|
73
|
+
/** Combining nasalization mark ߲. */
|
|
74
|
+
exports.NASALIZATION = "\u07F2";
|
|
75
|
+
/** Combining double dot above ߳ (used for borrowed sounds). */
|
|
76
|
+
exports.DOUBLE_DOT_ABOVE = "\u07F3";
|
|
77
|
+
/** Punctuation and symbols: N'Ko → Latin. */
|
|
78
|
+
exports.PUNCTUATION = {
|
|
79
|
+
"\u07F4": "'", // ߴ high tone apostrophe
|
|
80
|
+
"\u07F5": "'", // ߵ low tone apostrophe
|
|
81
|
+
"\u07F8": ",", // ߸ comma
|
|
82
|
+
"\u07F9": "!", // ߹ exclamation mark
|
|
83
|
+
"\u060C": ",", // ، Arabic comma, used in N'Ko text
|
|
84
|
+
"\u061B": ";", // ؛ Arabic semicolon
|
|
85
|
+
"\u061F": "?", // ؟ Arabic question mark
|
|
86
|
+
"\u2E1C": "«", // ⸜ left low paraphrase bracket
|
|
87
|
+
"\u2E1D": "»", // ⸝ right low paraphrase bracket
|
|
88
|
+
};
|
|
89
|
+
/** Characters that carry no Latin equivalent and are dropped. */
|
|
90
|
+
exports.DROPPED = new Set([
|
|
91
|
+
"\u07FA", // ߺ lajanyalan (elongation)
|
|
92
|
+
"\u07FD", // ߽ dantayalan
|
|
93
|
+
]);
|
|
94
|
+
/** Latin combining accents used to write tones. */
|
|
95
|
+
exports.LATIN_TONE_ACCENTS = {
|
|
96
|
+
high: "\u0301", // á
|
|
97
|
+
low: "\u0300", // à
|
|
98
|
+
rising: "\u030C", // ǎ
|
|
99
|
+
falling: "\u0302", // â
|
|
100
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { containsNko, isNko, isolateRtl, normalizeNko, stripDiacritics, stripTones, textDirection, toLatinDigits, toNkoDigits, type TextDirection, } from "./text.js";
|
|
2
|
+
export { searchKey } from "./search.js";
|
|
3
|
+
export { toLatin, toLatinDetailed, type ToLatinOptions, type ToLatinResult, type Warning, } from "./toLatin.js";
|
|
4
|
+
export { toNko, toNkoDetailed, type ToNkoOptions, type ToNkoResult, } from "./toNko.js";
|
|
5
|
+
export type { Tone } from "./chars.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toNkoDetailed = exports.toNko = exports.toLatinDetailed = exports.toLatin = exports.searchKey = exports.toNkoDigits = exports.toLatinDigits = exports.textDirection = exports.stripTones = exports.stripDiacritics = exports.normalizeNko = exports.isolateRtl = exports.isNko = exports.containsNko = void 0;
|
|
4
|
+
var text_js_1 = require("./text.js");
|
|
5
|
+
Object.defineProperty(exports, "containsNko", { enumerable: true, get: function () { return text_js_1.containsNko; } });
|
|
6
|
+
Object.defineProperty(exports, "isNko", { enumerable: true, get: function () { return text_js_1.isNko; } });
|
|
7
|
+
Object.defineProperty(exports, "isolateRtl", { enumerable: true, get: function () { return text_js_1.isolateRtl; } });
|
|
8
|
+
Object.defineProperty(exports, "normalizeNko", { enumerable: true, get: function () { return text_js_1.normalizeNko; } });
|
|
9
|
+
Object.defineProperty(exports, "stripDiacritics", { enumerable: true, get: function () { return text_js_1.stripDiacritics; } });
|
|
10
|
+
Object.defineProperty(exports, "stripTones", { enumerable: true, get: function () { return text_js_1.stripTones; } });
|
|
11
|
+
Object.defineProperty(exports, "textDirection", { enumerable: true, get: function () { return text_js_1.textDirection; } });
|
|
12
|
+
Object.defineProperty(exports, "toLatinDigits", { enumerable: true, get: function () { return text_js_1.toLatinDigits; } });
|
|
13
|
+
Object.defineProperty(exports, "toNkoDigits", { enumerable: true, get: function () { return text_js_1.toNkoDigits; } });
|
|
14
|
+
var search_js_1 = require("./search.js");
|
|
15
|
+
Object.defineProperty(exports, "searchKey", { enumerable: true, get: function () { return search_js_1.searchKey; } });
|
|
16
|
+
var toLatin_js_1 = require("./toLatin.js");
|
|
17
|
+
Object.defineProperty(exports, "toLatin", { enumerable: true, get: function () { return toLatin_js_1.toLatin; } });
|
|
18
|
+
Object.defineProperty(exports, "toLatinDetailed", { enumerable: true, get: function () { return toLatin_js_1.toLatinDetailed; } });
|
|
19
|
+
var toNko_js_1 = require("./toNko.js");
|
|
20
|
+
Object.defineProperty(exports, "toNko", { enumerable: true, get: function () { return toNko_js_1.toNko; } });
|
|
21
|
+
Object.defineProperty(exports, "toNkoDetailed", { enumerable: true, get: function () { return toNko_js_1.toNkoDetailed; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plain key for searching Bambara text whatever its script or spelling.
|
|
3
|
+
*
|
|
4
|
+
* N'Ko is first read as Latin (with `toLatin`). Then tones, accents and
|
|
5
|
+
* case are dropped, ɛ → e, ɔ → o, ɲ → ny, ŋ → ng, apostrophes vanish and
|
|
6
|
+
* every other run of characters that are not letters or digits becomes
|
|
7
|
+
* one space. Compare keys, never raw text:
|
|
8
|
+
*
|
|
9
|
+
* searchKey("ߓߡߊߣߊ߲ߞߊ߲") === "bamanankan"
|
|
10
|
+
* searchKey("Bámànànkàn") === "bamanankan"
|
|
11
|
+
* searchKey("ɲɔgɔn") === "nyogon"
|
|
12
|
+
*/
|
|
13
|
+
export declare function searchKey(text: string): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.searchKey = searchKey;
|
|
4
|
+
const toLatin_js_1 = require("./toLatin.js");
|
|
5
|
+
/** Letters folded to what a keyboard without them would type. */
|
|
6
|
+
const FOLD = {
|
|
7
|
+
"ɛ": "e",
|
|
8
|
+
"ɔ": "o",
|
|
9
|
+
"ɲ": "ny",
|
|
10
|
+
"ŋ": "ng",
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* A plain key for searching Bambara text whatever its script or spelling.
|
|
14
|
+
*
|
|
15
|
+
* N'Ko is first read as Latin (with `toLatin`). Then tones, accents and
|
|
16
|
+
* case are dropped, ɛ → e, ɔ → o, ɲ → ny, ŋ → ng, apostrophes vanish and
|
|
17
|
+
* every other run of characters that are not letters or digits becomes
|
|
18
|
+
* one space. Compare keys, never raw text:
|
|
19
|
+
*
|
|
20
|
+
* searchKey("ߓߡߊߣߊ߲ߞߊ߲") === "bamanankan"
|
|
21
|
+
* searchKey("Bámànànkàn") === "bamanankan"
|
|
22
|
+
* searchKey("ɲɔgɔn") === "nyogon"
|
|
23
|
+
*/
|
|
24
|
+
function searchKey(text) {
|
|
25
|
+
return (0, toLatin_js_1.toLatin)(text)
|
|
26
|
+
.normalize("NFD")
|
|
27
|
+
.replace(/\p{M}/gu, "")
|
|
28
|
+
.toLowerCase()
|
|
29
|
+
.replace(/[ɛɔɲŋ]/gu, (ch) => FOLD[ch])
|
|
30
|
+
.replace(/['`´‘’ʼ]/gu, "")
|
|
31
|
+
.replace(/[^\p{L}\p{N}]+/gu, " ")
|
|
32
|
+
.trim();
|
|
33
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** True if the text contains at least one N'Ko character. */
|
|
2
|
+
export declare function containsNko(text: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* True if every letter of the text is N'Ko. Spaces, digits and
|
|
5
|
+
* punctuation are ignored.
|
|
6
|
+
*/
|
|
7
|
+
export declare function isNko(text: string): boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Puts combining marks in canonical order (nasalization before tone)
|
|
10
|
+
* so that two spellings of the same word compare equal.
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeNko(text: string): string;
|
|
13
|
+
/** Removes tone marks, keeps nasalization. Useful for search. */
|
|
14
|
+
export declare function stripTones(text: string): string;
|
|
15
|
+
/** Removes tone marks and nasalization. */
|
|
16
|
+
export declare function stripDiacritics(text: string): string;
|
|
17
|
+
/** ߁߉߄߉ → 1949 */
|
|
18
|
+
export declare function toLatinDigits(text: string): string;
|
|
19
|
+
/** 1949 → ߁߉߄߉ */
|
|
20
|
+
export declare function toNkoDigits(text: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Wraps N'Ko text in Unicode directional isolates (RLI … PDI) so it
|
|
23
|
+
* displays right-to-left correctly inside left-to-right text, as the
|
|
24
|
+
* W3C recommends.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isolateRtl(text: string): string;
|
|
27
|
+
export type TextDirection = "rtl" | "ltr" | "neutral";
|
|
28
|
+
/**
|
|
29
|
+
* Direction of a text from its first strong character, like the HTML
|
|
30
|
+
* attribute dir="auto" and rule P2 of the Unicode bidi algorithm: N'Ko,
|
|
31
|
+
* Arabic, Hebrew, Adlam… give "rtl", Latin and other letters give "ltr".
|
|
32
|
+
* N'Ko and Adlam digits and the marks LRM, RLM and ALM also decide; other
|
|
33
|
+
* digits, punctuation, emoji and text inside directional isolates are
|
|
34
|
+
* skipped. A text with no strong character gives "neutral".
|
|
35
|
+
*/
|
|
36
|
+
export declare function textDirection(text: string): TextDirection;
|