From 02a78b6fcf3df89e446c2a59089763597c869cce Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Tue, 30 Aug 2022 17:57:28 +0400 Subject: [PATCH] fixup --- package.json | 2 +- src/lib/grammar-units.ts | 2 +- src/lib/misc-helpers.ts | 6 ++++++ src/lib/phrase-building/compile.ts | 13 ++++++------- src/lib/phrase-building/english-vp-rendering.ts | 7 ++++--- src/lib/phrase-building/render-np.ts | 14 +++++++------- src/lib/phrase-building/render-sandwich.ts | 7 +++---- src/library.ts | 10 +++++----- 8 files changed, 33 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 7fe0cd5..f3af2fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "3.8.4", + "version": "3.8.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/lib/grammar-units.ts b/src/lib/grammar-units.ts index 528399e..cfb63d1 100644 --- a/src/lib/grammar-units.ts +++ b/src/lib/grammar-units.ts @@ -189,7 +189,7 @@ export const pastEndings: { ], [ [{ - p: "ۀ", + p: "ه", f: "u" }, { diff --git a/src/lib/misc-helpers.ts b/src/lib/misc-helpers.ts index 3af9eaf..3cd7035 100644 --- a/src/lib/misc-helpers.ts +++ b/src/lib/misc-helpers.ts @@ -8,6 +8,12 @@ import * as T from "../types"; +export const blank: T.PsString = { + p: "_____", + f: "_____", +}; +export const kidsBlank: T.PsString = { p: "___", f: "___" }; + // just for type safety export function noPersInfs(s: T.OptionalPersonInflections>): T.LengthOptions; export function noPersInfs(s: T.FullForm): T.SingleOrLengthOpts; diff --git a/src/lib/phrase-building/compile.ts b/src/lib/phrase-building/compile.ts index 438461d..5f7ae78 100644 --- a/src/lib/phrase-building/compile.ts +++ b/src/lib/phrase-building/compile.ts @@ -25,16 +25,14 @@ import { specifyBlockLength, specifyEquativeLength, } from "./blocks-utils"; +import { + blank, + kidsBlank, +} from "../../lib/misc-helpers"; + -export const blank: T.PsString = { - p: "_____", - f: "_____", -}; type BlankoutOptions = { equative?: boolean, ba?: boolean, kidsSection?: boolean, verb?: boolean }; -export const kidsBlank: T.PsString = { p: "___", f: "___" }; - - // function compilePs({ blocks, kids, verb: { head, rest }, VP }: CompilePsInput): T.SingleOrLengthOpts { // if ("long" in rest) { // return { @@ -436,3 +434,4 @@ export function flattenLengths(r: T.SingleOrLengthOpts string[] > = { imperfectiveImperative: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([ - `$SUBJ ${n ? "don't " : ""}${ec[0]}! (command)`, + `$SUBJ ${n ? "don't " : ""}${ec[0]}!`, ]), perfectiveImperative: (s: T.Person, ec: T.EnglishVerbConjugationEc, n: boolean) => ([ - `$SUBJ ${n ? "don't " : ""}${ec[0]}! (command)`, + `$SUBJ ${n ? "don't " : ""}${ec[0]}!`, ]), }; const base = ( @@ -265,5 +265,6 @@ export function renderEnglishVPBase({ subjectPerson, object, vs }: { : isImperativeTense(vs.tense) ? imperativeBuilders[vs.tense] : (vs.voice === "active" ? modalBuilders : passiveModalBuilders)[vs.tense])(subjectPerson, ec, vs.negative); - return base.map(b => `${b}${typeof object === "object" ? " $OBJ" : ""}${ep ? ` ${ep}` : ""}`.replace(" ", " ").trim()); + return base + .map(b => `${b}${typeof object === "object" ? " $OBJ" : ""}${ep ? ` ${ep}` : ""}${isImperativeTense(vs.tense) ? " (command)" : ""}`.replace(" ", " ").trim()); } diff --git a/src/lib/phrase-building/render-np.ts b/src/lib/phrase-building/render-np.ts index 768730b..2571db5 100644 --- a/src/lib/phrase-building/render-np.ts +++ b/src/lib/phrase-building/render-np.ts @@ -16,9 +16,9 @@ import { getEnglishWord } from "../get-english-word"; import { renderAdjectiveSelection } from "./render-adj"; import { isPattern5Entry, isAnimNounEntry, isPattern1Entry } from "../type-predicates"; -export function renderNPSelection(NP: T.NPSelection, inflected: boolean, inflectEnglish: boolean, role: "subject", soRole: "servant" | "king" | "none", isLocationSandwich: boolean): T.Rendered; -export function renderNPSelection(NP: T.NPSelection, inflected: boolean, inflectEnglish: boolean, role: "object", soRole: "servant" | "king" | "none", isLocationSandwich: boolean): T.Rendered; -export function renderNPSelection(NP: T.NPSelection, inflected: boolean, inflectEnglish: boolean, role: "subject" | "object", soRole: "servant" | "king" | "none", isLocationSandwich: boolean): T.Rendered { +export function renderNPSelection(NP: T.NPSelection, inflected: boolean, inflectEnglish: boolean, role: "subject", soRole: "servant" | "king" | "none", isPuSandwich: boolean): T.Rendered; +export function renderNPSelection(NP: T.NPSelection, inflected: boolean, inflectEnglish: boolean, role: "object", soRole: "servant" | "king" | "none", isPuSandwich: boolean): T.Rendered; +export function renderNPSelection(NP: T.NPSelection, inflected: boolean, inflectEnglish: boolean, role: "subject" | "object", soRole: "servant" | "king" | "none", isPuSandwich: boolean): T.Rendered { if (typeof NP !== "object") { if (role !== "object") { throw new Error("ObjectNP only allowed for objects"); @@ -28,7 +28,7 @@ export function renderNPSelection(NP: T.NPSelection, inflected: boolean, inflect if (NP.selection.type === "noun") { return { type: "NP", - selection: renderNounSelection(NP.selection, inflected, soRole, undefined, isLocationSandwich), + selection: renderNounSelection(NP.selection, inflected, soRole, undefined, isPuSandwich), }; } if (NP.selection.type === "pronoun") { @@ -46,9 +46,9 @@ 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", noArticles?: true | "noArticles", isLocationSandwich?: boolean): T.Rendered { +export function renderNounSelection(n: T.NounSelection, inflected: boolean, role: "servant" | "king" | "none", noArticles?: true | "noArticles", isPuSandwich?: boolean): T.Rendered { const english = getEnglishFromNoun(n.entry, n.number, noArticles); - const nounInflects = !(isLocationSandwich && isPattern1Entry(n.entry) && n.number === "singular") + const nounInflects = !(isPuSandwich && isPattern1Entry(n.entry) && n.number === "singular") const pashto = ((): T.PsString[] => { const infs = inflectWord(n.entry); const ps = n.number === "singular" @@ -69,7 +69,7 @@ export function renderNounSelection(n: T.NounSelection, inflected: boolean, role const person = getPersonNumber(n.gender, n.number); return { ...n, - adjectives: n.adjectives.map(a => renderAdjectiveSelection(a, person, inflected, isLocationSandwich && n.number === "singular")), + adjectives: n.adjectives.map(a => renderAdjectiveSelection(a, person, inflected, isPuSandwich && n.number === "singular")), person, inflected, role, diff --git a/src/lib/phrase-building/render-sandwich.ts b/src/lib/phrase-building/render-sandwich.ts index f6dab97..6ff09a6 100644 --- a/src/lib/phrase-building/render-sandwich.ts +++ b/src/lib/phrase-building/render-sandwich.ts @@ -14,12 +14,11 @@ export function renderSandwich(s: T.SandwichSelection): T.Rendered): boolean { - // TODO: more nuanced version of this? or just په ? - return (s.before?.p === "په") && (s.after?.p === "کې"); +function isPuSandwich(s: T.SandwichSelection): boolean { + return s.before?.p === "په"; } \ No newline at end of file diff --git a/src/library.ts b/src/library.ts index d0d30ff..ac5704b 100644 --- a/src/library.ts +++ b/src/library.ts @@ -39,9 +39,6 @@ import Block, { NPBlock, APBlock } from "./components/blocks/Block"; import { roleIcon } from "./components/vp-explorer/VPExplorerExplanationModal"; import CompiledPTextDisplay from "./components/CompiledPTextDisplay"; import RenderedBlocksDisplay from "./components/RenderedBlocksDisplay"; -import { - isPashtoScript, -} from "./lib/is-pashto"; import { makePsString, removeFVarients, @@ -122,6 +119,8 @@ import { isFirstPerson, isSecondPerson, isThirdPerson, + blank, + kidsBlank, } from "./lib/misc-helpers"; import { simplifyPhonetics, @@ -154,9 +153,10 @@ import { compileEP, compileVP, flattenLengths, - blank, - kidsBlank, } from "./lib/phrase-building/compile"; +import { + isPashtoScript, +} from "./lib/is-pashto"; import { renderAPSelection, } from "./lib/phrase-building/render-ap";