This commit is contained in:
lingdocs 2021-10-10 01:55:23 -04:00
parent cc12c50dfc
commit 3f417b933b
5 changed files with 48 additions and 22 deletions

View File

@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.2",
"@lingdocs/lingdocs-main": "^0.1.4",
"@lingdocs/lingdocs-main": "^0.1.7",
"@lingdocs/pashto-inflector": "^1.1.4",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",

View File

@ -23,6 +23,18 @@ function uniqueSort(arr: UnisexNounInput[]): UnisexNounInput[];
function uniqueSort(arr: (AdjectiveInput | UnisexNounInput)[]): (AdjectiveInput | UnisexNounInput)[] {
return arr
.filter((v, i, a) => a.findIndex((e) => e.ts === v.ts) === i)
.filter((e) => {
try {
for (let p = 0; p < 12; p++) {
equativeMachine(p, e);
}
} catch (err) {
console.error("equative generation failed", e);
console.error(err);
return false;
}
return true;
})
.sort((a, b) => a.p.localeCompare(b.p));
}
const inputs = {
@ -65,7 +77,7 @@ function EquativeExplorer() {
function makeOptionLabel(e: T.DictionaryEntry): string {
const eng = getEnglishWord(e);
// @ts-ignore - with dumb old typescript
const english = typeof eng === "string" ? eng : eng.plural;
const english = typeof eng === "string" ? eng : eng?.singular;
return `${e.p} - ${removeFVarients(e.f)} (${english})`;
}
function handlePredicateSelect(e: React.ChangeEvent<HTMLSelectElement>) {
@ -128,7 +140,7 @@ function EquativeExplorer() {
</label>
</div>
{/* hiding this because it's a bit buggy still */}
<div className="form-check mb-2" style={{ display: "none" }}>
<div className="form-check mb-2">
<input
className="form-check-input"
type="radio"
@ -154,6 +166,9 @@ function EquativeExplorer() {
</select>
</div>
</div>
{/*
// @ts-ignore */}
{pe.ts}
<VerbTable textOptions={opts} block={block} />
</>;
}

View File

@ -132,23 +132,34 @@ function makeUnisexNoun(e: UnisexNounInput, subjPerson: T.Person | undefined): T
// reuse english from make noun - do the a / an sensitivity
// if it's the predicate - get the inflection according to the subjPerson
const isPredicate = subjPerson !== undefined;
console.log("making", e, "isPredicate", isPredicate);
if (isPredicate) {
const inf = inflectWord(e);
// TODO: Use if no inflections // FIX THIS
// BETTER CHECKING / GUARDING HERE
// @ts-ignore - TODO: REMOVE THIS
if (!inf || (!inf.inflections && !("plural" in inf)) || !isUnisexSet(inf.inflections)) {
const english = getEnglishFromNoun(e, personIsPlural(subjPerson || 0), "predicate");
if (!inf) {
return [psStringFromEntry(e, english)];
}
if (!inf.inflections && (!("plural" in inf) || (!inf.inflections || !isUnisexSet(inf.inflections)))) {
throw Error("improper unisex noun");
}
// if plural // anim // chose that
// otherwise just chose inflection (or add both) // needed for older version of typescript
const pashto = ("plural" in inf && inf.plural !== undefined && personIsPlural(subjPerson || 0))
// @ts-ignore
? inf.plural[personGender(subjPerson)][0] as T.ArrayOneOrMore<T.PsString>
// needed for older version of typescript
: chooseInflection(inf.inflections, subjPerson || 0);
const english = getEnglishFromNoun(e, personIsPlural(subjPerson || 0), "predicate");
// otherwise just chose inflection (or add both)
const pashto = ((): T.ArrayOneOrMore<T.PsString> => { // needed for older version of typescript
if ("plural" in inf && inf.plural !== undefined && personIsPlural(subjPerson || 0)) {
const gender = personGender(subjPerson || 0);
if (gender === "masc" && "masc" in inf.plural) {
return inf.plural.masc[0];
}
if (gender === "fem" && "fem" in inf.plural) {
return inf.plural.fem[0];
}
throw new Error("gender not available for plural");
}
if (isUnisexSet(inf.inflections)) {
return chooseInflection(inf.inflections, subjPerson || 0);
} else {
return [psStringFromEntry(e, english)];
}
})();
return addEnglish(english, pashto);
}
// if it's the subject - TO BE IMPLEMENTED
@ -305,6 +316,6 @@ export function isAdjectiveInput(e: EntityInput): e is AdjectiveInput {
if (isNounInput(e)) return false;
if (isUnisexNounInput(e)) return false;
if (isSpecifiedUnisexNounInput(e)) return false;
return !!e.c?.includes("adj.");
return !!(e.c?.includes("adj.") && !(e.c.includes("n. m.") || e.c.includes("n. f.")));
}

File diff suppressed because one or more lines are too long

View File

@ -1573,10 +1573,10 @@
"@types/yargs" "^16.0.0"
chalk "^4.0.0"
"@lingdocs/lingdocs-main@^0.1.4":
version "0.1.6"
resolved "https://npm.lingdocs.com/@lingdocs%2flingdocs-main/-/lingdocs-main-0.1.6.tgz#b79c95d68e200eb7f323e8144fd3a3cea0ceb805"
integrity sha512-xVwBg01eJng9d+LMvaNtAjUGJhUt3yRmKAsCGlvJPQp8Ud4zpmJ5gotOTLUOEWTsjXzW0H/PjQXG767reuX3aA==
"@lingdocs/lingdocs-main@^0.1.7":
version "0.1.7"
resolved "https://npm.lingdocs.com/@lingdocs%2flingdocs-main/-/lingdocs-main-0.1.7.tgz#9b94c8b2b43c73f989b9a551c7544554bc0a74a5"
integrity sha512-+7Snx3jDj8Jekh69UO+n8+5B+yMuMg6HcEcZReW9e0Sam07i57u/g8+tlpu2ET5lblPF0KGs783EXX+UWFhzWw==
dependencies:
nano "^9.0.5"
passport-github2 "^0.1.12"