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, "private": true,
"dependencies": { "dependencies": {
"@fortawesome/fontawesome-free": "^5.15.2", "@fortawesome/fontawesome-free": "^5.15.2",
"@lingdocs/lingdocs-main": "^0.1.4", "@lingdocs/lingdocs-main": "^0.1.7",
"@lingdocs/pashto-inflector": "^1.1.4", "@lingdocs/pashto-inflector": "^1.1.4",
"@testing-library/jest-dom": "^4.2.4", "@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2", "@testing-library/react": "^9.3.2",

View File

@ -22,7 +22,19 @@ function uniqueSort(arr: AdjectiveInput[]): AdjectiveInput[];
function uniqueSort(arr: UnisexNounInput[]): UnisexNounInput[]; function uniqueSort(arr: UnisexNounInput[]): UnisexNounInput[];
function uniqueSort(arr: (AdjectiveInput | UnisexNounInput)[]): (AdjectiveInput | UnisexNounInput)[] { function uniqueSort(arr: (AdjectiveInput | UnisexNounInput)[]): (AdjectiveInput | UnisexNounInput)[] {
return arr return arr
.filter((v, i, a) => a.findIndex((e) => e.ts === v.ts) === i) .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)); .sort((a, b) => a.p.localeCompare(b.p));
} }
const inputs = { const inputs = {
@ -65,7 +77,7 @@ function EquativeExplorer() {
function makeOptionLabel(e: T.DictionaryEntry): string { function makeOptionLabel(e: T.DictionaryEntry): string {
const eng = getEnglishWord(e); const eng = getEnglishWord(e);
// @ts-ignore - with dumb old typescript // @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})`; return `${e.p} - ${removeFVarients(e.f)} (${english})`;
} }
function handlePredicateSelect(e: React.ChangeEvent<HTMLSelectElement>) { function handlePredicateSelect(e: React.ChangeEvent<HTMLSelectElement>) {
@ -128,7 +140,7 @@ function EquativeExplorer() {
</label> </label>
</div> </div>
{/* hiding this because it's a bit buggy still */} {/* 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 <input
className="form-check-input" className="form-check-input"
type="radio" type="radio"
@ -154,6 +166,9 @@ function EquativeExplorer() {
</select> </select>
</div> </div>
</div> </div>
{/*
// @ts-ignore */}
{pe.ts}
<VerbTable textOptions={opts} block={block} /> <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 // reuse english from make noun - do the a / an sensitivity
// if it's the predicate - get the inflection according to the subjPerson // if it's the predicate - get the inflection according to the subjPerson
const isPredicate = subjPerson !== undefined; const isPredicate = subjPerson !== undefined;
console.log("making", e, "isPredicate", isPredicate);
if (isPredicate) { if (isPredicate) {
const inf = inflectWord(e); const inf = inflectWord(e);
// TODO: Use if no inflections // FIX THIS const english = getEnglishFromNoun(e, personIsPlural(subjPerson || 0), "predicate");
// BETTER CHECKING / GUARDING HERE if (!inf) {
// @ts-ignore - TODO: REMOVE THIS return [psStringFromEntry(e, english)];
if (!inf || (!inf.inflections && !("plural" in inf)) || !isUnisexSet(inf.inflections)) { }
if (!inf.inflections && (!("plural" in inf) || (!inf.inflections || !isUnisexSet(inf.inflections)))) {
throw Error("improper unisex noun"); throw Error("improper unisex noun");
} }
// if plural // anim // chose that // if plural // anim // chose that
// otherwise just chose inflection (or add both) // needed for older version of typescript // otherwise just chose inflection (or add both)
const pashto = ("plural" in inf && inf.plural !== undefined && personIsPlural(subjPerson || 0)) const pashto = ((): T.ArrayOneOrMore<T.PsString> => { // needed for older version of typescript
// @ts-ignore if ("plural" in inf && inf.plural !== undefined && personIsPlural(subjPerson || 0)) {
? inf.plural[personGender(subjPerson)][0] as T.ArrayOneOrMore<T.PsString> const gender = personGender(subjPerson || 0);
// needed for older version of typescript if (gender === "masc" && "masc" in inf.plural) {
: chooseInflection(inf.inflections, subjPerson || 0); return inf.plural.masc[0];
const english = getEnglishFromNoun(e, personIsPlural(subjPerson || 0), "predicate"); }
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); return addEnglish(english, pashto);
} }
// if it's the subject - TO BE IMPLEMENTED // 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 (isNounInput(e)) return false;
if (isUnisexNounInput(e)) return false; if (isUnisexNounInput(e)) return false;
if (isSpecifiedUnisexNounInput(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" "@types/yargs" "^16.0.0"
chalk "^4.0.0" chalk "^4.0.0"
"@lingdocs/lingdocs-main@^0.1.4": "@lingdocs/lingdocs-main@^0.1.7":
version "0.1.6" version "0.1.7"
resolved "https://npm.lingdocs.com/@lingdocs%2flingdocs-main/-/lingdocs-main-0.1.6.tgz#b79c95d68e200eb7f323e8144fd3a3cea0ceb805" resolved "https://npm.lingdocs.com/@lingdocs%2flingdocs-main/-/lingdocs-main-0.1.7.tgz#9b94c8b2b43c73f989b9a551c7544554bc0a74a5"
integrity sha512-xVwBg01eJng9d+LMvaNtAjUGJhUt3yRmKAsCGlvJPQp8Ud4zpmJ5gotOTLUOEWTsjXzW0H/PjQXG767reuX3aA== integrity sha512-+7Snx3jDj8Jekh69UO+n8+5B+yMuMg6HcEcZReW9e0Sam07i57u/g8+tlpu2ET5lblPF0KGs783EXX+UWFhzWw==
dependencies: dependencies:
nano "^9.0.5" nano "^9.0.5"
passport-github2 "^0.1.12" passport-github2 "^0.1.12"