@lacspace/nepali-match
Nepali and English matching for names and keywords in running text: normaliseNe() folds spelling variants (chandrabindu → anusvara, half nasal + consonant → anusvara, long/short vowels, nukta/ZWJ/ZWNJ, NFC, Devanagari digits); whole-word matching that lets Nepali postpositions follow a word (झापाको → Jhapa, जिल्लाहरूमा, काठमाडौंबाटै) but no other letters (पर्वतारोही ≠ Parbat); English whole words with short all-caps acronyms kept exact-case ("Come and see" ≠ SEE); near() for two terms within N characters in the same sentence (। . ? ! newline), dotted abbreviations kept together; offsets into the original text; splitSuffix(); and districtTerms() for all 77 districts with real-world spellings. Pure JS, zero dependencies, React Native safe.
npm i @lacspace/nepali-matchUsage
import { createMatcher, districtTerms, near, normaliseNe } from "@lacspace/nepali-match";
const areas = createMatcher(districtTerms());
areas.ids("चितवनमा बाढी, झापाको मेचीनगरमा पहिरो"); // ["chitwan", "jhapa"]
areas.test("दुई पर्वतारोही बेपत्ता"); // false
areas.find("काठमाण्डौबाटै आएका")[0];
// { id: "kathmandu", term: "काठमाण्डौ", lang: "ne", index: 0, end: 13, text: "काठमाण्डौबाटै", suffix: "बाटै" }
const exam = ["परीक्षा", "नतिजा", "विज्ञापन", "exam", "result"];
near("लोकसेवा आयोगले निजामती विधेयकमा राय दियो", "लोकसेवा", exam, 60); // null: not exam news
near("लोकसेवा आयोगको खरिदार परीक्षाको नतिजा", "लोकसेवा", exam, 60); // { a, b, gap }
createMatcher([{ id: "see", en: "SEE", ne: "एसईई" }]).test("Come and see"); // false
normaliseNe("काठमाडौँ") === normaliseNe("काठमाडौं"); // trueExports 12
POSTPOSITIONSVERSIONcontainscreateMatcherdistrictTermsfindTermsnearnormaliseNenormalizeNepreparesentenceSpanssplitSuffixKeywords
More in Nepal Toolkit
Nepal's official public holidays by Bikram Sambat year, transcribed from the Ministry of Home Affairs notice in Nepal Rajpatra (BS 2083: Khanda 75, Sankhya 67, Bhag 5). BS + AD dates, English/Nepali names, kind (public holiday / observance with offices open), scope (national, regional with districts, community, women, education, disability), multi-day Dashain and Tihar ranges, lunar holidays the notice leaves undated kept as null. holidays(), holidaysOn(), isHoliday(), upcoming(), bsToAD()/adToBS(). Every date checked against the weekday printed in the notice. Pure JS, zero dependencies, React Native safe.
@lacspace/preetiPreeti ⇄ Unicode for Nepali: convert legacy Preeti-font ASCII text ("g]kfn") to Unicode Devanagari (नेपाल) and back. Handles short-i and reph reordering, half letters, ra-kaar (| and «), conjunct keys (क्ष ज्ञ त्र श्र …), Preeti numerals, and looksLikePreeti() to detect pasted legacy text. Pure JS, zero dependencies, React Native safe.
@lacspace/nepali-typingRomanised Nepali → Devanagari typing with per-word candidates, like a phonetic input method: "namaste" → नमस्ते, "mero desh" → मेरो देश, "kathmandu" → काठमाडौं, "netaharulai" → नेताहरूलाई. A frequency lexicon matched by a loose key that forgives romanisation variance (aa/a, sh/s, w/v/b, ch/chh, dropped schwas, nasals), typed case endings, English loanwords (facebook → फेसबुक), a phonetic engine with ITRANS capitals (T D N Sh → ट ड ण ष), buildLexicon() from your own Nepali text and learn() to remember picks. Pure JS, zero dependencies, React Native safe.
@lacspace/nepali-dateBikram Sambat (BS) ↔ Gregorian (AD) date conversion — zero-dependency, isomorphic, with token formatting (Nepali digits & names), BS date arithmetic, parsing, calendar-month and fiscal-year helpers.
@lacspace/nepali-utilsEveryday Nepal helpers — NPR currency formatting, Devanagari numerals, amount-in-words, validators, provinces. Zero-dependency.
@lacspace/translitNepali ⇄ English name transliteration and cross-script fuzzy name matching — romanize Devanagari (schwa-deleted), generate spelling variants (Poudel/Paudel), strip honorifics, and match "Ram Chandra Poudel" to "रामचन्द्र पौडेल", with a per-token safety guard so different people who share a surname never collapse. Plus looksLikeName / isCommonWord so a search box doesn't transliterate ordinary words, and Devanagari-aware script-ratio analysis that ignores proper nouns and quotes. Zero-dependency, isomorphic, deterministic.