diff --git a/package.json b/package.json index 2f99f6d..e78503a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "3.4.4", + "version": "3.4.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", diff --git a/src/components/blocks/Block.tsx b/src/components/blocks/Block.tsx index 2fb3252..470491d 100644 --- a/src/components/blocks/Block.tsx +++ b/src/components/blocks/Block.tsx @@ -41,9 +41,6 @@ function Block({ opts, block, king, script }: { if (block.block.type === "perfectiveHead") { return } - if (block.block.type === "verbComplement") { - return ; - } if (block.block.type === "verb") { return ; } @@ -103,8 +100,8 @@ function VerbSBlock({ opts, v, script }: { {"long" in v.ps &&
{length}
} <> - {(v.type === "verb" || v.type === "perfectParticipleBlock") && v.complement && - + {(v.type === "verb" || v.type === "perfectParticipleBlock") && v.complementWelded && + } {getLength(v.ps, length)[0][script]} @@ -134,8 +131,8 @@ function ModalVerbBlock({ opts, v, script }: { {"long" in v.ps &&
{length}
} <> - {v.complement && - + {v.complementWelded && + } {getLength(v.ps, length)[0][script]} @@ -160,20 +157,6 @@ function PerfHeadBlock({ opts, ps, script }: { ; } -function VCompBlock({ opts, comp, script }: { - opts: T.TextOptions, - comp: T.VerbComplementBlock["complement"], - script: "p" | "f", -}) { - return
- - {comp[script]} - -
Complement
- {'\u00A0'} -
; -} - function ModalAuxBlock({ opts, aux, script }: { opts: T.TextOptions, aux: T.ModalVerbKedulPart, @@ -271,7 +254,7 @@ function ComplementBlock({ opts, comp, script, inside }: { {adj.ps[0][script]} -
Adj.
+
Adj. ({getEnglishParticipleInflection(adj.person, "short")})
{adj.e} ; } @@ -295,9 +278,7 @@ function ComplementBlock({ opts, comp, script, inside }: { : comp.type === "loc. adv." ? : comp.type === "noun" - ? - NOT DONE YET - + ? : comp.type === "unselected" ?
@@ -359,6 +340,25 @@ function Sandwich({ opts, sandwich, script }: {
; } +function CompNounBlock({ opts, noun, script }: { + opts: T.TextOptions, + noun: T.Rendered, + script: "p" | "f", +}) { + return
+ + {noun.ps[0][script]} + +
+ Comp. Noun +
+ {noun.e} +
+} + export function NPBlock({ opts, children, inside, english, script }: { opts: T.TextOptions, children: T.Rendered, diff --git a/src/lib/irregular-conjugations.ts b/src/lib/irregular-conjugations.ts index e6114c3..b267cf7 100644 --- a/src/lib/irregular-conjugations.ts +++ b/src/lib/irregular-conjugations.ts @@ -134,7 +134,7 @@ const kawulStatOrDynImperfectivePassive: T.AspectContentPassive = { [[{p: "کول کېدلم", f: "kawul kedúlum"}], [{p: "کول کېدلو", f: "kawul kedúloo"}]], [[{p: "کول کېدلې", f: "kawul kedúle"}], [{p: "کول کېدلئ", f: "kawul kedúleyy"}]], [[{p: "کول کېدلې", f: "kawul kedúle"}], [{p: "کول کېدلئ", f: "kawul kedúleyy"}]], - [[{p: "کول کېدله", f: "kawul kedúlu"}, {p: "کول کېدلو", f: "kawul kedúlo"}], [{p: "کول کېدل", f: "kawul kedúl"}]], + [[{p: "کول کېدلو", f: "kawul kedúlo"}], [{p: "کول کېدل", f: "kawul kedúl"}]], [[{p: "کول کېدله", f: "kawul kedúla"}], [{p: "کول کېدلې", f: "kawul kedúle"}]], ], }, @@ -152,7 +152,7 @@ const kawulStatOrDynImperfectivePassive: T.AspectContentPassive = { [[{p: "به کول کېدلم", f: "ba kawul kedúlum"}], [{p: "به کول کېدلو", f: "ba kawul kedúloo"}]], [[{p: "به کول کېدلې", f: "ba kawul kedúle"}], [{p: "به کول کېدلئ", f: "ba kawul kedúleyy"}]], [[{p: "به کول کېدلې", f: "ba kawul kedúle"}], [{p: "به کول کېدلئ", f: "ba kawul kedúleyy"}]], - [[{p: "به کول کېدله", f: "ba kawul kedúlu"}, {p: "به کول کېدلو", f: "ba kawul kedúlo"}], [{p: "به کول کېدل", f: "ba kawul kedúl"}]], + [[{p: "به کول کېدلو", f: "ba kawul kedúlo"}], [{p: "به کول کېدل", f: "ba kawul kedúl"}]], [[{p: "به کول کېدله", f: "ba kawul kedúla"}], [{p: "به کول کېدلې", f: "ba kawul kedúle"}]], ], }, @@ -387,7 +387,7 @@ export const kedulStat: T.VerbConjugation = { [[{p: "کېدلم", f: "kedúlum"}], [{p: "کېدلو", f: "kedúloo"}]], [[{p: "کېدلې", f: "kedúle"}], [{p: "کېدلئ", f: "kedúleyy"}]], [[{p: "کېدلې", f: "kedúle"}], [{p: "کېدلئ", f: "kedúleyy"}]], - [[{p: "کېدله", f: "kedúlu"}, {p: "کېدلو", f: "kedúlo"}], [{p: "کېدل", f: "kedúl"}]], + [[{p: "کېدلو", f: "kedúlo"}], [{p: "کېدل", f: "kedúl"}]], [[{p: "کېدله", f: "kedúla"}], [{p: "کېدلې", f: "kedúle"}]], ], }, @@ -405,7 +405,7 @@ export const kedulStat: T.VerbConjugation = { [[{p: "به کېدلم", f: "ba kedúlum"}], [{p: "به کېدلو", f: "ba kedúloo"}]], [[{p: "به کېدلې", f: "ba kedúle"}], [{p: "به کېدلئ", f: "ba kedúleyy"}]], [[{p: "به کېدلې", f: "ba kedúle"}], [{p: "به کېدلئ", f: "ba kedúleyy"}]], - [[{p: "به کېدله", f: "ba kedúlu"}, {p: "به کېدلو", f: "ba kedúlo"}], [{p: "به کېدل", f: "ba kedúl"}]], + [[{p: "به کېدلو", f: "ba kedúlo"}], [{p: "به کېدل", f: "ba kedúl"}]], [[{p: "به کېدله", f: "ba kedúla"}], [{p: "به کېدلې", f: "ba kedúle"}]], ], }, @@ -657,7 +657,7 @@ export const kedulDyn: T.VerbConjugation = { [[{p: "کېدلم", f: "kedúlum"}], [{p: "کېدلو", f: "kedúloo"}]], [[{p: "کېدلې", f: "kedúle"}], [{p: "کېدلئ", f: "kedúleyy"}]], [[{p: "کېدلې", f: "kedúle"}], [{p: "کېدلئ", f: "kedúleyy"}]], - [[{p: "کېدله", f: "kedúlu"}, {p: "کېدلو", f: "kedúlo"}], [{p: "کېدل", f: "kedúl"}]], + [[{p: "کېدلو", f: "kedúlo"}], [{p: "کېدل", f: "kedúl"}]], [[{p: "کېدله", f: "kedúla"}], [{p: "کېدلې", f: "kedúle"}]], ], }, @@ -675,7 +675,7 @@ export const kedulDyn: T.VerbConjugation = { [[{p: "به کېدلم", f: "ba kedúlum"}], [{p: "به کېدلو", f: "ba kedúloo"}]], [[{p: "به کېدلې", f: "ba kedúle"}], [{p: "به کېدلئ", f: "ba kedúleyy"}]], [[{p: "به کېدلې", f: "ba kedúle"}], [{p: "به کېدلئ", f: "ba kedúleyy"}]], - [[{p: "به کېدله", f: "ba kedúlu"}, {p: "به کېدلو", f: "ba kedúlo"}], [{p: "به کېدل", f: "ba kedúl"}]], + [[{p: "به کېدلو", f: "ba kedúlo"}], [{p: "به کېدل", f: "ba kedúl"}]], [[{p: "به کېدله", f: "ba kedúla"}], [{p: "به کېدلې", f: "ba kedúle"}]], ], }, @@ -1210,7 +1210,7 @@ export const kawulStat: T.VerbConjugation = { [[{p: "کړلم", f: "kRulum"}], [{p: "کړلو", f: "kRuloo"}]], [[{p: "کړلې", f: "kRule"}], [{p: "کړلئ", f: "kRuleyy"}]], [[{p: "کړلې", f: "kRule"}], [{p: "کړلئ", f: "kRuleyy"}]], - [[{p: "کړله", f: "kRulu"}, {p: "کړلو", f: "kRulo"}], [{p: "کړل", f: "kRul"}, {p: "کړلو", f: "kRuloo"}]], + [[{p: "کړلو", f: "kRulo"}], [{p: "کړل", f: "kRul"}, {p: "کړلو", f: "kRuloo"}]], [[{p: "کړله", f: "kRula"}], [{p: "کړلې", f: "kRule"}]], ], }, @@ -1236,7 +1236,7 @@ export const kawulStat: T.VerbConjugation = { [[{p: "به کړلم", f: "ba kRulum"}], [{p: "به کړلو", f: "ba kRuloo"}]], [[{p: "به کړلې", f: "ba kRule"}], [{p: "به کړلئ", f: "ba kRuleyy"}]], [[{p: "به کړلې", f: "ba kRule"}], [{p: "به کړلئ", f: "ba kRuleyy"}]], - [[{p: "به کړله", f: "ba kRulu"}, {p: "به کړلو", f: "ba kRulo"}], [{p: "به کړل", f: "ba kRul"}, {p: "به کړلو", f: "ba kRuloo"}]], + [[{p: "به کړلو", f: "ba kRulo"}], [{p: "به کړل", f: "ba kRul"}, {p: "به کړلو", f: "ba kRuloo"}]], [[{p: "به کړله", f: "ba kRula"}], [{p: "به کړلې", f: "ba kRule"}]], ], }, @@ -1688,7 +1688,7 @@ export const kawulDyn: T.VerbConjugation = { [[{p: "وکړلم", f: "óokRulum"}], [{p: "وکړلو", f: "óokRuloo"}]], [[{p: "وکړلې", f: "óokRule"}], [{p: "وکړلئ", f: "óokRuleyy"}]], [[{p: "وکړلې", f: "óokRule"}], [{p: "وکړلئ", f: "óokRuleyy"}]], - [[{p: "وکړله", f: "óokRulu"}, {p: "وکړلو", f: "óokRulo"}], [{p: "وکړل", f: "óokRul"}, {p: "وکړلو", f: "óokRuloo"}]], + [[{p: "وکړلو", f: "óokRulo"}], [{p: "وکړل", f: "óokRul"}, {p: "وکړلو", f: "óokRuloo"}]], [[{p: "وکړله", f: "óokRula"}], [{p: "وکړلې", f: "óokRule"}]], ], }, @@ -1714,7 +1714,7 @@ export const kawulDyn: T.VerbConjugation = { [[{p: "به وکړلم", f: "ba óokRulum"}], [{p: "به وکړلو", f: "ba óokRuloo"}]], [[{p: "به وکړلې", f: "ba óokRule"}], [{p: "به وکړلئ", f: "ba óokRuleyy"}]], [[{p: "به وکړلې", f: "ba óokRule"}], [{p: "به وکړلئ", f: "ba óokRuleyy"}]], - [[{p: "به وکړله", f: "ba óokRulu"}, {p: "به وکړلو", f: "ba óokRulo"}], [{p: "به وکړل", f: "ba óokRul"}, {p: "به وکړلو", f: "ba óokRuloo"}]], + [[{p: "به وکړلو", f: "ba óokRulo"}], [{p: "به وکړل", f: "ba óokRul"}, {p: "به وکړلو", f: "ba óokRuloo"}]], [[{p: "به وکړله", f: "ba óokRula"}], [{p: "به وکړلې", f: "ba óokRule"}]], ], }, @@ -4705,7 +4705,7 @@ export const tlul: T.VerbConjugation = { [[{p: "تللم", f: "tlulum"}], [{p: "تللو", f: "tluloo"}]], [[{p: "تللې", f: "tlule"}], [{p: "تللئ", f: "tluleyy"}]], [[{p: "تللې", f: "tlule"}], [{p: "تللئ", f: "tluleyy"}]], - [[{p: "تلله", f: "tlulu"}, {p: "تللو", f: "tlulo"}], [{p: "تلل", f: "tlul"}]], + [[{p: "تللو", f: "tlulo"}], [{p: "تلل", f: "tlul"}]], [[{p: "تلله", f: "tlula"}], [{p: "تللې", f: "tlule"}]], ], }, @@ -4723,7 +4723,7 @@ export const tlul: T.VerbConjugation = { [[{p: "به تللم", f: "ba tlulum"}], [{p: "به تللو", f: "ba tluloo"}]], [[{p: "به تللې", f: "ba tlule"}], [{p: "به تللئ", f: "ba tluleyy"}]], [[{p: "به تللې", f: "ba tlule"}], [{p: "به تللئ", f: "ba tluleyy"}]], - [[{p: "به تلله", f: "ba tlulu"}, {p: "به تللو", f: "ba tlulo"}], [{p: "به تلل", f: "ba tlul"}]], + [[{p: "به تللو", f: "ba tlulo"}], [{p: "به تلل", f: "ba tlul"}]], [[{p: "به تلله", f: "ba tlula"}], [{p: "به تللې", f: "ba tlule"}]], ], }, @@ -5281,7 +5281,7 @@ export const warkawul: T.VerbConjugation = { [[{p: "ورکړلم", f: "wărkRulum"}], [{p: "ورکړلو", f: "wărkRuloo"}]], [[{p: "ورکړلې", f: "wărkRule"}], [{p: "ورکړلئ", f: "wărkRuleyy"}]], [[{p: "ورکړلې", f: "wărkRule"}], [{p: "ورکړلئ", f: "wărkRuleyy"}]], - [[{p: "ورکړله", f: "wărkRulu"}, {p: "ورکړلو", f: "wărkRulo"}], [{p: "ورکړل", f: "wărkRul"}, {p: "ورکړلو", f: "wărkRuloo"}]], + [[{p: "ورکړلو", f: "wărkRulo"}], [{p: "ورکړل", f: "wărkRul"}, {p: "ورکړلو", f: "wărkRuloo"}]], [[{p: "ورکړله", f: "wărkRula"}], [{p: "ورکړلې", f: "wărkRule"}]], ], }, @@ -5307,7 +5307,7 @@ export const warkawul: T.VerbConjugation = { [[{p: "به ورکړلم", f: "ba wărkRulum"}], [{p: "به ورکړلو", f: "ba wărkRuloo"}]], [[{p: "به ورکړلې", f: "ba wărkRule"}], [{p: "به ورکړلئ", f: "ba wărkRuleyy"}]], [[{p: "به ورکړلې", f: "ba wărkRule"}], [{p: "به ورکړلئ", f: "ba wărkRuleyy"}]], - [[{p: "به ورکړله", f: "ba wărkRulu"}, {p: "به ورکړلو", f: "ba wărkRulo"}], [{p: "به ورکړل", f: "ba wărkRul"}, {p: "به ورکړلو", f: "ba wărkRuloo"}]], + [[{p: "به ورکړلو", f: "ba wărkRulo"}], [{p: "به ورکړل", f: "ba wărkRul"}, {p: "به ورکړلو", f: "ba wărkRuloo"}]], [[{p: "به ورکړله", f: "ba wărkRula"}], [{p: "به ورکړلې", f: "ba wărkRule"}]], ], }, @@ -5969,7 +5969,7 @@ export const raakawul: T.VerbConjugation = { [[{p: "راکړلم", f: "raakRulum"}], [{p: "راکړلو", f: "raakRuloo"}]], [[{p: "راکړلې", f: "raakRule"}], [{p: "راکړلئ", f: "raakRuleyy"}]], [[{p: "راکړلې", f: "raakRule"}], [{p: "راکړلئ", f: "raakRuleyy"}]], - [[{p: "راکړله", f: "raakRulu"}, {p: "راکړلو", f: "raakRulo"}], [{p: "راکړل", f: "raakRul"}, {p: "راکړلو", f: "raakRuloo"}]], + [[{p: "راکړلو", f: "raakRulo"}], [{p: "راکړل", f: "raakRul"}, {p: "راکړلو", f: "raakRuloo"}]], [[{p: "راکړله", f: "raakRula"}], [{p: "راکړلې", f: "raakRule"}]], ], }, @@ -5995,7 +5995,7 @@ export const raakawul: T.VerbConjugation = { [[{p: "به راکړلم", f: "ba raakRulum"}], [{p: "به راکړلو", f: "ba raakRuloo"}]], [[{p: "به راکړلې", f: "ba raakRule"}], [{p: "به راکړلئ", f: "ba raakRuleyy"}]], [[{p: "به راکړلې", f: "ba raakRule"}], [{p: "به راکړلئ", f: "ba raakRuleyy"}]], - [[{p: "به راکړله", f: "ba raakRulu"}, {p: "به راکړلو", f: "ba raakRulo"}], [{p: "به راکړل", f: "ba raakRul"}, {p: "به راکړلو", f: "ba raakRuloo"}]], + [[{p: "به راکړلو", f: "ba raakRulo"}], [{p: "به راکړل", f: "ba raakRul"}, {p: "به راکړلو", f: "ba raakRuloo"}]], [[{p: "به راکړله", f: "ba raakRula"}], [{p: "به راکړلې", f: "ba raakRule"}]], ], }, @@ -6657,7 +6657,7 @@ export const darkawul: T.VerbConjugation = { [[{p: "درکړلم", f: "dărkRulum"}], [{p: "درکړلو", f: "dărkRuloo"}]], [[{p: "درکړلې", f: "dărkRule"}], [{p: "درکړلئ", f: "dărkRuleyy"}]], [[{p: "درکړلې", f: "dărkRule"}], [{p: "درکړلئ", f: "dărkRuleyy"}]], - [[{p: "درکړله", f: "dărkRulu"}, {p: "درکړلو", f: "dărkRulo"}], [{p: "درکړل", f: "dărkRul"}, {p: "درکړلو", f: "dărkRuloo"}]], + [[{p: "درکړلو", f: "dărkRulo"}], [{p: "درکړل", f: "dărkRul"}, {p: "درکړلو", f: "dărkRuloo"}]], [[{p: "درکړله", f: "dărkRula"}], [{p: "درکړلې", f: "dărkRule"}]], ], }, @@ -6683,7 +6683,7 @@ export const darkawul: T.VerbConjugation = { [[{p: "به درکړلم", f: "ba dărkRulum"}], [{p: "به درکړلو", f: "ba dărkRuloo"}]], [[{p: "به درکړلې", f: "ba dărkRule"}], [{p: "به درکړلئ", f: "ba dărkRuleyy"}]], [[{p: "به درکړلې", f: "ba dărkRule"}], [{p: "به درکړلئ", f: "ba dărkRuleyy"}]], - [[{p: "به درکړله", f: "ba dărkRulu"}, {p: "به درکړلو", f: "ba dărkRulo"}], [{p: "به درکړل", f: "ba dărkRul"}, {p: "به درکړلو", f: "ba dărkRuloo"}]], + [[{p: "به درکړلو", f: "ba dărkRulo"}], [{p: "به درکړل", f: "ba dărkRul"}, {p: "به درکړلو", f: "ba dărkRuloo"}]], [[{p: "به درکړله", f: "ba dărkRula"}], [{p: "به درکړلې", f: "ba dărkRule"}]], ], }, diff --git a/src/lib/phrase-building/blocks-utils.ts b/src/lib/phrase-building/blocks-utils.ts index 5e6e298..7c069f4 100644 --- a/src/lib/phrase-building/blocks-utils.ts +++ b/src/lib/phrase-building/blocks-utils.ts @@ -119,8 +119,8 @@ export function getComplementFromBlocks(blocks: T.Block[][]): T.Rendered { + const e = getEnglishWord(entry); + if (!e || typeof e !== "string") { + throw new Error("error getting english for compliment"); + } + return { + type: "loc. adv.", + entry: entry, + ps: [psStringFromEntry(entry)], + e, + inflected: false, + // TODO: don't use persons for these + person: T.Person.FirstSingMale, + role: "none", + }; } \ No newline at end of file diff --git a/src/lib/phrase-building/render-complement.ts b/src/lib/phrase-building/render-complement.ts index 2184396..43caaae 100644 --- a/src/lib/phrase-building/render-complement.ts +++ b/src/lib/phrase-building/render-complement.ts @@ -1,9 +1,8 @@ import * as T from "../../types"; import { renderNounSelection } from "./render-np"; -import { getEnglishWord } from "../get-english-word"; -import { psStringFromEntry } from "../p-text-helpers"; import { renderAdjectiveSelection } from "./render-adj"; import { renderSandwich } from "./render-sandwich"; +import { renderLocativeAdverbSelection } from "./render-ap"; export function renderComplementSelection(s: T.ComplementSelection | T.UnselectedComplementSelection, person: T.Person): T.Rendered { if (s.selection.type === "unselected") { @@ -22,23 +21,10 @@ export function renderComplementSelection(s: T.ComplementSelection | T.Unselecte selection: renderSandwich(s.selection), }; } - const e = getEnglishWord(s.selection.entry); - if (!e || typeof e !== "string") { - throw new Error("error getting english for compliment"); - } if (s.selection.type === "loc. adv.") { return { type: "complement", - selection: { - type: "loc. adv.", - entry: s.selection.entry, - ps: [psStringFromEntry(s.selection.entry)], - e, - inflected: false, - // TODO: don't use persons for these - person, - role: "none", - }, + selection: renderLocativeAdverbSelection(s.selection), }; } if (s.selection.type === "adjective") { @@ -50,6 +36,6 @@ export function renderComplementSelection(s: T.ComplementSelection | T.Unselecte // if (s.selection.type === "noun") { return { type: "complement", - selection: renderNounSelection(s.selection, false, "none"), + selection: renderNounSelection(s.selection, false, "none", "noArticles"), }; } \ No newline at end of file diff --git a/src/lib/phrase-building/render-np.ts b/src/lib/phrase-building/render-np.ts index 01bf7fd..53a893b 100644 --- a/src/lib/phrase-building/render-np.ts +++ b/src/lib/phrase-building/render-np.ts @@ -46,8 +46,8 @@ export function renderNPSelection(NP: T.NPSelection, inflected: boolean, inflect throw new Error("unknown NP type"); }; -export function renderNounSelection(n: T.NounSelection, inflected: boolean, role: "servant" | "king" | "none"): T.Rendered { - const english = getEnglishFromNoun(n.entry, n.number); +export function renderNounSelection(n: T.NounSelection, inflected: boolean, role: "servant" | "king" | "none", noArticles?: true | "noArticles"): T.Rendered { + const english = getEnglishFromNoun(n.entry, n.number, noArticles); const pashto = ((): T.PsString[] => { const infs = inflectWord(n.entry); const ps = n.number === "singular" @@ -129,13 +129,14 @@ function getInf(infs: T.InflectorOutput, t: "plural" | "arabicPlural" | "inflect return []; } -function getEnglishFromNoun(entry: T.DictionaryEntry, number: T.NounNumber): string { +function getEnglishFromNoun(entry: T.DictionaryEntry, number: T.NounNumber, noArticles?: true | "noArticles"): string { const articles = { singular: "(a/the)", plural: "(the)", }; const article = articles[number]; function addArticle(s: string) { + if (noArticles) return s; return `${article} ${s}`; } const e = getEnglishWord(entry); diff --git a/src/lib/phrase-building/render-vp.ts b/src/lib/phrase-building/render-vp.ts index c7b3a00..cef831d 100644 --- a/src/lib/phrase-building/render-vp.ts +++ b/src/lib/phrase-building/render-vp.ts @@ -18,8 +18,11 @@ import { getTenseVerbForm, } from "./vp-tools"; import { + isAdjectiveEntry, isImperativeTense, + isLocativeAdverbEntry, isModalTense, + isNounEntry, isPattern4Entry, isPerfectTense, } from "../type-predicates"; @@ -30,8 +33,7 @@ import { findPerfectiveHead, getObjectSelection, getSubjectSelection, makeBlock, import { renderAPSelection } from "./render-ap"; import { findPossesivesToShrink, orderKids, getMiniPronounPs } from "./render-common"; import { renderComplementSelection } from "./render-complement"; - -// TODO: ISSUE GETTING SPLIT HEAD NOT MATCHING WITH FUTURE VERBS +import { makeNounSelection } from "../../library"; export function renderVP(VP: T.VPSelectionComplete): T.VPRendered { const subject = getSubjectSelection(VP.blocks).selection; @@ -421,7 +423,15 @@ function renderVerbSelection(vs: T.VerbSelectionComplete, person: T.Person, comp : conjugations; const { ps: { head, rest }, hasBa } = getPsVerbConjugation(conj, vs, person, complementPerson); const perfective = isPerfective(vs.tense); - const stativeHelper = isStativeHelper(vs.verb) + const stativeHelper = isStativeHelper(vs.verb); + const complement: T.ComplementSelection | T.UnselectedComplementSelection | undefined = externalComplement + ? externalComplement + : vs.isCompound === "stative" + ? createComplementRetroactively(vs.verb.complement, complementPerson) + : undefined; + const renderedComplement = complement + ? renderComplementSelection(complement, complementPerson || T.Person.FirstSingMale) + : undefined; const vrb: T.VerbRenderedBlock = { type: "verb", block: { @@ -429,21 +439,26 @@ function renderVerbSelection(vs: T.VerbSelectionComplete, person: T.Person, comp ps: rest, person, hasBa, - complement: (!perfective && stativeHelper && externalComplement) - ? renderComplementSelection(externalComplement, complementPerson || T.Person.FirstSingMale) + complementWelded: ((!perfective && renderedComplement) && ( + // it's a stative helper (kawul/kedul) with an external complement + (stativeHelper && externalComplement) + || + // it's a stative compound with a space + (vs.verb.entry.p.includes(" ")) + )) + ? renderedComplement : undefined, }, }; const verbBlocks = [ ...(head ? ( - (!!(vs.isCompound === "stative" && vrb.block.complement)) ? [{ - type: "verbComplement", - complement: head, - } as T.VerbComplementBlock] : [{ + (!!(vs.isCompound === "stative" && renderedComplement)) ? [ + renderedComplement, + ] : [{ type: "perfectiveHead", ps: head, } as T.PerfectiveHeadBlock] - ) : [] as [T.VerbComplementBlock] | [T.PerfectiveHeadBlock] | []), + ) : [] as [T.Rendered] | [T.PerfectiveHeadBlock] | []), ...(externalComplement && perfective && stativeHelper) ? [renderComplementSelection(externalComplement, complementPerson || T.Person.FirstSingMale)] : [], @@ -456,7 +471,43 @@ function renderVerbSelection(vs: T.VerbSelectionComplete, person: T.Person, comp }; } -function isStativeHelper(v: T.VerbEntry): boolean { +function createComplementRetroactively(complement: T.DictionaryEntry | undefined, person: T.Person | undefined): T.ComplementSelection { + // This is a bit of a hack to work with the current verb conjugation system. + if (!complement) { + throw new Error("error creating complement from head - no complement in verb entry"); + } + if (isNounEntry(complement)) { + return { + type: "complement", + selection: makeNounSelection(complement, undefined, undefined), + }; + } + if (isAdjectiveEntry(complement)) { + if (person === undefined) { + throw new Error("there needs to be a complement person for rendering an adjective complement"); + } + return { + type: "complement", + selection: { + type: "adjective", + entry: complement, + sandwich: undefined, + }, + }; + } + if (isLocativeAdverbEntry(complement)) { + return { + type: "complement", + selection: { + type: "loc. adv.", + entry: complement, + }, + }; + } + throw new Error("unsupported complement type"); +} + +export function isStativeHelper(v: T.VerbEntry): boolean { if (v.entry.p === "کول" && v.entry.e.includes("make")) return true; if (v.entry.p === "کېدل" && v.entry.e.includes("become")) return true; return false; @@ -472,7 +523,7 @@ function splitUpIfModal(v: T.VerbRenderedBlock): [T.VerbRenderedBlock] | [T.Moda type: "modalVerbBlock", ps: vrb, verb: v, - complement: v.block.complement, + complementWelded: v.block.complementWelded, }, { type: "modalVerbKedulPart", @@ -491,7 +542,7 @@ function getPerfectStuff(v: T.SingleOrLengthOpts, vrb: T.VerbRende ps: p, person: vrb.block.person, verb: vrb, - complement: vrb.block.complement, + complementWelded: vrb.block.complementWelded, }, { type: "perfectEquativeBlock", diff --git a/src/types.ts b/src/types.ts index 1d3b803..089e331 100644 --- a/src/types.ts +++ b/src/types.ts @@ -895,16 +895,13 @@ export type EntryLookupPortal = { } export type EquativeBlock = { type: "equative", equative: EquativeRendered }; -export type VerbComplementBlock = { - type: "verbComplement", - complement: PsString, -}; + export type PerfectParticipleBlock = { type: "perfectParticipleBlock", ps: SingleOrLengthOpts, verb: VerbRenderedBlock, person: Person, - complement: undefined | Rendered | Rendered, + complementWelded: undefined | Rendered | Rendered, }; export type PerfectEquativeBlock = { type: "perfectEquativeBlock", @@ -915,7 +912,7 @@ export type ModalVerbBlock = { type: "modalVerbBlock", ps: SingleOrLengthOpts, verb: VerbRenderedBlock, - complement: undefined | Rendered | Rendered, + complementWelded: undefined | Rendered | Rendered, }; export type ModalVerbKedulPart = { type: "modalVerbKedulPart", @@ -929,7 +926,7 @@ export type VerbRenderedBlock = { hasBa: boolean, ps: SingleOrLengthOpts, person: Person, - complement: undefined | Rendered | Rendered, + complementWelded: undefined | Rendered | Rendered, }, }; @@ -948,7 +945,6 @@ export type Block = { | { type: "negative", imperative: boolean } | PerfectiveHeadBlock | VerbRenderedBlock - | VerbComplementBlock | EquativeBlock; }