fixed issue with the lone ps value in grammatically transitive past participles tripping up the conjugation tree search -- might be costly though
This commit is contained in:
parent
95fd8f46ec
commit
d77056a130
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/pashto-inflector",
|
"name": "@lingdocs/pashto-inflector",
|
||||||
"version": "0.7.6",
|
"version": "0.7.7",
|
||||||
"author": "lingdocs.com",
|
"author": "lingdocs.com",
|
||||||
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
|
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
|
||||||
"homepage": "https://verbs.lingdocs.com",
|
"homepage": "https://verbs.lingdocs.com",
|
||||||
|
|
|
@ -199,7 +199,6 @@ function ConjugationViewer({ entry, complement, textOptions, showOnly, highlight
|
||||||
const conjugation = (() => {
|
const conjugation = (() => {
|
||||||
if (!(entry.c && entry.c.slice(0, 2) === "v.")) return undefined;
|
if (!(entry.c && entry.c.slice(0, 2) === "v.")) return undefined;
|
||||||
try {
|
try {
|
||||||
console.log("my entry is", entry);
|
|
||||||
return conjugateVerb(entry, complement);
|
return conjugateVerb(entry, complement);
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
console.log("conjugation error", e);
|
console.log("conjugation error", e);
|
||||||
|
|
|
@ -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();
|
||||||
|
});
|
|
@ -9,16 +9,16 @@ import { personFromVerbBlockPos } from "./misc-helpers";
|
||||||
const inflectionNames: InflectionName[] = ["plain", "1st", "2nd"];
|
const inflectionNames: InflectionName[] = ["plain", "1st", "2nd"];
|
||||||
|
|
||||||
type ObPile = { [key: string]: ObRec; }
|
type ObPile = { [key: string]: ObRec; }
|
||||||
type ObRec = any[] | ObPile;
|
type ObRec = any[] | { p: string } | ObPile;
|
||||||
|
|
||||||
type ConjSearchResults = {
|
type ConjSearchResults = {
|
||||||
form: string[],
|
form: string[],
|
||||||
position: InflectionName[] | T.Person[],
|
position: InflectionName[] | T.Person[] | null,
|
||||||
}[];
|
}[];
|
||||||
|
|
||||||
type BlockResult = {
|
type BlockResult = {
|
||||||
blockResult: true,
|
blockResult: true,
|
||||||
position: InflectionName[] | T.Person[],
|
position: InflectionName[] | T.Person[] | null,
|
||||||
}
|
}
|
||||||
|
|
||||||
type InflectionName = "plain" | "1st" | "2nd";
|
type InflectionName = "plain" | "1st" | "2nd";
|
||||||
|
@ -30,6 +30,11 @@ export function searchConjugation(pile: ObPile, s: string): ConjSearchResults {
|
||||||
if (Array.isArray(record)) {
|
if (Array.isArray(record)) {
|
||||||
return searchBlock(record, s);
|
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
|
// look further down the tree recursively
|
||||||
return searchConjugation(record, s);
|
return searchConjugation(record, s);
|
||||||
}
|
}
|
||||||
|
@ -39,7 +44,6 @@ export function searchConjugation(pile: ObPile, s: string): ConjSearchResults {
|
||||||
if (name === "info") {
|
if (name === "info") {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
// search for value from key
|
|
||||||
const result = searchObRecord(value);
|
const result = searchObRecord(value);
|
||||||
// Result: Hit the bottom and nothing found
|
// Result: Hit the bottom and nothing found
|
||||||
if (result === null) {
|
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 {
|
function searchBlock(block: any[], s: string): null | BlockResult {
|
||||||
if (isVerbBlock(block)) {
|
if (isVerbBlock(block)) {
|
||||||
const verbBlock = block as T.VerbBlock;
|
const verbBlock = block as T.VerbBlock;
|
||||||
|
|
|
@ -343,8 +343,8 @@ function makeParticipleContent(info: T.NonComboVerbInfo): T.ParticipleContent {
|
||||||
? concatInflections(info.complement, stativeAux[transitivity].participle.present as T.UnisexInflections)
|
? concatInflections(info.complement, stativeAux[transitivity].participle.present as T.UnisexInflections)
|
||||||
: inflectYey(noPersInfs(info.participle.present));
|
: inflectYey(noPersInfs(info.participle.present));
|
||||||
return {
|
return {
|
||||||
present, // PAST PARTICIPLE inflected
|
present, // PRESENT PARTICIPLE inflected
|
||||||
past, // PRESENT PARTICIPLE inflected
|
past, // PAST PARTICIPLE inflected
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue