fix issues with verbConjugation failing by assuming that we would get simple verb conjugation results

This commit is contained in:
adueck 2024-08-06 17:26:06 -04:00
parent dee417aa05
commit 8455f26b0a
11 changed files with 287 additions and 41 deletions

View File

@ -19,7 +19,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache: "yarn"
- name: run script
run: |
yarn install-r

View File

@ -29,7 +29,7 @@ async function checkAll() {
err: e.toString(),
});
}
if (tp.isVerbEntry(entry)) {
if (tp.isVerbDictionaryEntry(entry)) {
const complement = entry.l
? entries.find((e) => e.ts === entry.l)
: undefined;
@ -41,6 +41,16 @@ async function checkAll() {
err: "verb complement missing",
});
} else {
try {
conjugateVerb(entry, complement);
} catch (e) {
errors.push({
ts: entry.ts,
p: entry.p,
f: entry.f,
err: e,
});
}
}
}
});

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "pashto-inflector",
"version": "7.4.0",
"version": "7.4.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "pashto-inflector",
"version": "7.4.0",
"version": "7.4.1",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "pashto-inflector",
"version": "7.4.0",
"version": "7.4.1",
"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",
@ -79,4 +79,4 @@
]
},
"dependencies": {}
}
}

View File

@ -1,12 +1,12 @@
{
"name": "@lingdocs/ps-react",
"version": "7.4.0",
"version": "7.4.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@lingdocs/ps-react",
"version": "7.4.0",
"version": "7.4.1",
"license": "MIT",
"dependencies": {
"@formkit/auto-animate": "^1.0.0-beta.3",

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/ps-react",
"version": "7.4.0",
"version": "7.4.1",
"description": "Pashto inflector library module with React components",
"main": "dist/components/library.js",
"module": "dist/components/library.js",

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/inflect",
"version": "7.4.0",
"version": "7.4.1",
"description": "Pashto inflector library",
"main": "dist/index.js",
"types": "dist/lib/library.d.ts",

View File

@ -576,4 +576,228 @@ export const dynamicAuxVerbs: Array<{
ec: "send,sends,sending,sent,sent",
},
},
{
entry: {
ts: 1577299232429,
i: 1770,
p: "بدلول",
f: "badlawúl",
g: "badlawul",
e: "to change, to adapt, exchange, replace",
r: 4,
c: "v. stat. comp. trans.",
l: 1577299160732,
ec: "change",
a: 1,
},
complement: {
ts: 1577299160732,
i: 1761,
p: "بدل",
f: "badál",
g: "badal",
e: "changed, different, exchanged",
r: 4,
c: "adj.",
a: 1,
},
},
{
entry: {
ts: 1527812856,
i: 14629,
p: "لیکل",
f: "leekúl",
g: "leekul",
e: "to write, draw",
r: 3,
c: "v. trans./gramm. trans.",
ec: "write,writes,writing,wrote,written",
a: 1,
},
},
{
entry: {
ts: 1527812280,
i: 1425,
p: "اېښودل",
f: "exodúl",
g: "exodul",
e: "to put, put down, set in place, install, plant, plug in, invest, lay/build",
r: 4,
c: "v. trans.",
psp: "ږد",
psf: "Gd",
noOo: true,
a: 1,
},
},
{
entry: {
ts: 1527811395,
i: 6849,
p: "خپرول",
f: "khparawul",
g: "khparawul",
e: "to spread, disperse, open, unfold, publicize, distribute",
r: 3,
c: "v. stat. comp. trans.",
l: 1527816071,
ec: "spread,spreads,spreading,spread",
},
complement: {
ts: 1527816071,
i: 6874,
p: "خپور",
f: "khpor",
g: "khpor",
e: "spread, dispersed, publicized, published",
r: 4,
c: "adj.",
infap: "خپاره",
infaf: "khpaaru",
infbp: "خپر",
infbf: "khpar",
},
},
{
entry: {
ts: 1527818218,
i: 18245,
p: "ویستل",
f: "weestul",
g: "weestul",
e: "to take out, throw out, drive out, discard, chuck, toss, extract",
r: 4,
c: "v. trans.",
psp: "باس",
psf: "báas",
ssp: "وباس",
ssf: "óobaas",
diacExcept: true,
a: 1,
},
complement: {
ts: 1527818218,
i: 18245,
p: "ویستل",
f: "weestul",
g: "weestul",
e: "to take out, throw out, drive out, discard, chuck, toss, extract",
r: 4,
c: "v. trans.",
psp: "باس",
psf: "báas",
ssp: "وباس",
ssf: "óobaas",
diacExcept: true,
a: 1,
},
},
{
entry: {
ts: 1527811293,
i: 10992,
p: "ښودل",
f: "xodúl",
g: "xodul",
e: "to show; to teach; to suit, look good with (fig.), befit",
r: 4,
c: "v. trans.",
psp: "ښای",
psf: "xaay",
ec: "show,shows,showing,showed,shown",
a: 1,
},
},
{
entry: {
ts: 1527816012,
i: 14685,
p: "ماتول",
f: "maatawúl",
g: "maatawul",
e: "to break, split, defeat",
r: 4,
c: "v. stat. comp. trans.",
l: 1527816011,
ec: "break,breaks,breaking,broke,broken",
a: 1,
},
complement: {
ts: 1527816011,
i: 14677,
p: "مات",
f: "maat",
g: "maat",
e: "broken, split, defeated",
r: 4,
c: "adj.",
a: 1,
},
},
{
entry: {
ts: 1527812222,
i: 6879,
p: "ختمول",
f: "khatumawúl",
g: "khatumawul",
e: "to finish, complete, end, use up, destroy, kill",
r: 4,
c: "v. stat. comp. trans.",
l: 1527812221,
ec: "finish",
a: 1,
},
complement: {
ts: 1527812221,
i: 6878,
p: "ختم",
f: "khátum",
g: "khatum",
e: "finished, completed, ended, done",
r: 4,
c: "adj.",
a: 1,
},
},
{
entry: {
ts: 1527821309,
i: 2173,
p: "بندول",
f: "bandawúl",
g: "bandawul",
e: "to close, block, stop, barricade, cut off, restrain, hold back",
r: 3,
c: "v. stat. comp. trans.",
l: 1577301753727,
ec: "close",
a: 1,
},
complement: {
ts: 1577301753727,
i: 2158,
p: "بند",
f: "band",
g: "band",
e: "closed, blocked, stopped",
c: "adj.",
a: 1,
},
},
{
entry: {
ts: 1527817750,
i: 9964,
p: "سکل",
f: "skul",
g: "skul",
e: "to drink",
r: 3,
c: "v. trans.",
ec: "drink,drinks,drinking,drank,drank",
},
},
];

