From 0aa38bfb005ef924d14d7da0f5709a01d4087691 Mon Sep 17 00:00:00 2001 From: Bill D Date: Tue, 16 Mar 2021 17:35:41 +0400 Subject: [PATCH] w new g field --- .github/workflows/ci.yml | 5 +- package.json | 4 +- src/lib/dictionary-models.js | 27 +++--- src/lib/dictionary.proto | 13 +-- src/lib/dyn-comp-aux-verbs.ts | 52 ++++++++-- src/lib/pashto-inflector.test.ts | 31 ++++++ src/lib/protobuf.test.ts | 2 +- src/lib/simplify-phonetics.test.ts | 27 ++++++ src/lib/simplify-phonetics.ts | 32 +++++++ src/lib/verb-conjugation.ts | 2 +- src/lib/verb-info.test.ts | 146 ++++++++++++++++------------- src/lib/verb-info.ts | 1 + src/library.ts | 4 + src/types.ts | 87 +++++++++++------ 14 files changed, 305 insertions(+), 128 deletions(-) create mode 100644 src/lib/simplify-phonetics.test.ts create mode 100644 src/lib/simplify-phonetics.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 626fc4b..e5e7d7c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,14 +14,11 @@ jobs: env: LINGDOCS_DICTIONARY_URL: ${{ secrets.LINGDOCS_DICTIONARY_URL }} LINGDOCS_NPM_TOKEN: ${{ secrets.LINGDOCS_NPM_TOKEN }} - strategy: - matrix: - node-version: [12.x, 14.x, 15.x] steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 with: - node-version: ${{ matrix.node-version }} + node-version: 12 - run: yarn install - run: yarn build-library - run: yarn test \ No newline at end of file diff --git a/package.json b/package.json index ee02eca..52b9b0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "0.2.7", + "version": "0.2.8", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", @@ -63,7 +63,7 @@ "test": "react-scripts test", "eject": "react-scripts eject", "build-website": "node get-verbs.js && npm run build", - "build-library": "node get-verbs.js && rimraf dist && rimraf dist-cjs && tsc --project library-tsconfig.json && node library-post-build.js && rollup -c", + "build-library": "rimraf dist && rimraf dist-cjs && tsc --project library-tsconfig.json && node library-post-build.js && rollup -c", "test-ci": "npm run test -- --watchAll=false" }, "eslintConfig": { diff --git a/src/lib/dictionary-models.js b/src/lib/dictionary-models.js index 870a3ed..60a6f6d 100644 --- a/src/lib/dictionary-models.js +++ b/src/lib/dictionary-models.js @@ -1,4 +1,4 @@ -// code generated by pbf v3.2.1 - modified below on line 32 +// code generated by pbf v3.2.1 // DictionaryInfo ======================================== @@ -29,19 +29,19 @@ DictionaryInfo.write = function (obj, pbf) { var Entry = exports.Entry = {}; Entry.read = function (pbf, end) { - // modified so that objects do not include non-required fields unless added with Entry._readField below - return pbf.readFields(Entry._readField, {ts: 0, i: 0, p: "", f: "", e: ""}, end); + return pbf.readFields(Entry._readField, {ts: 0, i: 0, p: "", f: "", g: "", e: ""}, end); }; Entry._readField = function (tag, obj, pbf) { if (tag === 1) obj.ts = pbf.readVarint(true); else if (tag === 2) obj.i = pbf.readVarint(true); else if (tag === 3) obj.p = pbf.readString(); else if (tag === 4) obj.f = pbf.readString(); - else if (tag === 5) obj.e = pbf.readString(); - else if (tag === 6) obj.c = pbf.readString(); - else if (tag === 7) obj.l = pbf.readString(); - else if (tag === 8) obj.infap = pbf.readString(); - else if (tag === 9) obj.infaf = pbf.readString(); + else if (tag === 5) obj.g = pbf.readString(); + else if (tag === 6) obj.e = pbf.readString(); + else if (tag === 7) obj.c = pbf.readString(); + else if (tag === 8) obj.l = pbf.readVarint(true); + else if (tag === 9) obj.infap = pbf.readString(); + else if (tag === 10) obj.infaf = pbf.readString(); else if (tag === 11) obj.infbp = pbf.readString(); else if (tag === 12) obj.infbf = pbf.readString(); else if (tag === 13) obj.noInf = pbf.readString(); @@ -71,11 +71,12 @@ Entry.write = function (obj, pbf) { if (obj.i) pbf.writeVarintField(2, obj.i); if (obj.p) pbf.writeStringField(3, obj.p); if (obj.f) pbf.writeStringField(4, obj.f); - if (obj.e) pbf.writeStringField(5, obj.e); - if (obj.c) pbf.writeStringField(6, obj.c); - if (obj.l) pbf.writeStringField(7, obj.l); - if (obj.infap) pbf.writeStringField(8, obj.infap); - if (obj.infaf) pbf.writeStringField(9, obj.infaf); + if (obj.g) pbf.writeStringField(5, obj.g); + if (obj.e) pbf.writeStringField(6, obj.e); + if (obj.c) pbf.writeStringField(7, obj.c); + if (obj.l) pbf.writeVarintField(8, obj.l); + if (obj.infap) pbf.writeStringField(9, obj.infap); + if (obj.infaf) pbf.writeStringField(10, obj.infaf); if (obj.infbp) pbf.writeStringField(11, obj.infbp); if (obj.infbf) pbf.writeStringField(12, obj.infbf); if (obj.noInf) pbf.writeStringField(13, obj.noInf); diff --git a/src/lib/dictionary.proto b/src/lib/dictionary.proto index 589ac58..0944eee 100644 --- a/src/lib/dictionary.proto +++ b/src/lib/dictionary.proto @@ -13,12 +13,13 @@ message Entry { int32 ts = 1; int32 i = 2; string p = 3; - string f = 4; - string e = 5; - string c = 6; - string l = 7; - string infap = 8; - string infaf = 9; + string f = 4; + string g = 5; + string e = 6; + string c = 7; + int32 l = 8; + string infap = 9; + string infaf = 10; string infbp = 11; string infbf = 12; string noInf = 13; diff --git a/src/lib/dyn-comp-aux-verbs.ts b/src/lib/dyn-comp-aux-verbs.ts index def3ac3..cd42637 100644 --- a/src/lib/dyn-comp-aux-verbs.ts +++ b/src/lib/dyn-comp-aux-verbs.ts @@ -17,16 +17,17 @@ export const dynamicAuxVerbs: Array< } > = [ { - entry: {"i":10058,"ts":1527812752,"p":"کول","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, + entry: {"i":10058,"ts":1527812752,g: "","p":"کول","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, }, { - entry: {"i":10122,"ts":1527812754,"p":"کېدل","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, + entry: {"i":10122,"ts":1527812754,g: "","p":"کېدل","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, }, { entry: { ts:1527813914, p:"ورکول", f:"wărkawul", + g: "", e:"to give (to him, her, them, others)", c: "v. trans.", i:12350, @@ -37,18 +38,20 @@ export const dynamicAuxVerbs: Array< ts: 1527812157, p: "تېرول", f: "terawul", + g: "", e: "to pass (time), to take across, to pass, endure (difficulties)", c: "v. stat. comp. trans.", l: 1527813139, i: 3459, }, - complement: {"i":3774,"ts":1527813139,"p":"تېر","f":"ter","e":"last, past, previous, passed, gone over","c":"adj."}, + complement: {"i":3774,"ts":1527813139,g: "","p":"تېر","f":"ter","e":"last, past, previous, passed, gone over","c":"adj."}, }, { entry: { ts: 1527815399, p: "وهل", f: "wahul", + g: "", e: "to hit", c: "v. trans.", i: 12183, @@ -61,6 +64,7 @@ export const dynamicAuxVerbs: Array< ts: 1527817026, p: "کښل", f: "kxul", + g: "", e: "to drag, pull, take out, draw, get", c: "v. trans.", i: 8862, @@ -71,6 +75,7 @@ export const dynamicAuxVerbs: Array< ts: 1527814084, p: "لګول", f: "lagawul", + g: "", e: "to touch, join, use, take, place", c: "v. trans.", i: 9794, @@ -81,6 +86,7 @@ export const dynamicAuxVerbs: Array< ts: 1527814084, p: "لګول", f: "lagawul", + g: "", e: "to touch, join, use, take, place", c: "v. trans.", i: 9794, @@ -91,6 +97,7 @@ export const dynamicAuxVerbs: Array< ts: 1527817013, p: "ویل", f: "wayul, wayl", + g: "", e: "to say, to tell", c: "v. trans. indir.", i: 12229, @@ -101,6 +108,7 @@ export const dynamicAuxVerbs: Array< ts: 1527815396, p: "وایل", f: "waayul", + g: "", e: "to say, to tell", c: "v. trans. indir.", i: 11929, @@ -111,6 +119,7 @@ export const dynamicAuxVerbs: Array< ts: 1527812447, p: "اخستل", f: "akhustul", + g: "", e: "to take, buy, purchase, receive; to shave, cut with scissors", c: "v. trans.", i: 251, @@ -123,6 +132,7 @@ export const dynamicAuxVerbs: Array< ts: 1527817298, p: "اخیستل", f: "akheestul", + g: "", e: "to take, buy, purchase, receive; to shave, cut with scissors", c: "v. trans.", i: 266, @@ -133,6 +143,7 @@ export const dynamicAuxVerbs: Array< ts: 1527814617, p: "نیول", f: "neewul", + g: "", e: "to catch, grab, take, arrest; bear (fruit)", c: "v. trans. irreg.", i: 11880, @@ -145,6 +156,7 @@ export const dynamicAuxVerbs: Array< ts: 1527811872, p: "اچول", f: "achawul", + g: "", e: "to pour, drop, throw, put on", c: "v. trans.", i: 194, @@ -155,6 +167,7 @@ export const dynamicAuxVerbs: Array< ts: 1527812790, p: "خوړل", f: "khoRul", + g: "", e: "to eat, to bite", c: "v. trans.", i: 4769, @@ -169,6 +182,7 @@ export const dynamicAuxVerbs: Array< ts: 1527811868, p: "غښتل", f: "ghuxtul", + g: "", e: "to twist, curl, roll up, wrap up", c: "v. trans.", i: 7958, @@ -179,6 +193,7 @@ export const dynamicAuxVerbs: Array< ts: 1527816127, p: "اړول", f: "aRawul", + g: "", e: "to turn over, flip over; convert, change; to move over to, establish oneself in a new spot; divert, turn away, hijack; oblige, force", c: "v. trans.", i: 389, @@ -189,6 +204,7 @@ export const dynamicAuxVerbs: Array< ts: 1527812868, p: "لرل", f: "larul", + g: "", e: "to have, possess", c: "v. trans.", i: 9707, @@ -201,6 +217,7 @@ export const dynamicAuxVerbs: Array< ts: 1527813572, p: "رسول", f: "rasawul", + g: "", e: "to deliver, to make arrive, provide, send, supply, bring to,", c: "v. trans.", i: 5897, @@ -211,6 +228,7 @@ export const dynamicAuxVerbs: Array< ts: 1581619940636, p: "باسل", f: "baasul", + g: "", e: "to take out, extract, pull out, tear out", c: "v. trans.", i: 1115, @@ -221,6 +239,7 @@ export const dynamicAuxVerbs: Array< ts: 1527816146, p: "ایستل", f: "eestul", + g: "", e: "to throw out, discard, chuck, toss; to extract, to take out", c: "v. trans.", i: 1025, @@ -233,6 +252,7 @@ export const dynamicAuxVerbs: Array< ts: 1527818123, p: "څنډل", f: "tsanDúl", + g: "", e: "to shake out, shake off, brush aside", c: "v. trans.", i: 4975, @@ -245,6 +265,7 @@ export const dynamicAuxVerbs: Array< ts: 1527814862, p: "وژل", f: "wajzul", + g: "", e: "to kill, slaughter", c: "v. trans. irreg.", i: 12071, @@ -259,6 +280,7 @@ export const dynamicAuxVerbs: Array< ts: 1527813019, p: "ګرول", f: "grawul", + g: "", e: "to scratch, scrape", c: "v. trans.", i: 9370, @@ -269,6 +291,7 @@ export const dynamicAuxVerbs: Array< ts: 1527818260, p: "بادول", f: "baadawúl", + g: "", e: "to winnow, toss, throw to the wind, squander", c: "v. stat. comp. trans.", l: 1527816345, @@ -278,6 +301,7 @@ export const dynamicAuxVerbs: Array< ts: 1527816345, p: "باد", f: "baad", + g: "", e: "wind, air; swelling, rheumitism", c: "n. m.", i: 1076, @@ -288,6 +312,7 @@ export const dynamicAuxVerbs: Array< ts: 1527815343, p: "تېرېدل", f: "teredul", + g: "", e: "to pass, go across, go by", c: "v. stat. comp. intrans.", l: 1527813139, @@ -297,6 +322,7 @@ export const dynamicAuxVerbs: Array< ts: 1527813139, p: "تېر", f: "ter", + g: "", e: "last, past, previous, passed, gone over", c: "adj.", i: 3449, @@ -307,6 +333,7 @@ export const dynamicAuxVerbs: Array< ts: 1571859113828, p: "پخول", f: "pukhawul", + g: "", e: "to cook, prepare, to cause to ripen", c: "v. stat. comp. trans.", l: 1574867531681, @@ -316,6 +343,7 @@ export const dynamicAuxVerbs: Array< ts: 1574867531681, p: "پوخ", f: "pokh", + g: "", e: "mature, ripe, ready, cooked, able, skillful, experienced, tried, tested, true", c: "adj. irreg.", i: 2321, @@ -330,6 +358,7 @@ export const dynamicAuxVerbs: Array< ts: 1527817706, p: "ټکول", f: "Takawul", + g: "", e: "to knock, tap", c: "v. trans.", i: 3568, @@ -340,6 +369,7 @@ export const dynamicAuxVerbs: Array< ts: 1527812869, p: "لټول", f: "luTawul", + g: "", e: "to search, seek", c: "v. trans.", i: 9686, @@ -350,6 +380,7 @@ export const dynamicAuxVerbs: Array< ts: 1574784362578, p: "ډنګول", f: "Dangawul", + g: "", e: "to make sound, to make ring out, to meat to make a sound (like a symbal, pan, etc.)", c: "v. trans.", i: 5653, @@ -360,6 +391,7 @@ export const dynamicAuxVerbs: Array< ts: 1527811289, p: "کېنول", f: "kenawul", + g: "", e: "to seat, to make or have someone sit down", c: "v. trans.", i: 9240, @@ -371,6 +403,7 @@ export const dynamicAuxVerbs: Array< ts: 1527812873, p: "لوستل", f: "lwustul", + g: "", e: "to read, study", c: "v. trans. irreg.", i: 10163, @@ -384,24 +417,25 @@ export const dynamicAuxVerbs: Array< ts:1527814586, p:"چلول", f:"chalawul", + g: "", e:"to drive, operate, handle, put forward, circulate", c:"v. trans.", }, }, { - entry: {"i":6731,"ts":1527815240,"p":"ساتل","f":"saatul","e":"to keep, protect, watch over; to hold","c":"v. trans."}, + entry: {"i":6731,"ts":1527815240,"p":"ساتل","f":"saatul",g: "","e":"to keep, protect, watch over; to hold","c":"v. trans."}, }, { - entry: {"i":11782,"ts":1527814053,"p":"موندل","f":"moondúl","e":"to find, acquire, discover, get","c":"v. trans. irreg.","psp":"موم","psf":"moom"}, + entry: {"i":11782,"ts":1527814053,"p":"موندل","f":"moondúl",g: "","e":"to find, acquire, discover, get","c":"v. trans. irreg.","psp":"موم","psf":"moom"}, }, { - entry: {"i":4212,"ts":1527812712,"p":"جوړول","f":"joRawul","e":"to make, form, build, mend","l":1527812711,"c":"v. stat. comp. trans."}, - complement: {"i":4206,"ts":1527812711,"p":"جوړ","f":"joR","e":"well, healthy, whole, made","c":"adj."}, + entry: {"i":4212,"ts":1527812712,"p":"جوړول",g: "","f":"joRawul","e":"to make, form, build, mend","l":1527812711,"c":"v. stat. comp. trans."}, + complement: {"i":4206,"ts":1527812711,g: "","p":"جوړ","f":"joR","e":"well, healthy, whole, made","c":"adj."}, }, { - entry: {"i":13869,"ts":1527816865,"p":"وړل","f":"wuRúl, oRúl, wRul","e":"to take, carry, bear, move (inanimate objects); to win, earn (subjunctive یوسي - yósee or ویسي - wéesee, simple past یو یې وړلو - yo ye wRulo)","separationAtP":2,"separationAtF":2,"c":"v. trans. irreg.","ssp":"یوس","ssf":"yos","prp":"یوړل","prf":"yóRul","noOo":true,"diacExcept":true}, + entry: {"i":13869,"ts":1527816865,g: "","p":"وړل","f":"wuRúl, oRúl, wRul","e":"to take, carry, bear, move (inanimate objects); to win, earn (subjunctive یوسي - yósee or ویسي - wéesee, simple past یو یې وړلو - yo ye wRulo)","separationAtP":2,"separationAtF":2,"c":"v. trans. irreg.","ssp":"یوس","ssf":"yos","prp":"یوړل","prf":"yóRul","noOo":true,"diacExcept":true}, }, { - entry: {"i":6503,"ts":1527815214,"p":"راوړل","f":"raawRúl","e":"to bring, deliver (inanimate objects)","separationAtP":2,"separationAtF":3,"c":"v. trans. irreg.","noOo":true}, + entry: {"i":6503,"ts":1527815214,g: "","p":"راوړل","f":"raawRúl","e":"to bring, deliver (inanimate objects)","separationAtP":2,"separationAtF":3,"c":"v. trans. irreg.","noOo":true}, }, ]; diff --git a/src/lib/pashto-inflector.test.ts b/src/lib/pashto-inflector.test.ts index 8c68400..c85f2f8 100644 --- a/src/lib/pashto-inflector.test.ts +++ b/src/lib/pashto-inflector.test.ts @@ -24,6 +24,7 @@ const adjectives: Array<{ ts: 1527815451, p: "زوړ", f: "zoR", + g: "", e: "old", c: "adj. irreg.", i: 6264, @@ -51,6 +52,7 @@ const adjectives: Array<{ ts: 1527815306, p: "ستړی", f: "stúRey", + g: "", e: "tired", c: "adj.", i: 6564, @@ -74,6 +76,7 @@ const adjectives: Array<{ ts: 1527813636, p: "وروستی", f: "wroostéy", + g: "", e: "last, latest, recent", c: "adj.", i: 12026, @@ -97,6 +100,7 @@ const adjectives: Array<{ ts: 1527813498, p: "سپک", f: "spuk", + g: "", e: "light; dishonorable, not respectable", c: "adj.", i: 6502, @@ -119,6 +123,7 @@ const adjectives: Array<{ ts: 1527812862, p: "لوی", f: "looy", + g: "", e: "big, great, large", c: "adj.", i: 9945, @@ -141,6 +146,7 @@ const adjectives: Array<{ ts: 1527811469, p: "پوه", f: "poh", + g: "", e: "understanding, having understood; intelligent, quick, wise, clever; expert", c: "adj.", i: 2430, @@ -164,6 +170,7 @@ const adjectives: Array<{ ts: 1527812798, p: "خفه", f: "khufa", + g: "", e: "sad, upset, angry; choked, suffocated", c: "adj.", i: 4631, @@ -175,6 +182,7 @@ const adjectives: Array<{ ts: 1527814727, p: "اجباري", f: "ijbaaree", + g: "", e: "compulsory, obligatory", c: "adj.", i: 167, @@ -195,6 +203,7 @@ const nouns: Array<{ p: "مېلمه", f: "melmá", e: "guest", + g: "", c: "n. m. irreg. unisex", i: 11244, infap: "مېلمانه", @@ -221,6 +230,7 @@ const nouns: Array<{ ts: 1527814159, p: "ملګری", f: "malgúrey", + g: "", e: "friend, companion", c: "n. m. unisex", i: 10943, @@ -244,6 +254,7 @@ const nouns: Array<{ ts: 1527816431, p: "ترورزی", f: "trorzéy", + g: "", e: "cousin (son of paternal aunt)", c: "n. m. unisex", i: 2900, @@ -267,6 +278,7 @@ const nouns: Array<{ ts: 1527820043, p: "چرګ", f: "churg", + g: "", e: "rooster, cock; chicken, poultry", c: "n. m. unisex", i: 4101, @@ -291,6 +303,7 @@ const nouns: Array<{ ts: 1527815251, p: "سړی", f: "saRey", + g: "", e: "man", c: "n. m.", i: 6750, @@ -309,6 +322,7 @@ const nouns: Array<{ ts: 1527818511, p: "ترېلی", f: "treléy", + g: "", e: "pool, reservoir", c: "n. m.", i: 2931, @@ -328,6 +342,7 @@ const nouns: Array<{ ts: 1586760783536, p: "مشرتوب", f: "mushurtob", + g: "", e: "leadership, authority, presidency", c: "n. m.", }, @@ -345,6 +360,7 @@ const nouns: Array<{ ts: 1527813809, p: "لمونځ", f: "lamoondz", + g: "", e: "Muslim ritual prayers (namaz, salah, salat)", c: "n. m. irreg.", i: 9835, @@ -367,6 +383,7 @@ const nouns: Array<{ ts: 1527812817, p: "کتاب", f: "kitaab", + g: "", e: "book", c: "n. m.", i: 8640, @@ -380,6 +397,7 @@ const nouns: Array<{ ts: 1527812797, p: "ښځه", f: "xudza", + g: "", e: "woman, wife", c: "n. f.", i: 7444, @@ -397,6 +415,7 @@ const nouns: Array<{ ts: 1527821380, p: "اره", f: "ará", + g: "", e: "saw (the tool)", c: "n. f.", i: 365, @@ -415,6 +434,7 @@ const nouns: Array<{ ts: 1527820693, p: "مرجع", f: "marja'", + g: "", e: "reference, authority, body, place to go (for help, shelter, etc.)", c: "n. f.", i: 10661, @@ -434,6 +454,7 @@ const nouns: Array<{ ts: 1527820212, p: "منبع", f: "manbá", + g: "", e: "source, origin, resource, cause", c: "n. f.", i: 11201, @@ -454,6 +475,7 @@ const nouns: Array<{ ts: 1527815506, p: "ذبح", f: "zabha", + g: "", e: "slaughter, killing, butchering", c: "n. f.", i: 5813, @@ -472,6 +494,7 @@ const nouns: Array<{ ts: 1527814150, p: "لار", f: "laar", + g: "", e: "road, way, path", c: "n. f.", i: 9593, @@ -490,6 +513,7 @@ const nouns: Array<{ ts: 1527812928, p: "مور", f: "mor", + g: "", e: "mother, mom", c: "n. f. anim.", i: 11113, @@ -502,6 +526,7 @@ const nouns: Array<{ ts: 1527811877, p: "دوستي", f: "dostee", + g: "", e: "friendship", c: "n. f.", i: 5503, @@ -520,6 +545,7 @@ const nouns: Array<{ ts: 1527814203, p: "کرسۍ", f: "kUrsuy", + g: "", e: "chair, seat, stool", c: "n. f.", i: 8718, @@ -538,6 +564,7 @@ const nouns: Array<{ ts: 1527812456, p: "اړتیا", f: "aRtiyaa, aRtyaa", + g: "", e: "need, necessity", c: "n. f.", i: 376, @@ -556,6 +583,7 @@ const nouns: Array<{ ts: 1527821388, p: "وداع", f: "widáa'", + g: "", e: "farewell, goodbye", c: "n. f.", i: 12205, @@ -574,6 +602,7 @@ const nouns: Array<{ ts: 1527815402, p: "وړ", f: "waR", + g: "", e: "worthy of, deserving, -able", c: "suff. / adj.", i: 12045, @@ -588,6 +617,7 @@ const others: T.DictionaryEntry[] = [ ts: 1527812612, p: "ګنډل", f: "ganDul", + g: "", e: "to sew, mend, make, knit", c: "v. trans.", i: 9448, @@ -596,6 +626,7 @@ const others: T.DictionaryEntry[] = [ ts: 1527812457, p: "اصلاً", f: "aslan", + g: "", e: "actually", c: "adv.", i: 550, diff --git a/src/lib/protobuf.test.ts b/src/lib/protobuf.test.ts index e0f3eea..20f86f1 100644 --- a/src/lib/protobuf.test.ts +++ b/src/lib/protobuf.test.ts @@ -18,7 +18,7 @@ const sampleDictionaryInfo: T.DictionaryInfo = { const sampleDictionary: T.Dictionary = { info: sampleDictionaryInfo, entries: [ - {"i":616,"ts":1527813108,"p":"اظهار","f":"izháar","e":"expression, statement, declaration","c":"n. m."}, + {"i":616,"ts":1527813108,"p":"اظهار","f":"izháar","g":"izhaar","e":"expression, statement, declaration","c":"n. m."}, ], } diff --git a/src/lib/simplify-phonetics.test.ts b/src/lib/simplify-phonetics.test.ts new file mode 100644 index 0000000..0a9ceac --- /dev/null +++ b/src/lib/simplify-phonetics.test.ts @@ -0,0 +1,27 @@ +/** + * Copyright (c) 2021 lingdocs.com + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +import { simplifyPhonetics } from "./simplify-phonetics"; + +const toTest: [string, string][] = [ + ["saRéy", "saRey"], + ["Utráa`ee", "Utraaee"], + ["be kaar", "bekaar"], + ["ma'alóom", "maaloom"], + ["lÚtfan", "lUtfan"], + ["písta", "pista"], + ["săr", "sar"], + ["kawúl", "kawul"], + ["sắr", "sar"], +]; + +test("simplifyPhonetics should work", () => { + toTest.forEach((pair) => { + expect(simplifyPhonetics(pair[0])).toEqual(pair[1]); + }); +}); \ No newline at end of file diff --git a/src/lib/simplify-phonetics.ts b/src/lib/simplify-phonetics.ts new file mode 100644 index 0000000..9bd6b90 --- /dev/null +++ b/src/lib/simplify-phonetics.ts @@ -0,0 +1,32 @@ +/** + * Copyright (c) 2021 lingdocs.com + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + +const matcher = { + q: "k", + á: "a", + ă: "a", + ú: "u", + é: "e", + í: "i", + ó: "o", + G: "g", + Ú: "U", + "\u0301": "", + " ": "", + "'": "", + "`": "", +}; + +const fRepRegex = / |Ú|á|ă|ú|é|í|ó|G|q|'|`|\u0301/g; + +export function simplifyPhonetics(f: string): string { + return f.replace(fRepRegex, (mtch) => { + // @ts-ignore + return matcher[mtch]; + }); +} \ No newline at end of file diff --git a/src/lib/verb-conjugation.ts b/src/lib/verb-conjugation.ts index 63660cd..4a977e0 100644 --- a/src/lib/verb-conjugation.ts +++ b/src/lib/verb-conjugation.ts @@ -45,7 +45,7 @@ import { } from "./misc-helpers"; import * as T from "../types"; -const dummyEntry: T.DictionaryEntry = { i: 0, p: "", f: "", e: "", c: "", ts: 0 }; +const dummyEntry: T.DictionaryEntry = { i: 0, p: "", f: "", g: "", e: "", c: "", ts: 0 }; const getAayTail = (type: T.AayTail): T.PsString => ( type === "ey" diff --git a/src/lib/verb-info.test.ts b/src/lib/verb-info.test.ts index d5b0d4f..483db7d 100644 --- a/src/lib/verb-info.test.ts +++ b/src/lib/verb-info.test.ts @@ -13,7 +13,7 @@ import { const toTest = [ // simple verbs { - entry: {"i":10996,"ts":1527812856,"p":"لیکل","f":"leekul","e":"to write","c":"v. trans."}, + entry: {"i":10996,"ts":1527812856,"p":"لیکل","g":"","f":"leekul","e":"to write","c":"v. trans."}, result: { transitivity: "transitive", type: "simple", @@ -50,7 +50,7 @@ const toTest = [ }, }, { - entry: {"i":10243,"ts":1527812645,"p":"ګرځېدل","f":"gurdzedul","e":"to walk, wander, turn about; to become, to be","c":"v. intrans.","shortIntrans":true}, + entry: {"i":10243,"ts":1527812645,"p":"ګرځېدل","g":"","f":"gurdzedul","e":"to walk, wander, turn about; to become, to be","c":"v. intrans.","shortIntrans":true}, result: { transitivity: "intransitive", type: "simple", @@ -102,7 +102,7 @@ const toTest = [ }, }, { - entry: {"i":13664,"ts":1527823376,"p":"وتل","f":"watul","e":"to go out, exit, leave, emerge","c":"v. intrans. irreg.","psp":"وځ","psf":"oodz","tppp":"واته","tppf":"waatu"}, + entry: {"i":13664,"ts":1527823376,"p":"وتل","g":"","f":"watul","e":"to go out, exit, leave, emerge","c":"v. intrans. irreg.","psp":"وځ","psf":"oodz","tppp":"واته","tppf":"waatu"}, result: { transitivity: "intransitive", type: "simple", @@ -155,7 +155,7 @@ const toTest = [ }, }, { - entry: {"i":13801,"ts":1527816865,"p":"وړل","f":"oRúl, wRul, wuRúl","e":"to take, carry, bear, move (inanimate objects); to win, earn (subjunctive یوسي - yósee or ویسي - wéesee, simple past یو یې وړلو - yo ye wRulo)","separationAtP":2,"separationAtF":2,"c":"v. trans. irreg.","ssp":"یوس","ssf":"yos","prp":"یوړل","prf":"yóRul","noOo":true,"diacExcept":true}, + entry: {"i":13801,"ts":1527816865,"p":"وړل","g":"","f":"oRúl, wRul, wuRúl","e":"to take, carry, bear, move (inanimate objects); to win, earn (subjunctive یوسي - yósee or ویسي - wéesee, simple past یو یې وړلو - yo ye wRulo)","separationAtP":2,"separationAtF":2,"c":"v. trans. irreg.","ssp":"یوس","ssf":"yos","prp":"یوړل","prf":"yóRul","noOo":true,"diacExcept":true}, result: { transitivity: "transitive", type: "simple", @@ -204,7 +204,7 @@ const toTest = [ }, }, { - entry: {"i":13801,"ts":1527816865,"p":"وړل","f":"wRul, oRúl, wuRúl","e":"to take, carry, bear, move (inanimate objects); to win, earn (subjunctive یوسي - yósee or ویسي - wéesee, simple past یو یې وړلو - yo ye wRulo)","separationAtP":2,"separationAtF":2,"c":"v. trans. irreg.","ssp":"یوس","ssf":"yos","prp":"یوړل","prf":"yóRul","noOo":true,"diacExcept":true}, + entry: {"i":13801,"ts":1527816865,"p":"وړل","g":"","f":"wRul, oRúl, wuRúl","e":"to take, carry, bear, move (inanimate objects); to win, earn (subjunctive یوسي - yósee or ویسي - wéesee, simple past یو یې وړلو - yo ye wRulo)","separationAtP":2,"separationAtF":2,"c":"v. trans. irreg.","ssp":"یوس","ssf":"yos","prp":"یوړل","prf":"yóRul","noOo":true,"diacExcept":true}, result: { transitivity: "transitive", type: "simple", @@ -253,7 +253,7 @@ const toTest = [ }, }, { - entry: {"i":6503,"ts":1527815214,"p":"راوړل","f":"raawRúl","e":"to bring, deliver (inanimate objects)","separationAtP":2,"separationAtF":3,"c":"v. trans. irreg.","noOo":true}, + entry: {"i":6503,"ts":1527815214,"p":"راوړل","g":"","f":"raawRúl","e":"to bring, deliver (inanimate objects)","separationAtP":2,"separationAtF":3,"c":"v. trans. irreg.","noOo":true}, result: { transitivity: "transitive", type: "simple", @@ -302,7 +302,7 @@ const toTest = [ }, }, { - entry: {"i":5514,"ts":1527812790,"p":"خوړل","f":"khoRul","e":"to eat, to bite","c":"v. trans.","psp":"خور","psf":"khor","tppp":"خوړ","tppf":"khoR"}, + entry: {"i":5514,"ts":1527812790,"p":"خوړل","g":"","f":"khoRul","e":"to eat, to bite","c":"v. trans.","psp":"خور","psf":"khor","tppp":"خوړ","tppf":"khoR"}, result: { transitivity: "transitive", type: "simple", @@ -349,7 +349,7 @@ const toTest = [ }, }, { - entry: {"i":1675,"ts":1527822381,"p":"بنګېدل","f":"bungedúl","e":"to buzz, hum, jingle; to snuffle, to speak nasally, or with a twang","c":"v. intrans."}, + entry: {"i":1675,"ts":1527822381,"p":"بنګېدل","g":"","f":"bungedúl","e":"to buzz, hum, jingle; to snuffle, to speak nasally, or with a twang","c":"v. intrans."}, result: { transitivity: "intransitive", type: "simple", @@ -390,7 +390,7 @@ const toTest = [ }, }, { - entry: {"i":10144,"ts":1527812759,"p":"کېناستل","f":"kenaastul","e":"to sit","separationAtP":2,"separationAtF":2,"c":"v. intrans. irreg.","psp":"کېن","psf":"ken","noOo":true}, + entry: {"i":10144,"ts":1527812759,"p":"کېناستل","g":"","f":"kenaastul","e":"to sit","separationAtP":2,"separationAtF":2,"c":"v. intrans. irreg.","psp":"کېن","psf":"ken","noOo":true}, result: { transitivity: "intransitive", type: "simple", @@ -431,7 +431,7 @@ const toTest = [ }, }, { - entry: {"i":445,"ts":1527811605,"p":"ازمویل","f":"azmoyul","e":"to attempt, try; to experiment, test","c":"v. trans.","sepOo":true}, + entry: {"i":445,"ts":1527811605,"p":"ازمویل","g":"","f":"azmoyul","e":"to attempt, try; to experiment, test","c":"v. trans.","sepOo":true}, result: { transitivity: "transitive", type: "simple", @@ -462,7 +462,7 @@ const toTest = [ }, }, { - entry: {"i":8896,"ts":1527812627,"p":"غوښتل","f":"ghwuxtul, ghoxtul","e":"to want, to request","c":"v. trans.","psp":"غواړ","psf":"ghwaaR"}, + entry: {"i":8896,"ts":1527812627,"p":"غوښتل","g":"","f":"ghwuxtul, ghoxtul","e":"to want, to request","c":"v. trans.","psp":"غواړ","psf":"ghwaaR"}, result: { transitivity: "transitive", type: "simple", @@ -498,7 +498,7 @@ const toTest = [ }, }, { - entry: {"i":300,"ts":1527817298,"p":"اخیستل","f":"akheestul","e":"to take, buy, purchase, receive; to shave, cut with scissors","c":"v. trans.","psp":"اخل","psf":"akhl"}, + entry: {"i":300,"ts":1527817298,"p":"اخیستل","g":"","f":"akheestul","e":"to take, buy, purchase, receive; to shave, cut with scissors","c":"v. trans.","psp":"اخل","psf":"akhl"}, result: { transitivity: "transitive", type: "simple", @@ -534,7 +534,7 @@ const toTest = [ }, }, { - entry: {"i":300,"ts":1527817299,"p":"آخیستل","f":"aakheestul","e":"to take, buy, purchase, receive; to shave, cut with scissors","c":"v. trans.","psp":"اخل","psf":"akhl"}, + entry: {"i":300,"ts":1527817299,"p":"آخیستل","g":"","f":"aakheestul","e":"to take, buy, purchase, receive; to shave, cut with scissors","c":"v. trans.","psp":"اخل","psf":"akhl"}, result: { transitivity: "transitive", type: "simple", @@ -571,7 +571,7 @@ const toTest = [ }, // TODO: IS THE SPLIT HERE CORRECT?? { - entry: {"i":1105,"ts":1527816146,"p":"ایستل","f":"eestul","e":"to throw out, discard, chuck, toss; to extract, to take out","c":"v. trans.","psp":"باس","psf":"baas"}, + entry: {"i":1105,"ts":1527816146,"p":"ایستل","g":"","f":"eestul","e":"to throw out, discard, chuck, toss; to extract, to take out","c":"v. trans.","psp":"باس","psf":"baas"}, result: { transitivity: "transitive", type: "simple", @@ -607,7 +607,7 @@ const toTest = [ }, }, { - entry: {"i":1106,"ts":1596485537794,"p":"اېستل","f":"estul","e":"to throw out, discard, chuck, toss; to extract, to take out","c":"v. trans.","psp":"باس","psf":"baas"}, + entry: {"i":1106,"ts":1596485537794,"p":"اېستل","g":"","f":"estul","e":"to throw out, discard, chuck, toss; to extract, to take out","c":"v. trans.","psp":"باس","psf":"baas"}, result: { transitivity: "transitive", type: "simple", @@ -641,7 +641,7 @@ const toTest = [ }, }, { - entry: {"i":2766,"ts":1527815165,"p":"پېژندل","f":"pejzandul","e":"to recognize, know, meet","c":"v. trans.","psp":"پېژن","psf":"pejzan","tppp":"پېژاند","tppf":"pejzaand"}, + entry: {"i":2766,"ts":1527815165,"p":"پېژندل","g":"","f":"pejzandul","e":"to recognize, know, meet","c":"v. trans.","psp":"پېژن","psf":"pejzan","tppp":"پېژاند","tppf":"pejzaand"}, result: { transitivity: "transitive", type: "simple", @@ -676,7 +676,7 @@ const toTest = [ }, }, { - entry: {"i":5413,"ts":1527812767,"p":"خندل","f":"khandul","e":"to laugh","c":"v. gramm. trans.","psp":"خاند","psf":"khaand"}, + entry: {"i":5413,"ts":1527812767,"p":"خندل","g":"","f":"khandul","e":"to laugh","c":"v. gramm. trans.","psp":"خاند","psf":"khaand"}, result: { transitivity: "grammatically transitive", type: "simple", @@ -708,8 +708,8 @@ const toTest = [ }, // stative compounds { - entry: {"i":5367,"ts":1577898915919,"p":"خفه کول","f":"khufa kawul","e":"to make sad, to grieve, to annoy; to choke, to make suffocate","l":1527812798,"c":"v. stat. comp. trans."}, - complement: {"i":5366,"ts":1527812798,"p":"خفه","f":"khufa","e":"sad, upset, angry; choked, suffocated","c":"adj."}, + entry: {"i":5367,"ts":1577898915919,"p":"خفه کول","g":"","f":"khufa kawul","e":"to make sad, to grieve, to annoy; to choke, to make suffocate","l":1527812798,"c":"v. stat. comp. trans."}, + complement: {"i":5366,"ts":1527812798,"p":"خفه","g":"","f":"khufa","e":"sad, upset, angry; choked, suffocated","c":"adj."}, result: { transitivity: "transitive", type: "stative compound", @@ -760,8 +760,8 @@ const toTest = [ }, }, { - entry: {"i":5368,"ts":1577898920635,"p":"خفه کېدل","f":"khufa kedul","e":"to be sad, grieved, annoyed, upset; to be choked, to suffocate","l":1527812798,"c":"v. stat. comp. intrans."}, - complement: {"i":5366,"ts":1527812798,"p":"خفه","f":"khufa","e":"sad, upset, angry; choked, suffocated","c":"adj."}, + entry: {"i":5368,"ts":1577898920635,"p":"خفه کېدل","g":"","f":"khufa kedul","e":"to be sad, grieved, annoyed, upset; to be choked, to suffocate","l":1527812798,"c":"v. stat. comp. intrans."}, + complement: {"i":5366,"ts":1527812798,"p":"خفه","g":"","f":"khufa","e":"sad, upset, angry; choked, suffocated","c":"adj."}, result: { transitivity: "intransitive", type: "stative compound", @@ -804,8 +804,8 @@ const toTest = [ }, }, { - entry: {"i":2182,"ts":1571859113828,"p":"پخول","f":"pakhawul","e":"to cook, prepare, to cause to ripen, mature","l":1574867531681,"c":"v. stat. comp. trans."}, - complement: {"i":2610,"ts":1574867531681,"p":"پوخ","f":"pokh","e":"mature, ripe, ready, cooked, able, skillful, experienced, tried, tested, true","c":"adj. irreg.","infap":"پاخه","infaf":"paakhu","infbp":"پخ","infbf":"pakh"}, + entry: {"i":2182,"ts":1571859113828,"p":"پخول","g":"","f":"pakhawul","e":"to cook, prepare, to cause to ripen, mature","l":1574867531681,"c":"v. stat. comp. trans."}, + complement: {"i":2610,"ts":1574867531681,"p":"پوخ","g":"","f":"pokh","e":"mature, ripe, ready, cooked, able, skillful, experienced, tried, tested, true","c":"adj. irreg.","infap":"پاخه","infaf":"paakhu","infbp":"پخ","infbf":"pakh"}, result: { transitivity: "transitive", type: "stative compound", @@ -923,8 +923,8 @@ const toTest = [ }, }, { - entry: {"i":7205,"ts":1591033069786,"p":"ستړی کېدل","f":"stuRey kedul","e":"to get tired, fatigued","l":1527815306,"c":"v. stat. comp. intrans."}, - complement: {"i":7204,"ts":1527815306,"p":"ستړی","f":"stúRey","e":"tired","c":"adj."}, + entry: {"i":7205,"ts":1591033069786,"p":"ستړی کېدل","g":"","f":"stuRey kedul","e":"to get tired, fatigued","l":1527815306,"c":"v. stat. comp. intrans."}, + complement: {"i":7204,"ts":1527815306,"p":"ستړی","g":"","f":"stúRey","e":"tired","c":"adj."}, result: { transitivity: "intransitive", type: "stative compound", @@ -1034,8 +1034,8 @@ const toTest = [ }, }, { - entry: {"i":1895,"ts":1527812277,"p":"بیانول","f":"bayaanawul","e":"to describe, tell, explain, narrate","l":1527814259,"c":"v. stat. comp. trans."}, - complement: {"i":1893,"ts":1527814259,"p":"بیان","f":"bayaan","e":"description, statement, speaking, narration, sermon","c":"n. m.","app":"بیانات","apf":"bayaanaat"}, + entry: {"i":1895,"ts":1527812277,"p":"بیانول","g":"","f":"bayaanawul","e":"to describe, tell, explain, narrate","l":1527814259,"c":"v. stat. comp. trans."}, + complement: {"i":1893,"ts":1527814259,"p":"بیان","g":"","f":"bayaan","e":"description, statement, speaking, narration, sermon","c":"n. m.","app":"بیانات","apf":"bayaanaat"}, result: { transitivity: "transitive", type: "stative compound", @@ -1086,7 +1086,7 @@ const toTest = [ }, }, { - entry: {"i":1068,"ts":1527815139,"p":"اوسېدل","f":"osedul","e":"to live, reside, stay, be","c":"v. intrans.","shortIntrans":true,"diacExcept":true}, + entry: {"i":1068,"ts":1527815139,"p":"اوسېدل","g":"","f":"osedul","e":"to live, reside, stay, be","c":"v. intrans.","shortIntrans":true,"diacExcept":true}, result: { transitivity: "intransitive", type: "simple", @@ -1132,7 +1132,7 @@ const toTest = [ }, }, { - entry: {"i":2058,"ts":1527814038,"p":"پاڅېدل","f":"paatsedul","e":"to get up, rise, wake up","c":"v. intrans.","separationAtP":2,"separationAtF":3,"shortIntrans":true,"noOo":true}, + entry: {"i":2058,"ts":1527814038,"p":"پاڅېدل","g":"","f":"paatsedul","e":"to get up, rise, wake up","c":"v. intrans.","separationAtP":2,"separationAtF":3,"shortIntrans":true,"noOo":true}, result: { transitivity: "intransitive", type: "simple", @@ -1176,7 +1176,7 @@ const toTest = [ }, // auxilary kawul/kedul verbs { - entry: {"i":10246,"ts":1527812752,"p":"کول","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, + entry: {"i":10246,"ts":1527812752,"p":"کول","g":"","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, result: { transitivity: "transitive", type: "simple", @@ -1221,7 +1221,7 @@ const toTest = [ }, }, { - entry: {"i":10059,"ts":1579015359582,"p":"کول","f":"kawul","e":"to make ____ ____ (as in \"He's making me angry.\")","c":"v. trans. irreg. stat. aux.","ssp":"کړ","ssf":"kR","prp":"کړل","prf":"kRul","pprtp":"کړی","pprtf":"kúRey","noOo":true}, + entry: {"i":10059,"ts":1579015359582,"p":"کول","g":"","f":"kawul","e":"to make ____ ____ (as in \"He's making me angry.\")","c":"v. trans. irreg. stat. aux.","ssp":"کړ","ssf":"kR","prp":"کړل","prf":"kRul","pprtp":"کړی","pprtf":"kúRey","noOo":true}, result: { transitivity: "transitive", type: "simple", @@ -1257,7 +1257,7 @@ const toTest = [ }, }, { - entry: {"i":10124,"ts":1581086654898,"p":"کېدل","f":"kedul","e":"to become _____","c":"v. intrans. irreg. aux. stat.","ssp":"ش","ssf":"sh","prp":"شول","prf":"shwul","pprtp":"شوی","pprtf":"shúwey","noOo":true}, + entry: {"i":10124,"ts":1581086654898,"p":"کېدل","g":"","f":"kedul","e":"to become _____","c":"v. intrans. irreg. aux. stat.","ssp":"ش","ssf":"sh","prp":"شول","prf":"shwul","pprtp":"شوی","pprtf":"shúwey","noOo":true}, result: { transitivity: "intransitive", type: "simple", @@ -1289,7 +1289,7 @@ const toTest = [ }, }, { - entry: {"i":10124,"ts":1527812754,"p":"کېدل","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, + entry: {"i":10124,"ts":1527812754,"p":"کېدل","g":"","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, result: { transitivity: "intransitive", type: "simple", @@ -1321,8 +1321,8 @@ const toTest = [ }, // dynamic compound verbs { - entry: {"i":9371,"ts":1527812732,"p":"کار کول","f":"kaar kawul","e":"to work","l":1527822084,"c":"v. dyn. comp. trans."}, - complement: {"i":9369,"ts":1527822084,"p":"کار","f":"kaar","e":"work, job, business, stuff to do","c":"n. m."}, + entry: {"i":9371,"ts":1527812732,"p":"کار کول","g":"","f":"kaar kawul","e":"to work","l":1527822084,"c":"v. dyn. comp. trans."}, + complement: {"i":9369,"ts":1527822084,"p":"کار","g":"","f":"kaar","e":"work, job, business, stuff to do","c":"n. m."}, result: { type: "dynamic compound", transitivity: "transitive", @@ -1359,10 +1359,10 @@ const toTest = [ present: { p: "کار کوونکی", f: "kaar kawóonkey" }, }, objComplement: { - entry: {"i":9369,"ts":1527822084,"p":"کار","f":"kaar","e":"work, job, business, stuff to do","c":"n. m."}, + entry: {"i":9369,"ts":1527822084,"p":"کار","g":"","f":"kaar","e":"work, job, business, stuff to do","c":"n. m."}, person: 4, }, - auxVerb: {"i":10058,"ts":1527812752,"p":"کول","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, + auxVerb: {"i":10058,"ts":1527812752,"p":"کول","g":"","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, intransitiveForm: { type: "dynamic compound", transitivity: "intransitive", @@ -1391,16 +1391,16 @@ const toTest = [ present: { p: "کار کېدونکی", f: "kaar kedóonkey" }, }, objComplement: { - entry: {"i":9369,"ts":1527822084,"p":"کار","f":"kaar","e":"work, job, business, stuff to do","c":"n. m."}, + entry: {"i":9369,"ts":1527822084,"p":"کار","g":"","f":"kaar","e":"work, job, business, stuff to do","c":"n. m."}, person: 4, }, - auxVerb: {"i":10122,"ts":1527812754,"p":"کېدل","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, + auxVerb: {"i":10122,"ts":1527812754,"p":"کېدل","g":"","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, }, }, }, { - entry: {"i":12101,"ts":1527812939,"p":"منډې وهل","f":"munDe wahul","e":"to run","l":1527815805,"c":"v. dyn. comp. trans. sing. or plur."}, - complement: {"i":12098,"ts":1527815805,"p":"منډه","f":"múnDa","e":"run, running","c":"n. f."}, + entry: {"i":12101,"ts":1527812939,"p":"منډې وهل","g":"","f":"munDe wahul","e":"to run","l":1527815805,"c":"v. dyn. comp. trans. sing. or plur."}, + complement: {"i":12098,"ts":1527815805,"p":"منډه","g":"","f":"múnDa","e":"run, running","c":"n. f."}, result: { type: "dynamic compound", transitivity: "transitive", @@ -1429,7 +1429,7 @@ const toTest = [ present: { p: "منډې وهونکی", f: "munDe wahóonkey" }, }, objComplement: { - entry: {"i":12098,"ts":1527815805,"p":"منډه","f":"múnDa","e":"run, running","c":"n. f."}, + entry: {"i":12098,"ts":1527815805,"p":"منډه","g":"","f":"múnDa","e":"run, running","c":"n. f."}, plural: { p: "منډې", f: "munDe" }, person: 11, }, @@ -1437,6 +1437,7 @@ const toTest = [ ts: 1527815399, p: "وهل", f: "wahul", + g:"", e: "to hit", c: "v. trans.", i: 12183, @@ -1471,13 +1472,14 @@ const toTest = [ present: { p: "منډه وهونکی", f: "múnDa wahóonkey" }, }, objComplement: { - entry: {"i":12098,"ts":1527815805,"p":"منډه","f":"múnDa","e":"run, running","c":"n. f."}, + entry: {"i":12098,"ts":1527815805,"p":"منډه","g":"","f":"múnDa","e":"run, running","c":"n. f."}, person: 5, }, auxVerb: { ts: 1527815399, p: "وهل", f: "wahul", + g:"", e: "to hit", c: "v. trans.", i: 12183, @@ -1488,8 +1490,8 @@ const toTest = [ }, }, { - entry: {"i":10554,"ts":1579034883717,"p":"لاړې تېرول","f":"laaRe terawul","e":"to spit ?? (other fluids too??)","l":1527823566,"c":"v. dyn. comp. trans."}, - complement: {"i":10553,"ts":1527823567,"p":"لاړې","f":"laaRe","e":"spit, saliva, slobber, slime","c":"n. f. pl."}, + entry: {"i":10554,"ts":1579034883717,"p":"لاړې تېرول","g":"","f":"laaRe terawul","e":"to spit ?? (other fluids too??)","l":1527823566,"c":"v. dyn. comp. trans."}, + complement: {"i":10553,"ts":1527823567,"p":"لاړې","g":"","f":"laaRe","e":"spit, saliva, slobber, slime","c":"n. f. pl."}, result: { type: "dynamic compound", transitivity: "transitive", @@ -1526,17 +1528,17 @@ const toTest = [ present: { p: "لاړې تېروونکی", f: "laaRe terawóonkey" }, }, objComplement: { - entry: {"i":10553,"ts":1527823567,"p":"لاړې","f":"laaRe","e":"spit, saliva, slobber, slime","c":"n. f. pl."}, + entry: {"i":10553,"ts":1527823567,"p":"لاړې","g":"","f":"laaRe","e":"spit, saliva, slobber, slime","c":"n. f. pl."}, person: 11, }, - auxVerb: {"i":3459,"ts":1527812157,"p":"تېرول","f":"terawul","e":"to pass (time), to take across, to pass, endure (difficulties)","l":1527813139,"c":"v. stat. comp. trans."}, - auxVerbComplement: {"i":3774,"ts":1527813139,"p":"تېر","f":"ter","e":"last, past, previous, passed, gone over","c":"adj."}, + auxVerb: {"i":3459,"ts":1527812157,"p":"تېرول","g":"","f":"terawul","e":"to pass (time), to take across, to pass, endure (difficulties)","l":1527813139,"c":"v. stat. comp. trans."}, + auxVerbComplement: {"i":3774,"ts":1527813139,"p":"تېر","g":"","f":"ter","e":"last, past, previous, passed, gone over","c":"adj."}, }, }, // stative or dynamic compound verb { - entry: {"i":7910,"ts":1527819253,"p":"شروع کول","f":"shUróo' kawul","e":"to start, to begin","l":1527819252,"c":"v. dyn./stat. comp. trans."}, - complement: {"i":7909,"ts":1527819252,"p":"شروع","f":"shUróo'","e":"beginning, start, undertaking","c":"n. m."}, + entry: {"i":7910,"ts":1527819253,"p":"شروع کول","g":"","f":"shUróo' kawul","e":"to start, to begin","l":1527819252,"c":"v. dyn./stat. comp. trans."}, + complement: {"i":7909,"ts":1527819252,"p":"شروع","g":"","f":"shUróo'","e":"beginning, start, undertaking","c":"n. m."}, result: { type: "dynamic or stative compound", transitivity: "transitive", @@ -1576,10 +1578,10 @@ const toTest = [ present: { p: "شروع کوونکی", f: "shUróo' kawóonkey" }, }, objComplement: { - entry: {"i":7909,"ts":1527819252,"p":"شروع","f":"shUróo'","e":"beginning, start, undertaking","c":"n. m."}, + entry: {"i":7909,"ts":1527819252,"p":"شروع","g":"","f":"shUróo'","e":"beginning, start, undertaking","c":"n. m."}, person: 4, }, - auxVerb: {"i":10058,"ts":1527812752,"p":"کول","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, + auxVerb: {"i":10058,"ts":1527812752,"p":"کول","g":"","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, intransitiveForm: { type: "dynamic compound", transitivity: "intransitive", @@ -1608,10 +1610,10 @@ const toTest = [ present: { p: "شروع کېدونکی", f: "shUróo' kedóonkey" }, }, objComplement: { - entry: {"i":7909,"ts":1527819252,"p":"شروع","f":"shUróo'","e":"beginning, start, undertaking","c":"n. m."}, + entry: {"i":7909,"ts":1527819252,"p":"شروع","g":"","f":"shUróo'","e":"beginning, start, undertaking","c":"n. m."}, person: 4, }, - auxVerb: {"i":10122,"ts":1527812754,"p":"کېدل","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, + auxVerb: {"i":10122,"ts":1527812754,"p":"کېدل","g":"","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, }, }, stative: { @@ -1666,8 +1668,8 @@ const toTest = [ }, // dynamic or generative stative compound verb { - entry: {"i":4770,"ts":1608137130992,"p":"چیغه کول","f":"chéegha kawul","e":"to yell, scream, cry out","l":1527813972,"c":"v. gen. stat./dyn. comp. trans."}, - complement: {"i":4769,"ts":1527813972,"p":"چیغه","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, + entry: {"i":4770,"ts":1608137130992,"p":"چیغه کول","g":"","f":"chéegha kawul","e":"to yell, scream, cry out","l":1527813972,"c":"v. gen. stat./dyn. comp. trans."}, + complement: {"i":4769,"ts":1527813972,"p":"چیغه","g":"","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, result: { type: "dynamic or generative stative compound", transitivity: "transitive", @@ -1707,10 +1709,10 @@ const toTest = [ present: { p: "چیغه کوونکی", f: "chéegha kawóonkey" }, }, objComplement: { - entry: {"i":4769,"ts":1527813972,"p":"چیغه","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, + entry: {"i":4769,"ts":1527813972,"p":"چیغه","g":"","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, person: 5, }, - auxVerb: {"i":10058,"ts":1527812752,"p":"کول","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, + auxVerb: {"i":10058,"ts":1527812752,"p":"کول","g":"","f":"kawul","e":"to do (an action or activity)","c":"v. trans. irreg. dyn. aux.","ssp":"وکړ","ssf":"óokR","prp":"وکړل","prf":"óokRul","pprtp":"کړی","pprtf":"kúRey","diacExcept":true}, intransitiveForm: { type: "dynamic compound", transitivity: "intransitive", @@ -1739,10 +1741,10 @@ const toTest = [ present: { p: "چیغه کېدونکی", f: "chéegha kedóonkey" }, }, objComplement: { - entry: {"i":4769,"ts":1527813972,"p":"چیغه","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, + entry: {"i":4769,"ts":1527813972,"p":"چیغه","g":"","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, person: 5, }, - auxVerb: {"i":10122,"ts":1527812754,"p":"کېدل","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, + auxVerb: {"i":10122,"ts":1527812754,"p":"کېدل","g":"","f":"kedul","e":"to happen, occur","c":"v. intrans. irreg. aux. dyn.","ssp":"وش","ssf":"óosh","prp":"وشول","prf":"óoshwul","pprtp":"شوی","pprtf":"shúwey","diacExcept":true}, }, }, stative: { @@ -1781,7 +1783,7 @@ const toTest = [ present: { p: "چیغه کوونکی", f: "chéegha kawóonkey" }, }, objComplement: { - entry: {"i":4769,"ts":1527813972,"p":"چیغه","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, + entry: {"i":4769,"ts":1527813972,"p":"چیغه","g":"","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, person: 5, }, }, @@ -1789,8 +1791,8 @@ const toTest = [ }, // with plural form { - entry: {"i":4770,"ts":1608137130992,"p":"چیغې کول","f":"chéeghe kawul","e":"to yell, scream, cry out","l":1527813972,"c":"v. gen. stat./dyn. comp. trans."}, - complement: {"i":4769,"ts":1527813972,"p":"چیغه","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, + entry: {"i":4770,"ts":1608137130992,"p":"چیغې کول","g":"","f":"chéeghe kawul","e":"to yell, scream, cry out","l":1527813972,"c":"v. gen. stat./dyn. comp. trans."}, + complement: {"i":4769,"ts":1527813972,"p":"چیغه","g":"","f":"chéegha","e":"yell, scream, cry","c":"n. f."}, result: { "type": "dynamic or generative stative compound", "transitivity": "transitive", @@ -1895,6 +1897,7 @@ const toTest = [ "ts": 1527813972, "p": "چیغه", "f": "chéegha", + "g": "", "e": "yell, scream, cry", "c": "n. f." }, @@ -1909,6 +1912,7 @@ const toTest = [ "ts": 1527812752, "p": "کول", "f": "kawul", + "g": "", "e": "to do (an action or activity)", "c": "v. trans. irreg. dyn. aux.", "ssp": "وکړ", @@ -2020,6 +2024,7 @@ const toTest = [ "ts": 1527813972, "p": "چیغه", "f": "chéegha", + "g": "", "e": "yell, scream, cry", "c": "n. f." }, @@ -2030,6 +2035,7 @@ const toTest = [ "ts": 1527812752, "p": "کول", "f": "kawul", + "g": "", "e": "to do (an action or activity)", "c": "v. trans. irreg. dyn. aux.", "ssp": "وکړ", @@ -2115,6 +2121,7 @@ const toTest = [ "ts": 1527813972, "p": "چیغه", "f": "chéegha", + "g": "", "e": "yell, scream, cry", "c": "n. f." }, @@ -2129,6 +2136,7 @@ const toTest = [ "ts": 1527812754, "p": "کېدل", "f": "kedul", + "g":"", "e": "to happen, occur", "c": "v. intrans. irreg. aux. dyn.", "ssp": "وش", @@ -2214,6 +2222,7 @@ const toTest = [ "ts": 1527813972, "p": "چیغه", "f": "chéegha", + "g": "", "e": "yell, scream, cry", "c": "n. f." }, @@ -2224,6 +2233,7 @@ const toTest = [ "ts": 1527812754, "p": "کېدل", "f": "kedul", + "g":"", "e": "to happen, occur", "c": "v. intrans. irreg. aux. dyn.", "ssp": "وش", @@ -2312,6 +2322,7 @@ const toTest = [ "ts": 1527813972, "p": "چیغه", "f": "chéegha", + "g":"", "e": "yell, scream, cry", "c": "n. f." }, @@ -2326,6 +2337,7 @@ const toTest = [ "ts": 1527812754, "p": "کېدل", "f": "kedul", + "g":"", "e": "to happen, occur", "c": "v. intrans. irreg. aux. dyn.", "ssp": "وش", @@ -2411,6 +2423,7 @@ const toTest = [ "ts": 1527813972, "p": "چیغه", "f": "chéegha", + "g":"", "e": "yell, scream, cry", "c": "n. f." }, @@ -2421,6 +2434,7 @@ const toTest = [ "ts": 1527812754, "p": "کېدل", "f": "kedul", + "g":"", "e": "to happen, occur", "c": "v. intrans. irreg. aux. dyn.", "ssp": "وش", @@ -2535,6 +2549,7 @@ const toTest = [ "ts": 1527813972, "p": "چیغه", "f": "chéegha", + "g": "", "e": "yell, scream, cry", "c": "n. f." }, @@ -2645,6 +2660,7 @@ const toTest = [ "ts": 1527813972, "p": "چیغه", "f": "chéegha", + "g": "", "e": "yell, scream, cry", "c": "n. f." }, @@ -2669,12 +2685,12 @@ test(`verb info should work`, () => { // test(`verb info should not work if no parts of speech`, () => { // expect(() => { -// getVerbInfo({"i":5413,"ts":1527812767,"p":"خندل","f":"khandul","e":"to laugh"}); +// getVerbInfo({"i":5413,"ts":1527812767,"p":"خندل","g":"","f":"khandul","e":"to laugh"}); // }).toThrow("No part of speech info"); // }); // test(`verb info should not work if a complement is not provided for a compound verb`, () => { // expect(() => { -// getVerbInfo({"i":5368,"ts":1577898920635,"p":"خفه کېدل","f":"khufa kedul","e":"to be sad, grieved, annoyed, upset; to be choked, to suffocate","l":1527812798,"c":"v. stat. comp. intrans."}); +// getVerbInfo({"i":5368,"ts":1577898920635,"p":"خفه کېدل","g":"","f":"khufa kedul","e":"to be sad, grieved, annoyed, upset; to be choked, to suffocate","l":1527812798,"c":"v. stat. comp. intrans."}); // }).toThrow("complement required for compound verb"); // }); diff --git a/src/lib/verb-info.ts b/src/lib/verb-info.ts index d15836a..6d0f9f1 100644 --- a/src/lib/verb-info.ts +++ b/src/lib/verb-info.ts @@ -80,6 +80,7 @@ export function getVerbInfo( const transitivity = getTransitivity(entry); if (type !== "simple") { if (!complement) { + console.log(entry); throw new Error("complement required for compound verb"); } if (type === "dynamic compound") { diff --git a/src/library.ts b/src/library.ts index c6c8094..d2a7cb4 100644 --- a/src/library.ts +++ b/src/library.ts @@ -56,6 +56,9 @@ import { import { isNounAdjOrVerb, } from "./lib/misc-helpers"; +import { + simplifyPhonetics, +} from "./lib/simplify-phonetics"; import defaultTextOptions from "./lib/default-text-options"; import * as grammarUnits from "./lib/grammar-units"; import * as Types from "./types"; @@ -74,6 +77,7 @@ export { convertPkToAfSpelling, validateEntry, isNounAdjOrVerb, + simplifyPhonetics, // protobuf helpers readDictionary, writeDictionary, diff --git a/src/types.ts b/src/types.ts index a3342c1..274ea76 100644 --- a/src/types.ts +++ b/src/types.ts @@ -29,49 +29,82 @@ export type Dictionary = { export type DictionaryEntry = { // BASE REQUIRED INFO - ts: number; // timestamp - i: number; // Pashto Alphabetical Index - p: string; // Pashto word - f: string; // Phonetics word - e: string; // English word + /** timestamp - used for word id */ + ts: number; + /** Pashto alphabetical index */ + i: number; + /** entry in Pashto */ + p: string; + /** entry in Phonetics */ + f: string; + /** entry in simplified phonetics */ + g: string; + /** entry in English */ + e: string; + // PART OF SPEECH AND LINK INFO - c?: string; // Part of Speech Info - l?: number; // timestamp link to related word + /** part of speech info */ + c?: string; + /** link - timestamp of related word */ + l?: number; + // INFLECTION INFO - infap?: string; // Special (irregular) inflection info + /** first masculine irregular inflection in Pashto */ + infap?: string; + /** first masculine irregular inflection in Phonetics */ infaf?: string; + /** base for second masculine / feminine irregular inflection in Pashto */ infbp?: string; + /** base for second masculine / feminine irregular inflection in Phonetics */ infbf?: string; - noInf?: boolean; // No Inflections? + /** entry does not inflect? */ + noInf?: boolean; + // PLURAL INFO - app?: string; // Arabic plural in Pashto - apf?: string; // Arabic plural in Phonetics - ppp?: string; // Pashto plural in Pashto - ppf?: string; // Pashto plural in Phonetics + /** Arabic plural in Pashto */ + app?: string; + /** Arabic plural in Phonetics */ + apf?: string; + /** Pashto irregular plural in Pashto */ + ppp?: string; + /** Pashto irregular plural in phonetics */ + ppf?: string; + // VERB INFO - psp?: string; // Present stem in Pashto - psf?: string; // Present stem in Phonetics - /** The subjuctive / perfective stem in Pashto */ + /** imperfective (present) stem in Pashto */ + psp?: string; + /** imperfective (present) stem in Phonetics */ + psf?: string; + /** perfective (subjunctive) stem in Pashto */ ssp?: string; - /** The subjunctive / perfective stem in Phonetics */ + /** perfective (subjunctive) stem in Phonetics */ ssf?: string; - prp?: string; // Perfective root in Pashto - prf?: string; // Perfective root in Phonetics - /** The past participle in Pashto */ + /** perfective root in Pashto */ + prp?: string; + /** perfective root in Phonetics */ + prf?: string; + /** past participle in Pashto */ pprtp?: string; - /** The past participle in Phonetics */ + /** past participle in Phonetics */ pprtf?: string; /** The idiosyncratic third person singular masc. short past in Pashto */ tppp?: string; /** The idiosyncratic third person singular masc. short past in Phonetics */ tppf?: string; - shortIntrans?: boolean; // Short version is available like ګرځېږي and ګرځي - noOo?: boolean; // No و - oo verb prefix? - sepOo?: boolean; // Separate oo prefix? - separationAtP?: number; // Pashto separation point for separable verbs - separationAtF?: number; // Phonetics separation point for separable verbs + /** intransitive short version is available like ګرځېږي and ګرځي */ + shortIntrans?: boolean; + /** does not take a و - oo perfective verb prefix? */ + noOo?: boolean; + /** takes a seperate و - oo perfective verb prefix? */ + sepOo?: boolean; + /** Pashto separation point for seperable verbs */ + separationAtP?: number; + /** Phonetics separation point for seperable verbs */ + separationAtF?: number; + // PHONETICS - PASHTO - DIACRITICS INFO - diacExcept?: boolean; // Is an exception to the diacritics thing + /** Is an exception to the rules of diacritics for Pashto/Phonetics */ + diacExcept?: boolean; } export type DictionaryEntryTextField = "p" | "f" | "e" | "c" | "infap" | "infaf" | "infbp" | "infbf" | "app" | "apf" | "ppp" | "ppf" | "psp" | "psf" | "ssp" | "ssf" | "prp" | "prf" | "pprtp" | "pprtf" | "tppp" | "tppf";