This commit is contained in:
lingdocs 2022-05-02 15:53:37 -05:00
parent ee8e0598f4
commit adc375f2ce
3 changed files with 9 additions and 47 deletions

View File

@ -1,43 +0,0 @@
import {
Types as T,
getEnglishWord,
inflectWord,
isUnisexSet,
personGender,
personIsPlural,
typePredicates as tp,
psStringFromEntry,
} from "@lingdocs/pashto-inflector";
export function evaluateCompliment(c: Compliment, person: T.Person): { ps: T.PsString[], e: string } {
const e = getEnglishWord(c.entry);
if (!e || typeof e !== "string") {
console.log(e);
throw new Error("error getting english for compliment");
}
if (tp.isLocativeAdverbEntry(c.entry)) {
return {
ps: [psStringFromEntry(c.entry)],
e,
};
}
if (tp.isAdjectiveEntry(c.entry)) {
const infs = inflectWord(c.entry);
if (!infs) return {
ps: [psStringFromEntry(c.entry)],
e,
}
if (!infs.inflections || !isUnisexSet(infs.inflections)) {
throw new Error("error getting inflections for adjective, looks like a noun's inflections");
}
return {
ps: chooseInflection(infs.inflections, person),
e,
};
}
throw new Error("noun complements not yet implemented");
}
function chooseInflection(inflections: T.UnisexSet<T.InflectionSet>, pers: T.Person): T.ArrayOneOrMore<T.PsString> {
return inflections[personGender(pers)][personIsPlural(pers) ? 1 : 0];
}

5
src/types/gramm-types.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
type Pronoun = {
type: "pronoun",
pronounType: "near" | "far",
person: import("@lingdocs/pashto-inflector").Types.Person,
};

View File

@ -1684,10 +1684,10 @@
pbf "^3.2.1"
rambda "^6.7.0"
"@lingdocs/pashto-inflector@^2.3.4":
version "2.3.4"
resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-2.3.4.tgz#041c829a3a23c4ce5cadb4dfac0d50da6b583bc6"
integrity sha512-QaXKkzlucTd7PxiHr/MS9pl9wX6Zf+1doxD2k5vnER/FHgZWkKilr/4bIqQTTKW0zcxGupqd4ejyN6ynAZcsjQ==
"@lingdocs/pashto-inflector@^2.3.5":
version "2.3.5"
resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-2.3.5.tgz#2fc387f470f403eb12a82848b4d380c66aa4677c"
integrity sha512-e8JB4WRBGoI0qvrd2wfdhDusk0fFNUyfkl05WoRSZp7JCijvouFbutev3SNP8guQFx3KmvrLdDUx7xhnQfYvng==
dependencies:
classnames "^2.2.6"
pbf "^3.2.1"