english working properly with kawul/kedul w compounds

This commit is contained in:
lingdocs 2022-07-10 18:55:23 -05:00
parent 511e215592
commit 590ed3e0d8
5 changed files with 21 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/pashto-inflector",
"version": "3.3.4",
"version": "3.3.5",
"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",

View File

@ -113,15 +113,17 @@ export function getAPsFromBlocks(blocks: T.Block[][]): T.Rendered<T.APSelection>
}
export function getComplementFromBlocks(blocks: T.Block[][]): T.Rendered<T.ComplementSelection> | T.Rendered<T.UnselectedComplementSelection> | undefined {
const complement = blocks[0].find(b => b.block.type === "complement");
if (!complement) {
const complement = blocks[0].find(b => b.block.type === "complement")?.block as T.Rendered<T.ComplementSelection> | T.Rendered<T.UnselectedComplementSelection> | undefined;
if (complement) {
return complement;
}
// maybe there's a complement in the verb block
const verb = blocks[0].find(b => b.block.type === "verb" && b.block)?.block as T.VerbRenderedBlock | undefined;
if (verb?.block.complement) {
return verb.block.complement;
}
return undefined;
}
if (complement.block.type !== "complement") {
throw new Error("error finding complement - other kind of block retrieved");
}
return complement.block;
}
export function getObjectSelection(blocks: T.VPSBlockComplete[]): T.ObjectSelectionComplete;
export function getObjectSelection(blocks: T.VPSBlock[]): T.ObjectSelection;

View File

@ -26,8 +26,8 @@ import {
} from "./blocks-utils";
const blank: T.PsString = {
p: "______",
f: "______",
p: "_____",
f: "_____",
};
type BlankoutOptions = { equative?: boolean, ba?: boolean, kidsSection?: boolean };
@ -174,8 +174,9 @@ function combineIntoText(piecesWVars: (T.Block | T.Kid | T.PsString)[][], subjec
return combine(rest).flatMap(r => (
firstPs.map(fPs => concatPsString(
fPs,
// TODO: this spacing is a mess and not accurate
(!("p" in first) && "block" in first && first.block.type === "perfectiveHead" && !("p" in next) && (("block" in next && (next.block.type === "verb" || next.block.type === "negative" || next.block.type === "modalVerbBlock")) || ("kid" in next && next.kid.type === "mini-pronoun")))
? ((("block" in next && next.block.type === "negative") || ("kid" in next && next.kid.type === "mini-pronoun")) ? { p: "", f: "-" } : "")
? ((("block" in next && next.block.type === "negative") || ("kid" in next && next.kid.type === "mini-pronoun")) ? { p: "", f: " " } : "")
: " ",
r,
))
@ -206,6 +207,7 @@ function getPsFromPiece(piece: T.Block | T.Kid, subjectPerson: T.Person): T.PsSt
return [piece.block.ps];
}
if (piece.block.type === "verbComplement") {
// TODO: WHAAAAT
return [{ p: "____", f: "____"}]; //getPashtoFromRendered(piece.block.complement);
}
if (piece.block.type === "objectSelection") {
@ -277,12 +279,13 @@ function getEngAPs(blocks: T.Block[][]): string {
function getEngComplement(blocks: T.Block[][]): string | undefined {
const comp = getComplementFromBlocks(blocks);
if (!comp) return undefined;
if (comp.selection === undefined) {
if (comp.selection.type === "unselected") {
return "____";
}
if (comp.selection.type === "sandwich") {
return getEnglishFromRendered({ type: "AP", selection: comp.selection });
}
return comp.selection.e;
}
function putKidsInKidsSection(blocksWVars: T.Block[][], kids: T.Kid[], enforceKidsSectionBlankout: boolean): (T.Block | T.Kid | T.PsString)[][] {

View File

@ -24,7 +24,8 @@ export function renderEnglishVPBase({ subjectPerson, object, vs }: {
vs: T.VerbSelectionComplete,
}): string[] {
const ec = parseEc(vs.verb.entry.ec || "");
const ep = vs.verb.entry.ep;
// in case there's something left with the deprecated ep as _____
const ep = vs.verb.entry.ep?.includes("__") ? undefined : vs.verb.entry.ep;
function engEquative(tense: "past" | "present", s: T.Person): string {
const [row, col] = getVerbBlockPosFromPerson(s);
return grammarUnits.englishEquative[tense][row][col];
@ -53,8 +54,8 @@ export function renderEnglishVPBase({ subjectPerson, object, vs }: {
`$SUBJ ${engEquative("present", s)}${n ? " not" : ""} ${ec[2]}`,
]),
subjunctiveVerb: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
`that $SUBJ ${n ? " won't" : " will"} ${isToBe(ec) ? "be" : ec[0]}`,
`$SUBJ ${n ? " not" : ""} should ${isToBe(ec) ? "be" : ec[0]}`,
`that $SUBJ ${n ? " won't" : " will"} ${isToBe(ec) ? "be" : ec[0]}`,
]),
imperfectiveFuture: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
`$SUBJ will${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,

View File

@ -60,7 +60,7 @@ export function renderVP(VP: T.VPSelectionComplete): T.VPRendered {
king,
complementPerson,
});
const { verbBlocks, hasBa } = renderVerbSelection(VP.verb, kingPerson, objectPerson, VP.externalComplement);
const { verbBlocks, hasBa } = renderVerbSelection(VP.verb, kingPerson, objectPerson === undefined ? subjectPerson : objectPerson, VP.externalComplement);
const b: T.VPRendered = {
type: "VPRendered",
king,
@ -436,7 +436,7 @@ function renderVerbSelection(vs: T.VerbSelectionComplete, person: T.Person, comp
};
const verbBlocks = [
...(head ? (
(vs.isCompound === "stative" && !vrb.block.complement) ? [{
(!!(vs.isCompound === "stative" && vrb.block.complement)) ? [{
type: "verbComplement",
complement: head,
} as T.VerbComplementBlock] : [{