View File

@ -40,6 +40,10 @@ export function ensureNonComboVerbInfo(i: T.VerbInfo): T.NonComboVerbInfo {
return "stative" in i ? i.stative : "transitive" in i ? i.transitive : i;
}
export function ensureVerbConjugation(o: T.VerbOutput): T.VerbConjugation {
return "stative" in o ? o.stative : "transitive" in o ? o.transitive : o;
}
export function pickPersInf<T>(
s: T.OptionalPersonInflections<T>,
persInf: T.PersonInflectionsField

View File

@ -40,6 +40,8 @@ import {
chooseParticipleInflection,
spaceInForm,
noPersInfs,
ensureNonComboVerbInfo,
ensureVerbConjugation,
} from "./misc-helpers";
import * as T from "../../types";
@ -74,16 +76,20 @@ export function conjugateVerb(
if (info.type === "transitive or grammatically transitive simple") {
return {
info,
transitive: conjugateVerb(
{ ...entry, c: entry.c ? entry.c.replace("/gramm. trans.", "") : "" },
dummyEntry,
info.transitive
) as T.VerbConjugation,
grammaticallyTransitive: conjugateVerb(
{ ...entry, c: entry.c ? entry.c?.replace("trans./", "") : "" },
dummyEntry,
info.grammaticallyTransitive
) as T.VerbConjugation,
transitive: ensureVerbConjugation(
conjugateVerb(
{ ...entry, c: entry.c ? entry.c.replace("/gramm. trans.", "") : "" },
dummyEntry,
info.transitive
)
),
grammaticallyTransitive: ensureVerbConjugation(
conjugateVerb(
{ ...entry, c: entry.c ? entry.c?.replace("trans./", "") : "" },
dummyEntry,
info.grammaticallyTransitive
)
),
};
}
@ -93,16 +99,20 @@ export function conjugateVerb(
) {
return {
info,
stative: conjugateVerb(
{ ...entry, c: entry.c ? entry.c.replace("dyn./", "") : "" },
dummyEntry,
info.stative
) as T.VerbConjugation,
dynamic: conjugateVerb(
{ ...entry, c: entry.c ? entry.c.replace("/stat.", "") : "" },
dummyEntry,
info.dynamic
) as T.VerbConjugation,
stative: ensureVerbConjugation(
conjugateVerb(
{ ...entry, c: entry.c ? entry.c.replace("dyn./", "") : "" },
dummyEntry,
info.stative
)
),
dynamic: ensureVerbConjugation(
conjugateVerb(
{ ...entry, c: entry.c ? entry.c.replace("/stat.", "") : "" },
dummyEntry,
info.dynamic
)
),
};
}
@ -110,7 +120,7 @@ export function conjugateVerb(
return conjugateDynamicCompound(info);
}
const nonComboInfo = info as T.NonComboVerbInfo;
const nonComboInfo = ensureNonComboVerbInfo(info);
const conjugation: T.VerbConjugation = {
info: nonComboInfo,
@ -121,11 +131,9 @@ export function conjugateVerb(
perfect: makePerfectContent(nonComboInfo),
...("singularForm" in info
? {
singularForm: conjugateVerb(
entry,
complement,
info.singularForm
) as T.VerbConjugation,
singularForm: ensureVerbConjugation(
conjugateVerb(entry, complement, info.singularForm)
),
}
: {}),
// if transitive include passive voice
@ -153,7 +161,7 @@ function conjugateDynamicCompound(
// && info.auxVerb.p === "کېدل"
// );
const auxConj = enforceObject(
conjugateVerb(info.auxVerb, info.auxVerbComplement) as T.VerbConjugation,
ensureVerbConjugation(conjugateVerb(info.auxVerb, info.auxVerbComplement)),
info.objComplement.person
);
const complement = info.objComplement.plural

View File

@ -45,6 +45,7 @@ import {
getAuxTransitivity,
chooseParticipleInflection,
noPersInfs,
ensureNonComboVerbInfo,
} from "./misc-helpers";
import * as T from "../../types";
import { isTlulVerb } from "./type-predicates";
@ -283,10 +284,9 @@ function getDynamicCompoundInfo(
const yulEnding = null;
const objComplement = getObjComplementInfo(entry, comp, forceSingular);
const auxVerb = getDynamicAuxVerb(entry);
const auxVerbInfo = getVerbInfo(
auxVerb.entry,
auxVerb.complement
) as T.NonComboVerbInfo;
const auxVerbInfo = ensureNonComboVerbInfo(
getVerbInfo(auxVerb.entry, auxVerb.complement)
);
const compUsed = objComplement.plural
? objComplement.plural
: objComplement.entry;