ability to have tppp varients

This commit is contained in:
adueck 2023-08-14 15:01:00 +04:00
parent 8da9f9ce53
commit 0a10b1e9dc
4 changed files with 24 additions and 27 deletions

View File

@ -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

View File

@ -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 | " " | "">): T.PsString[] {
@ -1086,14 +1087,8 @@ export function splitPsByVarients(w: T.PsString): T.ArrayOneOrMore<T.PsString> {
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<T.PsString>;
const { p, f } = mapPsString(w, cut);
return zipWith(makePsString, p, f) as T.ArrayOneOrMore<T.PsString>;
}
export function removeEndTick(w: T.PsString): T.PsString;

View File

@ -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(

View File

@ -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,
// },
// ],
// },
],
},
{