shoot unisex nouns are a bit buggy/crashy, need to fix those up before releasing further
This commit is contained in:
parent
723cf331f9
commit
e2cae7638b
|
@ -4,6 +4,7 @@ import {
|
||||||
defaultTextOptions as opts,
|
defaultTextOptions as opts,
|
||||||
VerbTable,
|
VerbTable,
|
||||||
removeFVarients,
|
removeFVarients,
|
||||||
|
getEnglishWord,
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
import {
|
import {
|
||||||
equativeMachine,
|
equativeMachine,
|
||||||
|
@ -17,11 +18,18 @@ import {
|
||||||
} from "../lib/equative-machine";
|
} from "../lib/equative-machine";
|
||||||
import words from "../words/nouns-adjs";
|
import words from "../words/nouns-adjs";
|
||||||
|
|
||||||
|
function uniqueSort(arr: AdjectiveInput[]): AdjectiveInput[];
|
||||||
|
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)
|
||||||
|
.sort((a, b) => a.p.localeCompare(b.p));
|
||||||
|
}
|
||||||
const inputs = {
|
const inputs = {
|
||||||
adjectives: words.filter((w) => isAdjectiveInput(w.entry as EntityInput))
|
adjectives: uniqueSort(words.filter((w) => isAdjectiveInput(w.entry as EntityInput))
|
||||||
.map((w) => w.entry as AdjectiveInput).sort((a, b) => a.p.localeCompare(b.p)),
|
.map((w) => w.entry as AdjectiveInput)),
|
||||||
unisexNouns: words.filter((w) => isUnisexNounInput(w.entry as EntityInput))
|
unisexNouns: uniqueSort(words.filter((w) => isUnisexNounInput(w.entry as EntityInput))
|
||||||
.map((w) => w.entry as UnisexNounInput).sort((a, b) => a.p.localeCompare(b.p)),
|
.map((w) => w.entry as UnisexNounInput)),
|
||||||
};
|
};
|
||||||
|
|
||||||
function makeBlock(e: PredicateInput): T.VerbBlock {
|
function makeBlock(e: PredicateInput): T.VerbBlock {
|
||||||
|
@ -40,12 +48,26 @@ function makeBlock(e: PredicateInput): T.VerbBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PredicateType = "adjectives" | "unisexNouns";
|
type PredicateType = "adjectives" | "unisexNouns";
|
||||||
|
// type SubjectType = "pronouns" | "nouns";
|
||||||
|
|
||||||
|
// TODO: Plural nouns like shoode
|
||||||
|
const defaultTs = 1527815306;
|
||||||
|
const defaultPe = inputs.adjectives.find(a => a.ts === defaultTs) as AdjectiveInput;
|
||||||
|
|
||||||
function EquativeExplorer() {
|
function EquativeExplorer() {
|
||||||
// TODO: Use sticky state
|
// TODO: Use sticky state
|
||||||
const predicateTypes: PredicateType[] = ["adjectives", "unisexNouns"];
|
const predicateTypes: PredicateType[] = ["adjectives", "unisexNouns"];
|
||||||
const [predicate, setPredicate] = useState<number>(1527815306);
|
// const subjectTypes: SubjectType[] = ["pronouns", "nouns"];
|
||||||
|
const [predicate, setPredicate] = useState<number>(defaultTs);
|
||||||
|
// const [subjectType, setSubjectType] = useState<SubjectType>("pronouns");
|
||||||
const [predicateType, setPredicateType] = useState<PredicateType>("adjectives");
|
const [predicateType, setPredicateType] = useState<PredicateType>("adjectives");
|
||||||
|
|
||||||
|
function makeOptionLabel(e: T.DictionaryEntry): string {
|
||||||
|
const eng = getEnglishWord(e);
|
||||||
|
// @ts-ignore - with dumb old typescript
|
||||||
|
const english = typeof eng === "string" ? eng : eng.plural;
|
||||||
|
return `${e.p} - ${removeFVarients(e.f)} (${english})`;
|
||||||
|
}
|
||||||
function handlePredicateSelect(e: React.ChangeEvent<HTMLSelectElement>) {
|
function handlePredicateSelect(e: React.ChangeEvent<HTMLSelectElement>) {
|
||||||
setPredicate(parseInt(e.target.value));
|
setPredicate(parseInt(e.target.value));
|
||||||
}
|
}
|
||||||
|
@ -58,10 +80,37 @@ function EquativeExplorer() {
|
||||||
const pe = (inputs[predicateType].find((a: AdjectiveInput | UnisexNounInput) => (
|
const pe = (inputs[predicateType].find((a: AdjectiveInput | UnisexNounInput) => (
|
||||||
a.ts === predicate
|
a.ts === predicate
|
||||||
))) as PredicateInput;
|
))) as PredicateInput;
|
||||||
console.log("pe is", pe);
|
const block = (() => {
|
||||||
const block = makeBlock(pe);
|
try {
|
||||||
|
return makeBlock(pe);
|
||||||
|
} catch (e) {
|
||||||
|
console.error("error making equative");
|
||||||
|
console.error(e);
|
||||||
|
setPredicate(defaultTs);
|
||||||
|
setPredicateType("adjectives");
|
||||||
|
return makeBlock(defaultPe);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
|
<div className="d-flex flex-row">
|
||||||
|
{/* <div className="form-group">
|
||||||
|
<label htmlFor="subject-select"><strong>Subject:</strong></label>
|
||||||
|
<div className="form-check">
|
||||||
|
<input
|
||||||
|
className="form-check-input"
|
||||||
|
type="radio"
|
||||||
|
name="pronounsSubjectRadio"
|
||||||
|
id="pronounsSubjectRadio"
|
||||||
|
value={subjectTypes[0]}
|
||||||
|
checked={subjectType === "pronouns"}
|
||||||
|
onChange={handlePredicateTypeSelect}
|
||||||
|
/>
|
||||||
|
<label className="form-check-label" htmlFor="adjectivesPredicateRadio">
|
||||||
|
Pronouns
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div> */}
|
||||||
<div className="form-group">
|
<div className="form-group">
|
||||||
<label htmlFor="predicate-select"><strong>Predicate:</strong></label>
|
<label htmlFor="predicate-select"><strong>Predicate:</strong></label>
|
||||||
<div className="form-check">
|
<div className="form-check">
|
||||||
|
@ -78,7 +127,8 @@ function EquativeExplorer() {
|
||||||
Adjectives
|
Adjectives
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div className="form-check mb-2">
|
{/* hiding this because it's a bit buggy still */}
|
||||||
|
<div className="form-check mb-2" style={{ display: "none" }}>
|
||||||
<input
|
<input
|
||||||
className="form-check-input"
|
className="form-check-input"
|
||||||
type="radio"
|
type="radio"
|
||||||
|
@ -99,10 +149,11 @@ function EquativeExplorer() {
|
||||||
onChange={handlePredicateSelect}
|
onChange={handlePredicateSelect}
|
||||||
>
|
>
|
||||||
{inputs[predicateType].map((e: AdjectiveInput | UnisexNounInput) => (
|
{inputs[predicateType].map((e: AdjectiveInput | UnisexNounInput) => (
|
||||||
<option key={e.ts+"s"} value={e.ts}>{e.p} - {removeFVarients(e.f)}</option>
|
<option key={e.ts+"s"} value={e.ts}>{makeOptionLabel(e)}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<VerbTable textOptions={opts} block={block} />
|
<VerbTable textOptions={opts} block={block} />
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,6 @@ title: Equative Explorer 🌎
|
||||||
|
|
||||||
import EquativeExplorer from "../../components/EquativeExplorer";
|
import EquativeExplorer from "../../components/EquativeExplorer";
|
||||||
|
|
||||||
This is in progress... will be able to explore much more soon. 👷♂️
|
This is in progress and a bit buggy... will be able to explore much more soon. 👷♂️
|
||||||
|
|
||||||
<EquativeExplorer />
|
<EquativeExplorer />
|
||||||
|
|
|
@ -122,7 +122,6 @@ module.exports = [
|
||||||
{ ts: 1527814373, e: "lost" }, // ورک - wruk
|
{ ts: 1527814373, e: "lost" }, // ورک - wruk
|
||||||
{ ts: 1527822838, e: "decayed, spoiled, rotten" }, // وروست - wrost
|
{ ts: 1527822838, e: "decayed, spoiled, rotten" }, // وروست - wrost
|
||||||
{ ts: 1609949334478, e: "roasted" }, // وریت - wreet
|
{ ts: 1609949334478, e: "roasted" }, // وریت - wreet
|
||||||
{ ts: 1527823106, e: "cheerful" }, // ورین - wreen
|
|
||||||
{ ts: 1527811544, e: "standing" }, // ولاړ - waláaR, wuláaR
|
{ ts: 1527811544, e: "standing" }, // ولاړ - waláaR, wuláaR
|
||||||
{ ts: 1527815498, e: "aforementioned" }, // یاد - yaad
|
{ ts: 1527815498, e: "aforementioned" }, // یاد - yaad
|
||||||
{ ts: 1527815434, e: "cold" }, // یخ - yakh, yukh
|
{ ts: 1527815434, e: "cold" }, // یخ - yakh, yukh
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue