From 940764b1c2adba76e86edf63dbd6646f8e0fa9cc Mon Sep 17 00:00:00 2001 From: adueck Date: Fri, 25 Nov 2022 19:19:22 +0500 Subject: [PATCH] added r - rank field --- package-lock.json | 4 +- package.json | 2 +- src/components/package.json | 2 +- src/lib/package.json | 2 +- src/lib/src/dictionary-models.js | 118 ++++++++++++++++--------------- src/lib/src/dictionary.proto | 61 ++++++++-------- src/lib/src/misc-helpers.ts | 6 ++ src/types.ts | 11 ++- 8 files changed, 112 insertions(+), 94 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6bf226a..5447ace 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pashto-inflector", - "version": "5.1.10", + "version": "5.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "pashto-inflector", - "version": "5.1.10", + "version": "5.2.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 5e5b485..9a565f6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pashto-inflector", - "version": "5.1.10", + "version": "5.2.0", "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", diff --git a/src/components/package.json b/src/components/package.json index 50a9471..7aac59e 100644 --- a/src/components/package.json +++ b/src/components/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/ps-react", - "version": "5.1.10", + "version": "5.2.0", "description": "Pashto inflector library module with React components", "main": "dist/components/library.js", "module": "dist/components/library.js", diff --git a/src/lib/package.json b/src/lib/package.json index 6677c0b..e0428be 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/inflect", - "version": "5.1.10", + "version": "5.2.0", "description": "Pashto inflector library", "main": "dist/index.js", "types": "dist/lib/library.d.ts", diff --git a/src/lib/src/dictionary-models.js b/src/lib/src/dictionary-models.js index cec16a9..103a3b3 100644 --- a/src/lib/src/dictionary-models.js +++ b/src/lib/src/dictionary-models.js @@ -39,35 +39,36 @@ Entry._readField = function (tag, obj, pbf) { else if (tag === 4) obj.f = 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.readBoolean(); - else if (tag === 14) obj.app = pbf.readString(); - else if (tag === 15) obj.apf = pbf.readString(); - else if (tag === 16) obj.ppp = pbf.readString(); - else if (tag === 17) obj.ppf = pbf.readString(); - else if (tag === 18) obj.psp = pbf.readString(); - else if (tag === 19) obj.psf = pbf.readString(); - else if (tag === 20) obj.ssp = pbf.readString(); - else if (tag === 21) obj.ssf = pbf.readString(); - else if (tag === 22) obj.prp = pbf.readString(); - else if (tag === 23) obj.prf = pbf.readString(); - else if (tag === 24) obj.pprtp = pbf.readString(); - else if (tag === 25) obj.pprtf = pbf.readString(); - else if (tag === 26) obj.tppp = pbf.readString(); - else if (tag === 27) obj.tppf = pbf.readString(); - else if (tag === 28) obj.shortIntrans = pbf.readBoolean(); - else if (tag === 29) obj.noOo = pbf.readBoolean(); - else if (tag === 30) obj.sepOo = pbf.readBoolean(); - else if (tag === 31) obj.separationAtP = pbf.readVarint(true); - else if (tag === 32) obj.separationAtF = pbf.readVarint(true); - else if (tag === 33) obj.diacExcept = pbf.readBoolean(); - else if (tag === 34) obj.ec = pbf.readString(); - else if (tag === 35) obj.ep = pbf.readString(); + else if (tag === 7) obj.r = pbf.readVarint(true); + else if (tag === 8) obj.c = pbf.readString(); + else if (tag === 9) obj.l = pbf.readVarint(true); + else if (tag === 10) obj.infap = pbf.readString(); + else if (tag === 11) obj.infaf = pbf.readString(); + else if (tag === 12) obj.infbp = pbf.readString(); + else if (tag === 13) obj.infbf = pbf.readString(); + else if (tag === 14) obj.noInf = pbf.readBoolean(); + else if (tag === 15) obj.app = pbf.readString(); + else if (tag === 16) obj.apf = pbf.readString(); + else if (tag === 17) obj.ppp = pbf.readString(); + else if (tag === 18) obj.ppf = pbf.readString(); + else if (tag === 19) obj.psp = pbf.readString(); + else if (tag === 20) obj.psf = pbf.readString(); + else if (tag === 21) obj.ssp = pbf.readString(); + else if (tag === 22) obj.ssf = pbf.readString(); + else if (tag === 23) obj.prp = pbf.readString(); + else if (tag === 24) obj.prf = pbf.readString(); + else if (tag === 25) obj.pprtp = pbf.readString(); + else if (tag === 26) obj.pprtf = pbf.readString(); + else if (tag === 27) obj.tppp = pbf.readString(); + else if (tag === 28) obj.tppf = pbf.readString(); + else if (tag === 29) obj.shortIntrans = pbf.readBoolean(); + else if (tag === 30) obj.noOo = pbf.readBoolean(); + else if (tag === 31) obj.sepOo = pbf.readBoolean(); + else if (tag === 32) obj.separationAtP = pbf.readVarint(true); + else if (tag === 33) obj.separationAtF = pbf.readVarint(true); + else if (tag === 34) obj.diacExcept = pbf.readBoolean(); + else if (tag === 35) obj.ec = pbf.readString(); + else if (tag === 36) obj.ep = pbf.readString(); }; Entry.write = function (obj, pbf) { if (obj.ts) pbf.writeVarintField(1, obj.ts); @@ -76,35 +77,36 @@ Entry.write = function (obj, pbf) { if (obj.f) pbf.writeStringField(4, obj.f); 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.writeBooleanField(13, obj.noInf); - if (obj.app) pbf.writeStringField(14, obj.app); - if (obj.apf) pbf.writeStringField(15, obj.apf); - if (obj.ppp) pbf.writeStringField(16, obj.ppp); - if (obj.ppf) pbf.writeStringField(17, obj.ppf); - if (obj.psp) pbf.writeStringField(18, obj.psp); - if (obj.psf) pbf.writeStringField(19, obj.psf); - if (obj.ssp) pbf.writeStringField(20, obj.ssp); - if (obj.ssf) pbf.writeStringField(21, obj.ssf); - if (obj.prp) pbf.writeStringField(22, obj.prp); - if (obj.prf) pbf.writeStringField(23, obj.prf); - if (obj.pprtp) pbf.writeStringField(24, obj.pprtp); - if (obj.pprtf) pbf.writeStringField(25, obj.pprtf); - if (obj.tppp) pbf.writeStringField(26, obj.tppp); - if (obj.tppf) pbf.writeStringField(27, obj.tppf); - if (obj.shortIntrans) pbf.writeBooleanField(28, obj.shortIntrans); - if (obj.noOo) pbf.writeBooleanField(29, obj.noOo); - if (obj.sepOo) pbf.writeBooleanField(30, obj.sepOo); - if (obj.separationAtP) pbf.writeVarintField(31, obj.separationAtP); - if (obj.separationAtF) pbf.writeVarintField(32, obj.separationAtF); - if (obj.diacExcept) pbf.writeBooleanField(33, obj.diacExcept); - if (obj.ec) pbf.writeStringField(34, obj.ec); - if (obj.ep) pbf.writeStringField(35, obj.ep); + if (obj.r) pbf.writeVarintField(7, obj.r); + if (obj.c) pbf.writeStringField(8, obj.c); + if (obj.l) pbf.writeVarintField(9, obj.l); + if (obj.infap) pbf.writeStringField(10, obj.infap); + if (obj.infaf) pbf.writeStringField(11, obj.infaf); + if (obj.infbp) pbf.writeStringField(12, obj.infbp); + if (obj.infbf) pbf.writeStringField(13, obj.infbf); + if (obj.noInf) pbf.writeBooleanField(14, obj.noInf); + if (obj.app) pbf.writeStringField(15, obj.app); + if (obj.apf) pbf.writeStringField(16, obj.apf); + if (obj.ppp) pbf.writeStringField(17, obj.ppp); + if (obj.ppf) pbf.writeStringField(18, obj.ppf); + if (obj.psp) pbf.writeStringField(19, obj.psp); + if (obj.psf) pbf.writeStringField(20, obj.psf); + if (obj.ssp) pbf.writeStringField(21, obj.ssp); + if (obj.ssf) pbf.writeStringField(22, obj.ssf); + if (obj.prp) pbf.writeStringField(23, obj.prp); + if (obj.prf) pbf.writeStringField(24, obj.prf); + if (obj.pprtp) pbf.writeStringField(25, obj.pprtp); + if (obj.pprtf) pbf.writeStringField(26, obj.pprtf); + if (obj.tppp) pbf.writeStringField(27, obj.tppp); + if (obj.tppf) pbf.writeStringField(28, obj.tppf); + if (obj.shortIntrans) pbf.writeBooleanField(29, obj.shortIntrans); + if (obj.noOo) pbf.writeBooleanField(30, obj.noOo); + if (obj.sepOo) pbf.writeBooleanField(31, obj.sepOo); + if (obj.separationAtP) pbf.writeVarintField(32, obj.separationAtP); + if (obj.separationAtF) pbf.writeVarintField(33, obj.separationAtF); + if (obj.diacExcept) pbf.writeBooleanField(34, obj.diacExcept); + if (obj.ec) pbf.writeStringField(35, obj.ec); + if (obj.ep) pbf.writeStringField(36, obj.ep); }; // Dictionary ======================================== diff --git a/src/lib/src/dictionary.proto b/src/lib/src/dictionary.proto index a7b5887..ae05a7a 100644 --- a/src/lib/src/dictionary.proto +++ b/src/lib/src/dictionary.proto @@ -15,36 +15,37 @@ message Entry { string p = 3; 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; - bool noInf = 13; - string app = 14; - string apf = 15; - string ppp = 16; - string ppf = 17; - string psp = 18; - string psf = 19; - string ssp = 20; - string ssf = 21; - string prp = 22; - string prf = 23; - string pprtp = 24; - string pprtf = 25; - string tppp = 26; - string tppf = 27; - bool shortIntrans = 28; - bool noOo = 29; - bool sepOo = 30; - int32 separationAtP = 31; - int32 separationAtF = 32; - bool diacExcept = 33; - string ec = 34; - string ep = 35; + string e = 6; + int 32 r = 7; + string c = 8; + int32 l = 9; + string infap = 10; + string infaf = 11; + string infbp = 12; + string infbf = 13; + bool noInf = 14; + string app = 15; + string apf = 16; + string ppp = 17; + string ppf = 18; + string psp = 19; + string psf = 20; + string ssp = 21; + string ssf = 22; + string prp = 23; + string prf = 24; + string pprtp = 25; + string pprtf = 26; + string tppp = 27; + string tppf = 28; + bool shortIntrans = 29; + bool noOo = 30; + bool sepOo = 31; + int32 separationAtP = 32; + int32 separationAtF = 33; + bool diacExcept = 34; + string ec = 35; + string ep = 36; } message Dictionary { diff --git a/src/lib/src/misc-helpers.ts b/src/lib/src/misc-helpers.ts index abf07f9..8f27224 100644 --- a/src/lib/src/misc-helpers.ts +++ b/src/lib/src/misc-helpers.ts @@ -14,6 +14,12 @@ export const blank: T.PsString = { }; export const kidsBlank: T.PsString = { p: "___", f: "___" }; +/** + * returns the main entry of a VerbEntry or just the entry of a DictionaryEntry + * + * @param e FullEntry + * @returns DictionaryEntry + */ export function entryOfFull(e: T.FullEntry): T.DictionaryEntry { return "entry" in e ? e.entry : e; } diff --git a/src/types.ts b/src/types.ts index 493c03e..1454bf4 100644 --- a/src/types.ts +++ b/src/types.ts @@ -37,6 +37,15 @@ export type DictionaryEntry = { ts: number; /** Pashto alphabetical index */ i: number; + /** + * commonality rank + * 0 - wrong + * 1 - historical/not in use + * 2 - rarely used + * 3 - used but there are more common alternatives + * 4 - common + */ + r?: number; /** entry in Pashto */ p: string; /** entry in Phonetics */ @@ -122,7 +131,7 @@ export type FStringNoFVars = string & { __brand: "name for a phonetics string wi 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" | "ec" | "ep"; export type DictionaryEntryBooleanField = "noInf" | "shortIntrans" | "noOo" | "sepOo" | "diacExcept"; -export type DictionaryEntryNumberField = "ts" | "i" | "l" | "separationAtP" | "separationAtF"; +export type DictionaryEntryNumberField = "ts" | "r" | "i" | "l" | "separationAtP" | "separationAtF"; export type DictionaryEntryField = DictionaryEntryTextField | DictionaryEntryBooleanField | DictionaryEntryNumberField; // TODO: make