english working properly with kawul/kedul w compounds
This commit is contained in:
parent
511e215592
commit
590ed3e0d8
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/pashto-inflector",
|
"name": "@lingdocs/pashto-inflector",
|
||||||
"version": "3.3.4",
|
"version": "3.3.5",
|
||||||
"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",
|
||||||
|
|
|
@ -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 {
|
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");
|
const complement = blocks[0].find(b => b.block.type === "complement")?.block as T.Rendered<T.ComplementSelection> | T.Rendered<T.UnselectedComplementSelection> | undefined;
|
||||||
if (!complement) {
|
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;
|
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.VPSBlockComplete[]): T.ObjectSelectionComplete;
|
||||||
export function getObjectSelection(blocks: T.VPSBlock[]): T.ObjectSelection;
|
export function getObjectSelection(blocks: T.VPSBlock[]): T.ObjectSelection;
|
||||||
|
|
|
@ -26,8 +26,8 @@ import {
|
||||||
} from "./blocks-utils";
|
} from "./blocks-utils";
|
||||||
|
|
||||||
const blank: T.PsString = {
|
const blank: T.PsString = {
|
||||||
p: "______",
|
p: "_____",
|
||||||
f: "______",
|
f: "_____",
|
||||||
};
|
};
|
||||||
type BlankoutOptions = { equative?: boolean, ba?: boolean, kidsSection?: boolean };
|
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 => (
|
return combine(rest).flatMap(r => (
|
||||||
firstPs.map(fPs => concatPsString(
|
firstPs.map(fPs => concatPsString(
|
||||||
fPs,
|
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")))
|
(!("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,
|
r,
|
||||||
))
|
))
|
||||||
|
@ -206,6 +207,7 @@ function getPsFromPiece(piece: T.Block | T.Kid, subjectPerson: T.Person): T.PsSt
|
||||||
return [piece.block.ps];
|
return [piece.block.ps];
|
||||||
}
|
}
|
||||||
if (piece.block.type === "verbComplement") {
|
if (piece.block.type === "verbComplement") {
|
||||||
|
// TODO: WHAAAAT
|
||||||
return [{ p: "____", f: "____"}]; //getPashtoFromRendered(piece.block.complement);
|
return [{ p: "____", f: "____"}]; //getPashtoFromRendered(piece.block.complement);
|
||||||
}
|
}
|
||||||
if (piece.block.type === "objectSelection") {
|
if (piece.block.type === "objectSelection") {
|
||||||
|
@ -277,12 +279,13 @@ function getEngAPs(blocks: T.Block[][]): string {
|
||||||
function getEngComplement(blocks: T.Block[][]): string | undefined {
|
function getEngComplement(blocks: T.Block[][]): string | undefined {
|
||||||
const comp = getComplementFromBlocks(blocks);
|
const comp = getComplementFromBlocks(blocks);
|
||||||
if (!comp) return undefined;
|
if (!comp) return undefined;
|
||||||
if (comp.selection === undefined) {
|
if (comp.selection.type === "unselected") {
|
||||||
return "____";
|
return "____";
|
||||||
}
|
}
|
||||||
if (comp.selection.type === "sandwich") {
|
if (comp.selection.type === "sandwich") {
|
||||||
return getEnglishFromRendered({ type: "AP", selection: comp.selection });
|
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)[][] {
|
function putKidsInKidsSection(blocksWVars: T.Block[][], kids: T.Kid[], enforceKidsSectionBlankout: boolean): (T.Block | T.Kid | T.PsString)[][] {
|
||||||
|
|
|
@ -24,7 +24,8 @@ export function renderEnglishVPBase({ subjectPerson, object, vs }: {
|
||||||
vs: T.VerbSelectionComplete,
|
vs: T.VerbSelectionComplete,
|
||||||
}): string[] {
|
}): string[] {
|
||||||
const ec = parseEc(vs.verb.entry.ec || "");
|
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 {
|
function engEquative(tense: "past" | "present", s: T.Person): string {
|
||||||
const [row, col] = getVerbBlockPosFromPerson(s);
|
const [row, col] = getVerbBlockPosFromPerson(s);
|
||||||
return grammarUnits.englishEquative[tense][row][col];
|
return grammarUnits.englishEquative[tense][row][col];
|
||||||
|
@ -53,8 +54,8 @@ export function renderEnglishVPBase({ subjectPerson, object, vs }: {
|
||||||
`$SUBJ ${engEquative("present", s)}${n ? " not" : ""} ${ec[2]}`,
|
`$SUBJ ${engEquative("present", s)}${n ? " not" : ""} ${ec[2]}`,
|
||||||
]),
|
]),
|
||||||
subjunctiveVerb: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
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]}`,
|
`$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) => ([
|
imperfectiveFuture: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([
|
||||||
`$SUBJ will${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
`$SUBJ will${n ? " not" : ""} ${isToBe(ec) ? "be" : ec[0]}`,
|
||||||
|
|
|
@ -60,7 +60,7 @@ export function renderVP(VP: T.VPSelectionComplete): T.VPRendered {
|
||||||
king,
|
king,
|
||||||
complementPerson,
|
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 = {
|
const b: T.VPRendered = {
|
||||||
type: "VPRendered",
|
type: "VPRendered",
|
||||||
king,
|
king,
|
||||||
|
@ -436,7 +436,7 @@ function renderVerbSelection(vs: T.VerbSelectionComplete, person: T.Person, comp
|
||||||
};
|
};
|
||||||
const verbBlocks = [
|
const verbBlocks = [
|
||||||
...(head ? (
|
...(head ? (
|
||||||
(vs.isCompound === "stative" && !vrb.block.complement) ? [{
|
(!!(vs.isCompound === "stative" && vrb.block.complement)) ? [{
|
||||||
type: "verbComplement",
|
type: "verbComplement",
|
||||||
complement: head,
|
complement: head,
|
||||||
} as T.VerbComplementBlock] : [{
|
} as T.VerbComplementBlock] : [{
|
||||||
|
|
Loading…
Reference in New Issue