diff --git a/package.json b/package.json index 9d1daf1..5e953f0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "0.7.6", + "version": "0.7.7", "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/ConjugationViewer.tsx b/src/components/ConjugationViewer.tsx index 577a909..37663f2 100644 --- a/src/components/ConjugationViewer.tsx +++ b/src/components/ConjugationViewer.tsx @@ -199,7 +199,6 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight const conjugation = (() => { if (!(entry.c && entry.c.slice(0, 2) === "v.")) return undefined; try { - console.log("my entry is", entry); return conjugateVerb(entry, complement); } catch(e) { console.log("conjugation error", e); diff --git a/src/lib/search-conjugation.test.ts b/src/lib/search-conjugation.test.ts new file mode 100644 index 0000000..49b89a2 --- /dev/null +++ b/src/lib/search-conjugation.test.ts @@ -0,0 +1,20 @@ +import { + searchConjugation, +} from "./search-conjugation"; +import { + conjugateVerb, +} from "./verb-conjugation"; + +test("combo verbs should be searchable", () => { + const conjugation = conjugateVerb( + { i: 0, ts: 0, p: "قتل کول", f: "qatul kawul", e:"to kill", g: "qatil kawul", c: "v. dyn./stat. comp. trans.", l: 2 }, + { i: 1, ts: 2, p: "قتل", f: "qatul", e: "murder", g: "qatul", c: "n. m." }, + ); + // console.log(conjugation); + // @ts-ignore + const { grammaticallyTransitive, transitive } = conjugation; + // console.log(JSON.stringify(grammaticallyTransitive, null, " ")); + // @ts-ignore + const result = searchConjugation(conjugation, "ولیدل"); + expect(result).toBeTruthy(); +}); \ No newline at end of file diff --git a/src/lib/search-conjugation.ts b/src/lib/search-conjugation.ts index 1f1d485..ca50734 100644 --- a/src/lib/search-conjugation.ts +++ b/src/lib/search-conjugation.ts @@ -9,16 +9,16 @@ import { personFromVerbBlockPos } from "./misc-helpers"; const inflectionNames: InflectionName[] = ["plain", "1st", "2nd"]; type ObPile = { [key: string]: ObRec; } -type ObRec = any[] | ObPile; +type ObRec = any[] | { p: string } | ObPile; type ConjSearchResults = { form: string[], - position: InflectionName[] | T.Person[], + position: InflectionName[] | T.Person[] | null, }[]; type BlockResult = { blockResult: true, - position: InflectionName[] | T.Person[], + position: InflectionName[] | T.Person[] | null, } type InflectionName = "plain" | "1st" | "2nd"; @@ -30,6 +30,11 @@ export function searchConjugation(pile: ObPile, s: string): ConjSearchResults { if (Array.isArray(record)) { return searchBlock(record, s); } + // TODO: This is only because of the grammatically transitive past participle!! Should change that to make it faster + if ("p" in record) { + // @ts-ignore + return searchSinglePs(record, s); + } // look further down the tree recursively return searchConjugation(record, s); } @@ -39,7 +44,6 @@ export function searchConjugation(pile: ObPile, s: string): ConjSearchResults { if (name === "info") { return res; } - // search for value from key const result = searchObRecord(value); // Result: Hit the bottom and nothing found if (result === null) { @@ -69,6 +73,16 @@ export function searchConjugation(pile: ObPile, s: string): ConjSearchResults { }, []); } +function searchSinglePs(ps: T.PsString, s: string): null | BlockResult { + if (ps.p === s) { + return { + blockResult: true, + position: null, + }; + }; + return null; +} + function searchBlock(block: any[], s: string): null | BlockResult { if (isVerbBlock(block)) { const verbBlock = block as T.VerbBlock; diff --git a/src/lib/verb-conjugation.ts b/src/lib/verb-conjugation.ts index a3b4cd3..7fd425d 100644 --- a/src/lib/verb-conjugation.ts +++ b/src/lib/verb-conjugation.ts @@ -343,8 +343,8 @@ function makeParticipleContent(info: T.NonComboVerbInfo): T.ParticipleContent { ? concatInflections(info.complement, stativeAux[transitivity].participle.present as T.UnisexInflections) : inflectYey(noPersInfs(info.participle.present)); return { - present, // PAST PARTICIPLE inflected - past, // PRESENT PARTICIPLE inflected + present, // PRESENT PARTICIPLE inflected + past, // PAST PARTICIPLE inflected }; }