diff --git a/src/lib/src/new-verb-engine/render-verb.ts b/src/lib/src/new-verb-engine/render-verb.ts index 612c629..57e5dcb 100644 --- a/src/lib/src/new-verb-engine/render-verb.ts +++ b/src/lib/src/new-verb-engine/render-verb.ts @@ -6,8 +6,11 @@ import { personToGenNum, } from "../misc-helpers"; import { fmapSingleOrLengthOpts } from "../fp-ps"; -import { concatPsString, getLength } from "../p-text-helpers"; -import { zipWith } from "rambda"; +import { + concatPsString, + getLength, + splitPsByVarients, +} from "../p-text-helpers"; import { presentEndings, pastEndings, @@ -363,9 +366,9 @@ function ensure3rdPast( ]; } if (verb.entry.tppp && verb.entry.tppf) { - const tppp = verb.entry.tppp.split(",").map((x) => x.trim()); - const tppf = verb.entry.tppf.split(",").map((x) => x.trim()); - const tpps = zipWith((p, f) => ({ p, f }), tppp, tppf); + const tpps = splitPsByVarients( + makePsString(verb.entry.tppp, verb.entry.tppf) + ); return tpps.map(({ p, f }) => { const tip = removeAccents( verb.entry.separationAtP !== undefined diff --git a/src/lib/src/p-text-helpers.ts b/src/lib/src/p-text-helpers.ts index a5c1db2..83ef070 100644 --- a/src/lib/src/p-text-helpers.ts +++ b/src/lib/src/p-text-helpers.ts @@ -16,6 +16,7 @@ import { hasAccents, removeAccents } from "./accent-helpers"; import { phoneticsConsonants } from "./pashto-consonants"; import { simplifyPhonetics } from "./simplify-phonetics"; import { makePsString, removeFVarients } from "./accent-and-ps-utils"; +import { zipWith } from "rambda"; // export function concatPsStringWithVars(...items: Array): T.PsString[] { @@ -1086,14 +1087,8 @@ export function splitPsByVarients(w: T.PsString): T.ArrayOneOrMore { function cut(s: string) { return s.split(/[,|،]/).map((s) => s.trim()); } - const ps = mapPsString(w, cut); - return ps.p.map((p, i) => { - if (!ps.f[i]) - throw new Error( - "uneven comma seperated ps varients: " + JSON.stringify(w) - ); - return makePsString(p, ps.f[i]); - }) as T.ArrayOneOrMore; + const { p, f } = mapPsString(w, cut); + return zipWith(makePsString, p, f) as T.ArrayOneOrMore; } export function removeEndTick(w: T.PsString): T.PsString; diff --git a/src/lib/src/parsing/parse-phrase.ts b/src/lib/src/parsing/parse-phrase.ts index 42b9cf3..2b7223c 100644 --- a/src/lib/src/parsing/parse-phrase.ts +++ b/src/lib/src/parsing/parse-phrase.ts @@ -1,7 +1,6 @@ import * as T from "../../../types"; import { verbLookup } from "./lookup"; import { parseNP } from "./parse-np"; -import { parseVerb } from "./parse-verb"; import { parseVP } from "./parse-vp"; export function parsePhrase( diff --git a/src/lib/src/parsing/parse-verb.test.ts b/src/lib/src/parsing/parse-verb.test.ts index 3ffaf79..1f90b6c 100644 --- a/src/lib/src/parsing/parse-verb.test.ts +++ b/src/lib/src/parsing/parse-verb.test.ts @@ -488,19 +488,19 @@ const tests: { ], }, // TODO: should do کاته as well... what to do, have multiple tpp forms ? YES! - { - input: "وکوت", - output: [ - { - ph: "و", - root: { - persons: [T.Person.ThirdSingMale], - aspects: ["perfective"], - }, - verb: katul, - }, - ], - }, + // { + // input: "وکوت", + // output: [ + // { + // ph: "و", + // root: { + // persons: [T.Person.ThirdSingMale], + // aspects: ["perfective"], + // }, + // verb: katul, + // }, + // ], + // }, ], }, {