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 - uses: actions/setup-node@v4
with: with:
node-version: 20 node-version: 20
cache: "npm" cache: "yarn"
- name: run script - name: run script
run: | run: |
yarn install-r yarn install-r

View File

@ -29,7 +29,7 @@ async function checkAll() {
err: e.toString(), err: e.toString(),
}); });
} }
if (tp.isVerbEntry(entry)) { if (tp.isVerbDictionaryEntry(entry)) {
const complement = entry.l const complement = entry.l
? entries.find((e) => e.ts === entry.l) ? entries.find((e) => e.ts === entry.l)
: undefined; : undefined;
@ -41,6 +41,16 @@ async function checkAll() {
err: "verb complement missing", err: "verb complement missing",
}); });
} else { } 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", "name": "pashto-inflector",
"version": "7.4.0", "version": "7.4.1",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "pashto-inflector", "name": "pashto-inflector",
"version": "7.4.0", "version": "7.4.1",
"hasInstallScript": true, "hasInstallScript": true,
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {

View File

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

View File

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

View File

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

View File

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

View File

@ -576,4 +576,228 @@ export const dynamicAuxVerbs: Array<{
ec: "send,sends,sending,sent,sent", 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; 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>( export function pickPersInf<T>(
s: T.OptionalPersonInflections<T>, s: T.OptionalPersonInflections<T>,
persInf: T.PersonInflectionsField persInf: T.PersonInflectionsField

View File

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

View File

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