{"_id":"sango-nlp","name":"sango-nlp","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"sango-nlp","version":"0.1.0","description":"The first NLP toolkit for Sango, the national language of the Central African Republic","type":"module","main":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.js","types":"./dist/index.d.ts"}},"scripts":{"build":"tsc","clean":"rm -rf dist","prepublishOnly":"npm run clean && npm run build"},"keywords":["sango","nlp","natural-language-processing","tokenizer","stemmer","language-detection","central-african-republic","african-languages","linguistics"],"author":{"name":"MEYNG","email":"contact@meyng.com","url":"https://meyng.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/meyng-hub/sango-nlp.git"},"homepage":"https://sangoai.sbs","engines":{"node":">=18.0.0"},"devDependencies":{"typescript":"^5.4.0"},"_id":"sango-nlp@0.1.0","gitHead":"b7c1e5ab5f6b318ca020b5740180735228ad5763","bugs":{"url":"https://github.com/meyng-hub/sango-nlp/issues"},"_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-dzgljPutiRAlb9iQC/UBfFqIKj/tVCpjVYmgbciCc5QETTGbtkVI3FRFJhn/0oYyTYORkvwywaPwq73c5565Zg==","shasum":"cd4dfad85d954aa4b35901e558b4af7b51c272d0","tarball":"https://registry.npmjs.org/sango-nlp/-/sango-nlp-0.1.0.tgz","fileCount":23,"unpackedSize":109948,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIEuQd1vRZX18/3DFB22p77qMJEqr27+M2ZKACs5nCEHYAiAV5HLrU4g7jB1n9brHaqJB7Ao9QTCjs8KRh0gMwoHlmg=="}]},"_npmUser":{"name":"koyapit","email":"contact@meyng.com"},"directories":{},"maintainers":[{"name":"koyapit","email":"contact@meyng.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/sango-nlp_0.1.0_1775743004488_0.7394755000232802"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-09T13:56:44.487Z","0.1.0":"2026-04-09T13:56:44.628Z","modified":"2026-04-09T13:56:44.923Z"},"maintainers":[{"name":"koyapit","email":"contact@meyng.com"}],"description":"The first NLP toolkit for Sango, the national language of the Central African Republic","homepage":"https://sangoai.sbs","keywords":["sango","nlp","natural-language-processing","tokenizer","stemmer","language-detection","central-african-republic","african-languages","linguistics"],"repository":{"type":"git","url":"git+https://github.com/meyng-hub/sango-nlp.git"},"author":{"name":"MEYNG","email":"contact@meyng.com","url":"https://meyng.com"},"bugs":{"url":"https://github.com/meyng-hub/sango-nlp/issues"},"license":"MIT","readme":"# sango-nlp\n\nThe first NLP toolkit for **Sango** (ISO 639-1: `sg`), the national language of the Central African Republic, spoken by over 5 million people.\n\nBuilt by [MEYNG](https://meyng.com) as part of the [SangoAI](https://sangoai.sbs) platform.\n\n## Features\n\n- **Tokenizer** -- Splits Sango text into typed tokens (words, punctuation, numbers), correctly handling diacritics and hyphenated compounds\n- **Language Detection** -- Identifies Sango, French, or English text using character frequency analysis, word lists, and morphological patterns\n- **Stemmer** -- Reduces Sango words to base forms by stripping common prefixes (`wa-`, `a-`) and suffixes (`-ngo`, `-ngbi`)\n- **Normalization** -- Strips tonal diacritics for accent-insensitive comparison and search\n- **Dictionary** -- In-memory lookup with 80+ built-in entries, fuzzy matching, and diacritic-insensitive search\n\n## Installation\n\n```bash\nnpm install sango-nlp\n```\n\n## Quick Start\n\n```typescript\nimport {\n  tokenize,\n  detectLanguage,\n  stem,\n  normalize,\n  SangoDictionary,\n} from \"sango-nlp\";\n\n// Tokenize Sango text\nconst tokens = tokenize(\"Bara âla, tongana nye?\");\n// [\n//   { text: \"Bara\",    type: \"word\",        offset: 0 },\n//   { text: \"âla\",     type: \"word\",        offset: 5 },\n//   { text: \",\",       type: \"punctuation\", offset: 8 },\n//   { text: \"tongana\", type: \"word\",        offset: 10 },\n//   { text: \"nye\",     type: \"word\",        offset: 18 },\n//   { text: \"?\",       type: \"punctuation\", offset: 21 },\n// ]\n\n// Detect language\nconst result = detectLanguage(\"Mbî yeke nzoni\");\n// { language: \"sg\", confidence: 0.85, scores: { sg: 0.85, fr: 0.08, en: 0.07 } }\n\n// Stem words\nstem(\"längö\"); // \"lä\"  (strips nominalizer suffix -ngö)\nstem(\"wandë\"); // \"ndë\" (strips agentive prefix wa-)\n\n// Normalize (strip diacritics)\nnormalize(\"nzônî\"); // \"nzoni\"\nnormalize(\"Kôlï\"); // \"Koli\"\n\n// Dictionary lookup\nconst dict = new SangoDictionary();\nconst entry = dict.lookup(\"nzoni\");\n// { sango: \"Nzoni\", french: \"Bon/Bien\", english: \"Good/Well\", category: \"adjectives\", ... }\n\n// Fuzzy search\nconst results = dict.search(\"nzni\", { maxDistance: 2 });\n// Finds \"Nzoni\" with distance 1\n```\n\n## API Reference\n\n### Tokenizer\n\n#### `tokenize(text, options?)`\n\nSplits Sango text into an array of typed tokens.\n\n```typescript\ntokenize(text: string, options?: { includeWhitespace?: boolean }): Token[]\n```\n\nEach `Token` has:\n\n- `text` -- The raw token text\n- `type` -- `\"word\"` | `\"punctuation\"` | `\"number\"` | `\"whitespace\"` | `\"unknown\"`\n- `offset` -- Character position in the original text\n\n#### `extractWords(text)`\n\nConvenience function that returns only word tokens.\n\n#### `isParticle(token)`\n\nChecks if a token is a known Sango particle (na, ti, so, ni, ngba, etc.).\n\n### Language Detection\n\n#### `detectLanguage(text)`\n\n```typescript\ndetectLanguage(text: string): DetectionResult\n```\n\nReturns:\n\n- `language` -- `\"sg\"` | `\"fr\"` | `\"en\"` | `\"unknown\"`\n- `confidence` -- `0` to `1`\n- `scores` -- Per-language scores\n\nThe algorithm combines word matching (50%), character patterns (30%), and morphological analysis (20%).\n\n#### `isSango(text)`\n\nQuick boolean check (confidence threshold: 0.4).\n\n### Stemmer & Normalization\n\n#### `stem(word)`\n\nReduces a Sango word to its approximate base form.\n\n```typescript\nstem(\"längö\"); // \"lä\"\nstem(\"wandë\"); // \"ndë\"\nstem(\"nzoni\"); // \"nzoni\" (no affixes to strip)\n```\n\n#### `normalize(word)`\n\nStrips all diacritical marks (tone markers) from a word.\n\n```typescript\nnormalize(\"âêîôû\"); // \"aeiou\"\nnormalize(\"äëïöü\"); // \"aeiou\"\n```\n\n#### `equalsNormalized(a, b)`\n\nCompares two words ignoring diacritics and case.\n\n```typescript\nequalsNormalized(\"Kôlï\", \"koli\"); // true\n```\n\n#### `editDistance(a, b)`\n\nLevenshtein edit distance between two normalized words.\n\n### Dictionary\n\n#### `new SangoDictionary(additionalEntries?)`\n\nCreates a dictionary with 80+ built-in Sango entries.\n\n```typescript\nconst dict = new SangoDictionary();\n\ndict.lookup(\"nzoni\"); // Exact match (diacritic-insensitive)\ndict.lookupAny(\"bonjour\"); // Search across all languages\ndict.search(\"nzni\"); // Fuzzy search\ndict.getByCategory(\"verbs\"); // Filter by category\ndict.getCategories(); // List all categories\ndict.has(\"yeke\"); // Check existence\ndict.size; // Entry count\n```\n\n#### `lookup(word)` (standalone)\n\nConvenience function that creates a dictionary and looks up a word.\n\n```typescript\nimport { lookup } from \"sango-nlp\";\nlookup(\"yeke\"); // { sango: \"Yeke\", french: \"Etre\", english: \"To be\", ... }\n```\n\n## Sango Language Notes\n\nSango is a creole language based on Ngbandi, serving as the lingua franca and co-official language of the Central African Republic alongside French.\n\n### Orthography\n\nSango uses Latin script with tonal diacritics:\n\n- **Circumflex** (high tone): a, e, i, o, u\n- **Diaeresis** (mid tone): a, e, i, o, u\n- **No mark** (neutral/low tone): a, e, i, o, u\n\n### Phonology\n\nDistinctive consonant clusters: mb, nd, ng, ngb, nz, nj, ndr, gb, kp\n\n### Morphology\n\nSango is largely isolating but has productive affixes:\n\n- **wa-** prefix: agentive (person associated with noun)\n- **-ngo/-ngo** suffix: nominalizer (verb/adj to abstract noun)\n- **ti** particle: possessive (\"of\")\n- **na** particle: conjunction/preposition (\"and\", \"with\")\n\n## Zero Dependencies\n\nThis package has no runtime dependencies. It is pure TypeScript compiled to ESM.\n\n## Requirements\n\n- Node.js >= 18.0.0\n- TypeScript >= 5.0 (for development)\n\n## License\n\nMIT -- MEYNG (https://meyng.com)\n\n## Contributing\n\nContributions welcome, especially:\n\n- Additional vocabulary entries\n- Improved stemming rules\n- Native speaker linguistic review\n- Additional language detection training data\n\nPlease open an issue or PR at [github.com/meyng-hub/sango-nlp](https://github.com/meyng-hub/sango-nlp).\n","readmeFilename":"README.md","_rev":"1-e892c5c1712bb63cc1939fac810b87a7"}