diff --git a/src/lib/src/fp-ps.ts b/src/lib/src/fp-ps.ts
index f09b9ce..b9a3833 100644
--- a/src/lib/src/fp-ps.ts
+++ b/src/lib/src/fp-ps.ts
@@ -53,11 +53,11 @@ export function fmapParseResult(
}));
}
-export function fmapSingleOrLengthOpts(
+export function fmapSingleOrLengthOpts(
f: (x: A) => B,
x: T.SingleOrLengthOpts
): T.SingleOrLengthOpts {
- if ("long" in x) {
+ if (x && typeof x === "object" && "long" in x) {
return {
long: f(x.long),
short: f(x.short),
@@ -72,6 +72,42 @@ export function fmapSingleOrLengthOpts(
}
}
+export function pureSingleOrLengthOpts(a: A): T.SingleOrLengthOpts {
+ return a;
+}
+
+/**
+ * like and applicative <*> operator for SingleOrLengthOpts
+ *
+ * applies the appropriate length function for each type of given length, otherwise applies
+ * the long version as the default
+ *
+ * allows us to put transformation functions in the SingleOrLengthOpts data structure
+ * instead of
+ */
+export function applySingleOrLengthOpts(
+ f: T.SingleOrLengthOpts<(a: A) => B>,
+ a: T.SingleOrLengthOpts
+): T.SingleOrLengthOpts {
+ if (f && "long" in f) {
+ if (a && typeof a === "object" && "long" in a) {
+ return {
+ long: fmapSingleOrLengthOpts(f.long, a.long) as B,
+ short: fmapSingleOrLengthOpts(f.short, a.short) as B,
+ ...(a.mini
+ ? {
+ mini: fmapSingleOrLengthOpts(f.mini || f.short, a.mini) as B,
+ }
+ : {}),
+ };
+ } else {
+ return fmapSingleOrLengthOpts(f.long, a);
+ }
+ } else {
+ return fmapSingleOrLengthOpts(f, a);
+ }
+}
+
export function mapInflections(
f: (x: T.PsString) => T.PsString,
inf: T.UnisexInflections
diff --git a/src/lib/src/new-verb-engine/render-verb.ts b/src/lib/src/new-verb-engine/render-verb.ts
index b638348..d855e85 100644
--- a/src/lib/src/new-verb-engine/render-verb.ts
+++ b/src/lib/src/new-verb-engine/render-verb.ts
@@ -5,7 +5,7 @@ import {
personNumber,
personToGenNum,
} from "../misc-helpers";
-import { fmapSingleOrLengthOpts } from "../fp-ps";
+import { applySingleOrLengthOpts, fmapSingleOrLengthOpts } from "../fp-ps";
import {
concatPsString,
getLength,
@@ -269,41 +269,31 @@ function addEnding({
vb: T.VBBasic,
end: T.SingleOrLengthOpts
): T.VBBasic {
+ // exceptional ending for راتلل, ورتلل, درتلل
if ("long" in vb.ps) {
+ // TODO: do we need a more thorough check?
if (vb.ps.short[0].f === "ghl" && pastThird && basicForm) {
return {
...vb,
ps: [{ p: "غی", f: "ghay" }],
};
}
- const endLong = getLength(end, "long");
- const endShort = getLength(end, "short");
- // TODO: this is hacky
- return {
- ...vb,
- ps: {
- long: verbEndingConcat(vb.ps.long, endLong),
- short:
- pastThird && basicForm
- ? ensure3rdPast(vb.ps.short, endShort, verb, aspect)
- : verbEndingConcat(vb.ps.short, endShort),
- ...(vb.ps.mini
- ? {
- mini: verbEndingConcat(vb.ps.mini, endShort),
- }
- : {}),
- },
- };
- }
- /* istanbul ignore next */
- if ("long" in end) {
- throw new Error(
- "should not be using verb stems with long and short endings"
- );
}
+
+ const endShort = getLength(end, "short");
return {
...vb,
- ps: verbEndingConcat(vb.ps, end),
+ ps: applySingleOrLengthOpts(
+ {
+ long: (ps) => verbEndingConcat(ps, getLength(end, "long")),
+ short: (ps) =>
+ pastThird && basicForm
+ ? ensure3rdPast(ps, endShort, verb, aspect)
+ : verbEndingConcat(ps, endShort),
+ mini: (ps) => verbEndingConcat(ps, endShort),
+ },
+ vb.ps
+ ),
};
}
}
diff --git a/src/lib/src/parsing/irreg-verbs.ts b/src/lib/src/parsing/irreg-verbs.ts
index 6bd8bfd..1129147 100644
--- a/src/lib/src/parsing/irreg-verbs.ts
+++ b/src/lib/src/parsing/irreg-verbs.ts
@@ -7,7 +7,7 @@ export const tlul = wordQuery("tlul", "verb");
export const wartlul = wordQuery("ورتلل", "verb");
-export const dartlul = wordQuery("درتلل", "verb") as T.VerbEntry;
+export const dartlul = wordQuery("درتلل", "verb");
export const kedulStat = {
entry: {
diff --git a/src/lib/src/parsing/parse-vp.ts b/src/lib/src/parsing/parse-vp.ts
index 7d4ef56..e772e7f 100644
--- a/src/lib/src/parsing/parse-vp.ts
+++ b/src/lib/src/parsing/parse-vp.ts
@@ -21,7 +21,7 @@ import { isFirstOrSecondPersPronoun } from "../phrase-building/render-vp";
// وامې نه اخیست
// waa-me nú akheest
-// TODO: WHY IS NETLIFY TESTING FAILING - getting a different version of tlul
+// TODO: word query for kawul/kedul/stat/dyn
// map over transitivities, to give transitive / gramm. transitive optionns