big refactor with word typings
This commit is contained in:
parent
672d9dac40
commit
f5e2ed40a7
|
@ -5,7 +5,7 @@
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fortawesome/fontawesome-free": "^5.15.4",
|
"@fortawesome/fontawesome-free": "^5.15.4",
|
||||||
"@lingdocs/lingdocs-main": "^0.2.0",
|
"@lingdocs/lingdocs-main": "^0.2.0",
|
||||||
"@lingdocs/pashto-inflector": "^1.2.7",
|
"@lingdocs/pashto-inflector": "^1.2.8",
|
||||||
"@testing-library/jest-dom": "^5.11.4",
|
"@testing-library/jest-dom": "^5.11.4",
|
||||||
"@testing-library/react": "^11.1.0",
|
"@testing-library/react": "^11.1.0",
|
||||||
"@testing-library/user-event": "^12.1.10",
|
"@testing-library/user-event": "^12.1.10",
|
||||||
|
|
|
@ -14,7 +14,7 @@ import {
|
||||||
assembleEquativeOutput,
|
assembleEquativeOutput,
|
||||||
PredicateInput,
|
PredicateInput,
|
||||||
} from "../lib/equative-machine";
|
} from "../lib/equative-machine";
|
||||||
import { words } from "../words/words";
|
import words from "../words/words";
|
||||||
|
|
||||||
function uniqueSort(arr: Adjective[]): Adjective[];
|
function uniqueSort(arr: Adjective[]): Adjective[];
|
||||||
function uniqueSort(arr: UnisexNoun[]): UnisexNoun[];
|
function uniqueSort(arr: UnisexNoun[]): UnisexNoun[];
|
||||||
|
@ -58,7 +58,7 @@ function makeBlock(e: PredicateInput): T.VerbBlock {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PredicateType = "adjectives" | "unisexNouns";
|
type PredicateType = "adjectives" | "unisexNouns";
|
||||||
type SubjectType = "pronouns" | "nouns";
|
// type SubjectType = "pronouns" | "nouns";
|
||||||
|
|
||||||
// TODO: Plural nouns like shoode
|
// TODO: Plural nouns like shoode
|
||||||
const defaultTs = 1527815306;
|
const defaultTs = 1527815306;
|
||||||
|
@ -67,9 +67,9 @@ const defaultPe = inputs.adjectives.find(a => a.ts === defaultTs) || inputs.adje
|
||||||
function EquativeExplorer() {
|
function EquativeExplorer() {
|
||||||
// TODO: Use sticky state
|
// TODO: Use sticky state
|
||||||
const predicateTypes: PredicateType[] = ["adjectives", "unisexNouns"];
|
const predicateTypes: PredicateType[] = ["adjectives", "unisexNouns"];
|
||||||
const subjectTypes: SubjectType[] = ["pronouns", "nouns"];
|
// const subjectTypes: SubjectType[] = ["pronouns", "nouns"];
|
||||||
const [predicate, setPredicate] = useState<number>(defaultTs);
|
const [predicate, setPredicate] = useState<number>(defaultTs);
|
||||||
const [subjectType, setSubjectType] = useState<SubjectType>("pronouns");
|
// const [subjectType, setSubjectType] = useState<SubjectType>("pronouns");
|
||||||
const [predicateType, setPredicateType] = useState<PredicateType>("adjectives");
|
const [predicateType, setPredicateType] = useState<PredicateType>("adjectives");
|
||||||
|
|
||||||
function makeOptionLabel(e: T.DictionaryEntry): string {
|
function makeOptionLabel(e: T.DictionaryEntry): string {
|
||||||
|
@ -86,11 +86,11 @@ function EquativeExplorer() {
|
||||||
setPredicateType(pt);
|
setPredicateType(pt);
|
||||||
setPredicate(inputs[pt][0].ts);
|
setPredicate(inputs[pt][0].ts);
|
||||||
}
|
}
|
||||||
function handleSubjectTypeSelect(e: React.ChangeEvent<HTMLInputElement>) {
|
// function handleSubjectTypeSelect(e: React.ChangeEvent<HTMLInputElement>) {
|
||||||
const st = e.target.value as SubjectType;
|
// const st = e.target.value as SubjectType;
|
||||||
setSubjectType(st);
|
// setSubjectType(st);
|
||||||
// setPredicate(inputs[pt][0].ts);
|
// // setPredicate(inputs[pt][0].ts);
|
||||||
}
|
// }
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const pe = (inputs[predicateType].find((a: AdjectiveInput | UnisexNounInput) => (
|
const pe = (inputs[predicateType].find((a: AdjectiveInput | UnisexNounInput) => (
|
||||||
a.ts === predicate
|
a.ts === predicate
|
||||||
|
@ -109,7 +109,7 @@ function EquativeExplorer() {
|
||||||
|
|
||||||
return <>
|
return <>
|
||||||
<div className="d-flex flex-row">
|
<div className="d-flex flex-row">
|
||||||
<div className="form-group">
|
{/* <div className="form-group">
|
||||||
<label htmlFor="subject-select"><strong>Subject:</strong></label>
|
<label htmlFor="subject-select"><strong>Subject:</strong></label>
|
||||||
<div className="form-check">
|
<div className="form-check">
|
||||||
<input
|
<input
|
||||||
|
@ -139,7 +139,7 @@ function EquativeExplorer() {
|
||||||
Nouns
|
Nouns
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</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">
|
||||||
|
|
|
@ -25,7 +25,7 @@ import {
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
import shuffle from "../../lib/shuffle-array";
|
import shuffle from "../../lib/shuffle-array";
|
||||||
import InflectionCarousel from "../../components/InflectionCarousel";
|
import InflectionCarousel from "../../components/InflectionCarousel";
|
||||||
import { words } from "../../words/words";
|
import { nouns } from "../../words/words";
|
||||||
import Link from "../../components/Link";
|
import Link from "../../components/Link";
|
||||||
import Table from "../../components/Table";
|
import Table from "../../components/Table";
|
||||||
import { startingWord } from "../../lib/starting-word";
|
import { startingWord } from "../../lib/starting-word";
|
||||||
|
@ -35,7 +35,7 @@ import {
|
||||||
isPattern7FemNoun,
|
isPattern7FemNoun,
|
||||||
} from "../../lib/type-predicates";
|
} from "../../lib/type-predicates";
|
||||||
|
|
||||||
export const femNouns = words.nouns.filter(w => isFemNoun(w));
|
export const femNouns = nouns.filter(isFemNoun);
|
||||||
|
|
||||||
The <Link to="/inflection/inflection-patterns/">5 basic patterns in the last chapter</Link> work with both masculine and feminine words (nouns and adjectives).
|
The <Link to="/inflection/inflection-patterns/">5 basic patterns in the last chapter</Link> work with both masculine and feminine words (nouns and adjectives).
|
||||||
|
|
||||||
|
|
|
@ -32,13 +32,13 @@ import {
|
||||||
isUnisexNoun,
|
isUnisexNoun,
|
||||||
} from "../../lib/type-predicates";
|
} from "../../lib/type-predicates";
|
||||||
import InflectionCarousel from "../../components/InflectionCarousel";
|
import InflectionCarousel from "../../components/InflectionCarousel";
|
||||||
import { words as w } from "../../words/words";
|
import { nouns, adjectives } from "../../words/words";
|
||||||
import { startingWord } from "../../lib/starting-word";
|
import { startingWord } from "../../lib/starting-word";
|
||||||
import Link from "../../components/Link";
|
import Link from "../../components/Link";
|
||||||
|
|
||||||
export const words = [
|
export const words = [
|
||||||
...w.nouns.filter(isUnisexNoun),
|
...nouns.filter(isUnisexNoun),
|
||||||
...w.adjectives,
|
...adjectives,
|
||||||
];
|
];
|
||||||
|
|
||||||
In the <Link to="/inflection/inflection-intro/">previous chapter</Link> we talked about **why** words inflect. Now we will explain **how** words inflect. What actualy happens to them? How do they change?
|
In the <Link to="/inflection/inflection-intro/">previous chapter</Link> we talked about **why** words inflect. Now we will explain **how** words inflect. What actualy happens to them? How do they change?
|
||||||
|
|
|
@ -14,12 +14,12 @@ import psmd from "../../lib/psmd";
|
||||||
import Carousel from "../../components/Carousel";
|
import Carousel from "../../components/Carousel";
|
||||||
import Link from "../../components/Link";
|
import Link from "../../components/Link";
|
||||||
import Formula from "../../components/formula/Formula";
|
import Formula from "../../components/formula/Formula";
|
||||||
import { words } from "../../words/words";
|
import { verbs } from "../../words/words";
|
||||||
import shuffleArray from "../../lib/shuffle-array";
|
import shuffleArray from "../../lib/shuffle-array";
|
||||||
import imperfectiveFuture from "./imperfective-future-graph.svg";
|
import imperfectiveFuture from "./imperfective-future-graph.svg";
|
||||||
import perfectiveFuture from "./perfective-future-graph.svg";
|
import perfectiveFuture from "./perfective-future-graph.svg";
|
||||||
|
|
||||||
export const basicVerbs = words.verbs.filter((v) => !v.entry.c?.includes("gramm. trans."));
|
export const basicVerbs = verbs.filter((v) => !v.entry.c?.includes("gramm. trans."));
|
||||||
|
|
||||||
There are two kinds of future forms in Pashto:
|
There are two kinds of future forms in Pashto:
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import psmd from "../../lib/psmd";
|
||||||
import Carousel from "../../components/Carousel";
|
import Carousel from "../../components/Carousel";
|
||||||
import Link from "../../components/Link";
|
import Link from "../../components/Link";
|
||||||
import Formula from "../../components/formula/Formula";
|
import Formula from "../../components/formula/Formula";
|
||||||
import { words } from "../../words/words";
|
import { verbs } from "../../words/words";
|
||||||
import shuffleArray from "../../lib/shuffle-array";
|
import shuffleArray from "../../lib/shuffle-array";
|
||||||
import imperfectiveImperative from "./imperfective-imperative.svg";
|
import imperfectiveImperative from "./imperfective-imperative.svg";
|
||||||
import perfectiveImperative from "./perfective-imperative.svg";
|
import perfectiveImperative from "./perfective-imperative.svg";
|
||||||
|
@ -25,7 +25,7 @@ There are two forms of the imperative:
|
||||||
1. <i className="fas fa-video" /> Imperfective Imperative
|
1. <i className="fas fa-video" /> Imperfective Imperative
|
||||||
2. <i className="fas fa-camera" /> Perfective Imperative
|
2. <i className="fas fa-camera" /> Perfective Imperative
|
||||||
|
|
||||||
export const basicVerbs = words.verbs.filter((v) => !v.entry.c?.includes("gramm. trans."));
|
export const basicVerbs = verbs.filter((v) => !v.entry.c?.includes("gramm. trans."));
|
||||||
|
|
||||||
## Imperfective Imperative
|
## Imperfective Imperative
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,11 @@ import psmd from "../../lib/psmd";
|
||||||
import Carousel from "../../components/Carousel";
|
import Carousel from "../../components/Carousel";
|
||||||
import Link from "../../components/Link";
|
import Link from "../../components/Link";
|
||||||
import Formula from "../../components/formula/Formula";
|
import Formula from "../../components/formula/Formula";
|
||||||
import { words } from "../../words/words";
|
import { verbs } from "../../words/words";
|
||||||
import shuffleArray from "../../lib/shuffle-array";
|
import shuffleArray from "../../lib/shuffle-array";
|
||||||
import realityGraph from "./reality-graph.svg";
|
import realityGraph from "./reality-graph.svg";
|
||||||
import presentTime from "./present-time.svg";
|
import presentTime from "./present-time.svg";
|
||||||
|
|
||||||
export const verbs = words.verbs;
|
|
||||||
|
|
||||||
export const basicVerbs = verbs.filter((v) => !v.entry.c?.includes("gramm. trans."));
|
export const basicVerbs = verbs.filter((v) => !v.entry.c?.includes("gramm. trans."));
|
||||||
|
|
||||||
The first verb form we'll learn is the **present**. This will be the first tool in our toolbox of verb forms. 🧰 With each verb form we'll learn two things:
|
The first verb form we'll learn is the **present**. This will be the first tool in our toolbox of verb forms. 🧰 With each verb form we'll learn two things:
|
||||||
|
|
|
@ -25,14 +25,12 @@ import {
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
import shuffle from "../../lib/shuffle-array";
|
import shuffle from "../../lib/shuffle-array";
|
||||||
import Carousel from "../../components/Carousel";
|
import Carousel from "../../components/Carousel";
|
||||||
import { words } from "../../words/words";
|
import { verbs } from "../../words/words";
|
||||||
import Link from "../../components/Link";
|
import Link from "../../components/Link";
|
||||||
import verbTreeBase from "./verb-tree-base.svg";
|
import verbTreeBase from "./verb-tree-base.svg";
|
||||||
import verbTreePastPresent from "./verb-tree-past-present.svg";
|
import verbTreePastPresent from "./verb-tree-past-present.svg";
|
||||||
import verbTreeImperfectivePerfective from "./verb-tree-imperfective-perfective.svg";
|
import verbTreeImperfectivePerfective from "./verb-tree-imperfective-perfective.svg";
|
||||||
|
|
||||||
export const verbs = words.verbs;
|
|
||||||
|
|
||||||
export const opts = defaultTextOptions;
|
export const opts = defaultTextOptions;
|
||||||
|
|
||||||
export function InfoCarousel({ items, highlighted, hidePastParticiple }) {
|
export function InfoCarousel({ items, highlighted, hidePastParticiple }) {
|
||||||
|
|
|
@ -14,12 +14,12 @@ import psmd from "../../lib/psmd";
|
||||||
import Carousel from "../../components/Carousel";
|
import Carousel from "../../components/Carousel";
|
||||||
import Link from "../../components/Link";
|
import Link from "../../components/Link";
|
||||||
import Formula from "../../components/formula/Formula";
|
import Formula from "../../components/formula/Formula";
|
||||||
import { words } from "../../words/words";
|
import { verbs } from "../../words/words";
|
||||||
import shuffleArray from "../../lib/shuffle-array";
|
import shuffleArray from "../../lib/shuffle-array";
|
||||||
import presentInReality from "./present-in-reality.svg";
|
import presentInReality from "./present-in-reality.svg";
|
||||||
import subjunctiveAboveReality from "./subjunctive-above-reality.svg";
|
import subjunctiveAboveReality from "./subjunctive-above-reality.svg";
|
||||||
|
|
||||||
export const basicVerbs = words.verbs.filter((v) => !v.entry.c?.includes("gramm. trans."));
|
export const basicVerbs = verbs.filter((v) => !v.entry.c?.includes("gramm. trans."));
|
||||||
|
|
||||||
The **subjunctive** is a very important verb form in Pashto, but it's often ignored by English-speaking learners because we don't really have anything like it in English. So, we need to understand what it is, and then train our brains to reach for it and use it in the right situations!
|
The **subjunctive** is a very important verb form in Pashto, but it's often ignored by English-speaking learners because we don't really have anything like it in English. So, we need to understand what it is, and then train our brains to reach for it and use it in the right situations!
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ import {
|
||||||
inflectWord,
|
inflectWord,
|
||||||
isUnisexSet,
|
isUnisexSet,
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
import { words } from "../../words/words";
|
import { nouns } from "../../words/words";
|
||||||
import {
|
import {
|
||||||
firstVariation,
|
firstVariation,
|
||||||
} from "../../lib/text-tools";
|
} from "../../lib/text-tools";
|
||||||
|
@ -26,9 +26,9 @@ import { categorize } from "../../lib/categorize";
|
||||||
|
|
||||||
const genders: T.Gender[] = ["masc", "fem"];
|
const genders: T.Gender[] = ["masc", "fem"];
|
||||||
|
|
||||||
const mascNouns = words.nouns.filter(isMascNoun);
|
const mascNouns = nouns.filter(isMascNoun);
|
||||||
const femNouns = [
|
const femNouns = [
|
||||||
...words.nouns.filter(isFemNoun),
|
...nouns.filter(isFemNoun),
|
||||||
...getFemVersions(mascNouns.filter(isUnisexNoun)),
|
...getFemVersions(mascNouns.filter(isUnisexNoun)),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -12,9 +12,9 @@ import {
|
||||||
defaultTextOptions as opts,
|
defaultTextOptions as opts,
|
||||||
inflectWord,
|
inflectWord,
|
||||||
standardizePashto,
|
standardizePashto,
|
||||||
// pashtoConsonants,
|
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
import { words } from "../../words/words";
|
import { nouns } from "../../words/words";
|
||||||
|
import { intoPatterns } from "../../lib/categorize";
|
||||||
import {
|
import {
|
||||||
firstVariation,
|
firstVariation,
|
||||||
} from "../../lib/text-tools";
|
} from "../../lib/text-tools";
|
||||||
|
@ -22,15 +22,10 @@ import {
|
||||||
isUnisexNoun,
|
isUnisexNoun,
|
||||||
} from "../../lib/type-predicates";
|
} from "../../lib/type-predicates";
|
||||||
|
|
||||||
const nouns = words.nouns.filter(isUnisexNoun);
|
const unisexNouns = nouns.filter(isUnisexNoun);
|
||||||
// type NType = "consonant" | "eyUnstressed" | "eyStressed" | "pashtun" | "withu"
|
type NType = "pattern1" | "pattern2" | "pattern3" | "pattern4" | "pattern5" | "other";
|
||||||
// const types: Record<NType, T.DictionaryEntry[]> = {
|
// TODO: make pattern types as overlay types
|
||||||
// consonant: nouns.filter((w) => pashtoConsonants.includes(w.p.slice(-1))),
|
const types = intoPatterns(unisexNouns);
|
||||||
// eyUnstressed: nouns.filter((w) => w.f.slice(-2) === "ey"),
|
|
||||||
// eyStressed: nouns.filter((w) => w.f.slice(-2) === "éy"),
|
|
||||||
// pashtun: nouns.filter((w) => w.infaf?.includes("aa")),
|
|
||||||
// withu: nouns.filter((w) => w.infaf?.slice(-1) === "u" && !!w.infaf?.includes("aa")),
|
|
||||||
// }
|
|
||||||
const genders: T.Gender[] = ["masc", "fem"];
|
const genders: T.Gender[] = ["masc", "fem"];
|
||||||
|
|
||||||
const amount = 20;
|
const amount = 20;
|
||||||
|
@ -39,16 +34,20 @@ type Question = { entry: T.DictionaryEntry, gender: T.Gender };
|
||||||
|
|
||||||
export default function UnisexNounGame({ id, link }: { id: string, link: string }) {
|
export default function UnisexNounGame({ id, link }: { id: string, link: string }) {
|
||||||
function* questions (): Generator<Current<Question>> {
|
function* questions (): Generator<Current<Question>> {
|
||||||
let pool = [...nouns];
|
let pool = { ...types };
|
||||||
for (let i = 0; i < amount; i++) {
|
for (let i = 0; i < amount; i++) {
|
||||||
// const keys = Object.keys(types) as NType[];
|
const keys = Object.keys(types) as NType[];
|
||||||
// let type: NType
|
let type: NType
|
||||||
// do {
|
do {
|
||||||
// type = getRandomFromList(keys);
|
type = getRandomFromList(keys);
|
||||||
// } while (!pool[type].length);
|
} while (!pool[type].length);
|
||||||
const entry = getRandomFromList(pool);
|
const entry = getRandomFromList<UnisexNoun>(
|
||||||
|
// @ts-ignore
|
||||||
|
pool[type]
|
||||||
|
);
|
||||||
const gender = getRandomFromList(genders) as T.Gender;
|
const gender = getRandomFromList(genders) as T.Gender;
|
||||||
pool = pool.filter((x) => x.ts !== entry.ts);
|
// @ts-ignore
|
||||||
|
pool[type] = pool[type].filter((x) => x.ts !== entry.ts);
|
||||||
yield {
|
yield {
|
||||||
progress: makeProgress(i, amount),
|
progress: makeProgress(i, amount),
|
||||||
question: {
|
question: {
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
import {
|
import {
|
||||||
isNoun,
|
|
||||||
isPattern1Word,
|
isPattern1Word,
|
||||||
isPattern2Word,
|
isPattern2Word,
|
||||||
isPattern3Word,
|
isPattern3Word,
|
||||||
isPattern4Word,
|
isPattern4Word,
|
||||||
isPattern5Word,
|
isPattern5Word,
|
||||||
isPattern6FemNoun,
|
|
||||||
} from "./type-predicates";
|
} from "./type-predicates";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,23 +73,25 @@ export function categorize<I, X extends Record<string, I[]>>(
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function intoPatterns(words: (Noun | Adjective)[]): {
|
// TODO: uncategorizable words like ایرې - n. f. pl. -- could be pattern 1 or 2 🤷♂️
|
||||||
"pattern1": Pattern1Word[],
|
|
||||||
"pattern2": Pattern2Word[],
|
export function intoPatterns<T extends (Noun | Adjective)>(words: T[]): {
|
||||||
"pattern3": Pattern3Word[],
|
"pattern1": Pattern1Word<T>[],
|
||||||
"pattern4": Pattern4Word[],
|
"pattern2": Pattern2Word<T>[],
|
||||||
"pattern5": Pattern5Word[],
|
"pattern3": Pattern3Word<T>[],
|
||||||
"non-inflecting": NonInflecting[],
|
"pattern4": Pattern4Word<T>[],
|
||||||
"pattern6fem": Pattern6FemNoun[],
|
"pattern5": Pattern5Word<T>[],
|
||||||
|
"other": NonInflecting<T>[],
|
||||||
|
// "pattern6fem": Pattern6FemNoun<T>[],
|
||||||
} {
|
} {
|
||||||
return categorize<(Noun | Adjective), {
|
return categorize<(Noun | Adjective), {
|
||||||
"pattern1": Pattern1Word[],
|
"pattern1": Pattern1Word<T>[],
|
||||||
"pattern2": Pattern2Word[],
|
"pattern2": Pattern2Word<T>[],
|
||||||
"pattern3": Pattern3Word[],
|
"pattern3": Pattern3Word<T>[],
|
||||||
"pattern4": Pattern4Word[],
|
"pattern4": Pattern4Word<T>[],
|
||||||
"pattern5": Pattern5Word[],
|
"pattern5": Pattern5Word<T>[],
|
||||||
"non-inflecting": NonInflecting[],
|
"other": NonInflecting<T>[],
|
||||||
"pattern6fem": Pattern6FemNoun[],
|
// "pattern6fem": Pattern6FemNoun<T>[],
|
||||||
}>(
|
}>(
|
||||||
words,
|
words,
|
||||||
{
|
{
|
||||||
|
@ -100,8 +100,8 @@ export function intoPatterns(words: (Noun | Adjective)[]): {
|
||||||
"pattern3": isPattern3Word,
|
"pattern3": isPattern3Word,
|
||||||
"pattern4": isPattern4Word,
|
"pattern4": isPattern4Word,
|
||||||
"pattern5": isPattern5Word,
|
"pattern5": isPattern5Word,
|
||||||
"pattern6fem": (n) => (isNoun(n) && isPattern6FemNoun(n)),
|
// "pattern6fem": (n) => (isNoun(n) && isPattern6FemNoun(n)),
|
||||||
"non-inflecting": "leftovers",
|
"other": "leftovers",
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
|
@ -2,7 +2,6 @@ import {
|
||||||
pashtoConsonants,
|
pashtoConsonants,
|
||||||
endsWith,
|
endsWith,
|
||||||
countSyllables,
|
countSyllables,
|
||||||
removeAccents,
|
|
||||||
} from "@lingdocs/pashto-inflector";
|
} from "@lingdocs/pashto-inflector";
|
||||||
|
|
||||||
export function isNoun(e: Word): e is Noun {
|
export function isNoun(e: Word): e is Noun {
|
||||||
|
@ -47,11 +46,14 @@ export function isAdjOrUnisexNoun(e: Word): e is (Adjective | UnisexNoun) {
|
||||||
* @param e
|
* @param e
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function isPattern1Word(e: Noun | Adjective): e is Pattern1Word {
|
export function isPattern1Word<T extends (Noun | Adjective)>(e: T): e is Pattern1Word<T> {
|
||||||
if (e.noInf) return false;
|
if (e.noInf) return false;
|
||||||
if (e.infap) return false;
|
if (e.infap) return false;
|
||||||
if (isFemNoun(e)) {
|
if (isFemNoun(e)) {
|
||||||
return endsWith({ p: "ه", f: "a" }, e) && (endsWith({ p: pashtoConsonants }, e) && e.c.includes("anim."));
|
return (
|
||||||
|
endsWith([{ p: "ه", f: "a" }, { p: "ح", f: "a" }], e) ||
|
||||||
|
(endsWith({ p: pashtoConsonants }, e) && !e.c.includes("anim."))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
endsWith([{ p: pashtoConsonants }], e) ||
|
endsWith([{ p: pashtoConsonants }], e) ||
|
||||||
|
@ -66,14 +68,14 @@ export function isPattern1Word(e: Noun | Adjective): e is Pattern1Word {
|
||||||
* @param e
|
* @param e
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function isPattern2Word(e: Noun | Adjective): e is Pattern2Word {
|
export function isPattern2Word<T extends (Noun | Adjective)>(e: T): e is Pattern2Word<T> {
|
||||||
if (e.noInf) return false;
|
if (e.noInf) return false;
|
||||||
if (e.infap) return false;
|
if (e.infap) return false;
|
||||||
if (isFemNoun(e)) {
|
if (isFemNoun(e)) {
|
||||||
return !e.c.includes("pl.") && endsWith({ p: "ې", f: "e" }, e, true);
|
return !e.c.includes("pl.") && endsWith({ p: "ې", f: "e" }, e, true);
|
||||||
}
|
}
|
||||||
// TODO: check if it's a single syllable word, in which case it would be pattern 1
|
// TODO: check if it's a single syllable word, in which case it would be pattern 1
|
||||||
return endsWith({ p: "ی", f: "ey" }, e, true)// && (countSyllables(e.f) > 1);
|
return endsWith({ p: "ی", f: "ey" }, e, true) && (countSyllables(e.f) > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,13 +84,13 @@ export function isPattern2Word(e: Noun | Adjective): e is Pattern2Word {
|
||||||
* @param e
|
* @param e
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function isPattern3Word(e: Noun | Adjective): e is Pattern3Word {
|
export function isPattern3Word<T extends (Noun | Adjective)>(e: T): e is Pattern3Word<T> {
|
||||||
if (e.noInf) return false;
|
if (e.noInf) return false;
|
||||||
if (e.infap) return false;
|
if (e.infap) return false;
|
||||||
if (isFemNoun(e)) {
|
if (isFemNoun(e)) {
|
||||||
return endsWith({ p: "ۍ" }, e);
|
return endsWith({ p: "ۍ" }, e);
|
||||||
}
|
}
|
||||||
return (countSyllables(removeAccents(e.f)) > 1)
|
return (countSyllables(e.f) > 1)
|
||||||
? endsWith({ p: "ی", f: "éy" }, e, true)
|
? endsWith({ p: "ی", f: "éy" }, e, true)
|
||||||
: endsWith({ p: "ی", f: "ey" }, e)
|
: endsWith({ p: "ی", f: "ey" }, e)
|
||||||
}
|
}
|
||||||
|
@ -99,7 +101,7 @@ export function isPattern3Word(e: Noun | Adjective): e is Pattern3Word {
|
||||||
* @param e
|
* @param e
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function isPattern4Word(e: Noun | Adjective): e is Pattern4Word {
|
export function isPattern4Word<T extends (Noun | Adjective)>(e: T): e is Pattern4Word<T> {
|
||||||
if (e.noInf) return false;
|
if (e.noInf) return false;
|
||||||
return (
|
return (
|
||||||
!!(e.infap && e.infaf && e.infbp && e.infbf)
|
!!(e.infap && e.infaf && e.infbp && e.infbf)
|
||||||
|
@ -114,7 +116,7 @@ export function isPattern4Word(e: Noun | Adjective): e is Pattern4Word {
|
||||||
* @param e
|
* @param e
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function isPattern5Word(e: Noun | Adjective): e is Pattern5Word {
|
export function isPattern5Word<T extends (Noun | Adjective)>(e: T): e is Pattern5Word<T> {
|
||||||
if (e.noInf) return false;
|
if (e.noInf) return false;
|
||||||
return (
|
return (
|
||||||
!!(e.infap && e.infaf && e.infbp && e.infbf)
|
!!(e.infap && e.infaf && e.infbp && e.infbf)
|
||||||
|
@ -125,7 +127,7 @@ export function isPattern5Word(e: Noun | Adjective): e is Pattern5Word {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isPattern6FemNoun(e: Noun): e is Pattern6FemNoun {
|
export function isPattern6FemNoun(e: FemNoun): e is Pattern6FemNoun<FemNoun> {
|
||||||
if (!isFemNoun(e)) return false;
|
if (!isFemNoun(e)) return false;
|
||||||
if (e.c.includes("anim.")) return false;
|
if (e.c.includes("anim.")) return false;
|
||||||
return e.p.slice(-1) === "ي";
|
return e.p.slice(-1) === "ي";
|
||||||
|
|
|
@ -38,13 +38,13 @@ type RawWord = T.DictionaryEntry | {
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Write type predicates for these
|
// TODO: Write type predicates for these
|
||||||
type Pattern1Word = (Noun | Adjective) & { __brand3: "basic inflection pattern" };
|
type Pattern1Word<T> = T & { __brand3: "basic inflection pattern" };
|
||||||
type Pattern2Word = (Noun | Adjective) & { __brand3: "ending in unstressed ی pattern" };
|
type Pattern2Word<T> = T & { __brand3: "ending in unstressed ی pattern" };
|
||||||
type Pattern3Word = (Noun | Adjective) & { __brand3: "ending in stressed ی pattern" };
|
type Pattern3Word<T> = T & { __brand3: "ending in stressed ی pattern" };
|
||||||
type Pattern4Word = (Noun | Adjective) & { __brand3: "Pashtoon pattern" };
|
type Pattern4Word<T> = T & { __brand3: "Pashtoon pattern" };
|
||||||
type Pattern5Word = (Noun | Adjective) & { __brand3: "short squish pattern" };
|
type Pattern5Word<T> = T & { __brand3: "short squish pattern" };
|
||||||
type Pattern6FemNoun = FemNoun & { __brand3: "non anim. ending in ي" };
|
type Pattern6FemNoun<T extends FemNoun> = FemNoun & { __brand3: "non anim. ending in ي" };
|
||||||
type NonInflecting = (Noun | Adjective) & { __brand3: "non-inflecting" };
|
type NonInflecting<T> = T & { __brand3: "non-inflecting" };
|
||||||
// PLUS FEM INFLECTING
|
// PLUS FEM INFLECTING
|
||||||
|
|
||||||
type Word = Noun | Adjective | Verb;
|
type Word = Noun | Adjective | Verb;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
module.exports = [
|
module.exports = [
|
||||||
{ ts: 1527818948, e: `sneezing, sneeze` }, // اټسکی - aTúskey
|
{ ts: 1527818948, e: `sneezing, sneeze` }, // اټسکی - aTúskey
|
||||||
{ ts: 1527816481, e: `brother in law; sister's husband` }, // اخښی - akhxey
|
|
||||||
{ ts: 1573681135691, e: `tribal constable, tribal offical with police powers` }, // اربکی - arbakéy
|
{ ts: 1573681135691, e: `tribal constable, tribal offical with police powers` }, // اربکی - arbakéy
|
||||||
{ ts: 1573659054031, e: `width, spaciousness` }, // ارتوالی - artwaaley, aratwaaley
|
{ ts: 1573659054031, e: `width, spaciousness` }, // ارتوالی - artwaaley, aratwaaley
|
||||||
{ ts: 1527811890, e: `thorn, prickle` }, // ازغی - azghey
|
{ ts: 1527811890, e: `thorn, prickle` }, // ازغی - azghey
|
||||||
|
@ -13,8 +12,6 @@ module.exports = [
|
||||||
{ ts: 1527821545, e: `volcano` }, // اورشیندی - orsheendéy
|
{ ts: 1527821545, e: `volcano` }, // اورشیندی - orsheendéy
|
||||||
{ ts: 1527819192, e: `train` }, // اورګاډی - orgáaDey
|
{ ts: 1527819192, e: `train` }, // اورګاډی - orgáaDey
|
||||||
{ ts: 1527815585, e: `summer` }, // اوړی - oRey
|
{ ts: 1527815585, e: `summer` }, // اوړی - oRey
|
||||||
{ ts: 1527815132, e: `giraffe` }, // اوښ غویی - oox ghwayey
|
|
||||||
{ ts: 1527816488, e: `brother in law, wife's brother` }, // اوښی - awxey
|
|
||||||
{ ts: 1623044357441, e: `tuft, clump, shock of hair` }, // ببوتنکی - bubootúnkey
|
{ ts: 1623044357441, e: `tuft, clump, shock of hair` }, // ببوتنکی - bubootúnkey
|
||||||
{ ts: 1527821668, e: `spark, speck, flicker` }, // بڅری - batsúrey
|
{ ts: 1527821668, e: `spark, speck, flicker` }, // بڅری - batsúrey
|
||||||
{ ts: 1527821239, e: `kidney` }, // بډوری - baDóorey
|
{ ts: 1527821239, e: `kidney` }, // بډوری - baDóorey
|
||||||
|
@ -69,14 +66,10 @@ module.exports = [
|
||||||
{ ts: 1527819046, e: `drop` }, // څاڅکی - tsáatskey
|
{ ts: 1527819046, e: `drop` }, // څاڅکی - tsáatskey
|
||||||
{ ts: 1527817874, e: `quality, nature` }, // څرنګوالی - tsurangwaaley
|
{ ts: 1527817874, e: `quality, nature` }, // څرنګوالی - tsurangwaaley
|
||||||
{ ts: 1527814041, e: `spring (season)` }, // څړمنی - tsaRmuney
|
{ ts: 1527814041, e: `spring (season)` }, // څړمنی - tsaRmuney
|
||||||
{ ts: 1527813361, e: `column, pilliar, pyramid` }, // څلی - tsaley
|
|
||||||
{ ts: 1527819027, e: `ladle, dipper` }, // څمڅی - tsamtsey
|
|
||||||
{ ts: 1573055311846, e: `warning, notice, alarm` }, // خبرداری - khabardaarey
|
{ ts: 1573055311846, e: `warning, notice, alarm` }, // خبرداری - khabardaarey
|
||||||
{ ts: 1527820324, e: `melon` }, // خټکی - khaTakéy
|
{ ts: 1527820324, e: `melon` }, // خټکی - khaTakéy
|
||||||
{ ts: 1527819828, e: `weight; respect, honour` }, // درناوی - dranaawey
|
{ ts: 1527819828, e: `weight; respect, honour` }, // درناوی - dranaawey
|
||||||
{ ts: 1588161660483, e: `crutch, walking-stick, cane` }, // ډانګوری - Daangooréy
|
{ ts: 1588161660483, e: `crutch, walking-stick, cane` }, // ډانګوری - Daangooréy
|
||||||
{ ts: 1527813493, e: `majority; heap, pile` }, // ډېری - Derey
|
|
||||||
{ ts: 1527823700, e: `avalanche, flood, shower` }, // راشی - raashey
|
|
||||||
{ ts: 1527819732, e: `young, youth, young lad` }, // زلمی - zalméy
|
{ ts: 1527819732, e: `young, youth, young lad` }, // زلمی - zalméy
|
||||||
{ ts: 1527813708, e: `good news, gospel` }, // زېری - zerey
|
{ ts: 1527813708, e: `good news, gospel` }, // زېری - zerey
|
||||||
{ ts: 1588758498458, e: `jaundice` }, // زېړی - zeRéy
|
{ ts: 1588758498458, e: `jaundice` }, // زېړی - zeRéy
|
||||||
|
@ -105,8 +98,6 @@ module.exports = [
|
||||||
{ ts: 1527814569, e: `member` }, // غړی - ghuRey
|
{ ts: 1527814569, e: `member` }, // غړی - ghuRey
|
||||||
{ ts: 1527817627, e: `arrow` }, // غشی - ghúshey
|
{ ts: 1527817627, e: `arrow` }, // غشی - ghúshey
|
||||||
{ ts: 1527822913, e: `precious stone, precious stone in a signet ring` }, // غمی - ghaméy
|
{ ts: 1527822913, e: `precious stone, precious stone in a signet ring` }, // غمی - ghaméy
|
||||||
{ ts: 1527823466, e: `ear lobe` }, // غنګوری - ghangóorey
|
|
||||||
{ ts: 1527818483, e: `plate` }, // غوری - ghorey
|
|
||||||
{ ts: 1527816181, e: `vomit, nausea (Arabic)` }, // قی - qey
|
{ ts: 1527816181, e: `vomit, nausea (Arabic)` }, // قی - qey
|
||||||
{ ts: 1527814715, e: `user` }, // کاروونکی - kaarawoonkey
|
{ ts: 1527814715, e: `user` }, // کاروونکی - kaarawoonkey
|
||||||
{ ts: 1527823295, e: `stone, rock` }, // کاڼی - káaNey
|
{ ts: 1527823295, e: `stone, rock` }, // کاڼی - káaNey
|
||||||
|
@ -115,7 +106,6 @@ module.exports = [
|
||||||
{ ts: 1582388629980, e: `pupil (of an eye)` }, // کسی - kúsey
|
{ ts: 1582388629980, e: `pupil (of an eye)` }, // کسی - kúsey
|
||||||
{ ts: 1594906790729, e: `boy` }, // ککی - kakéy
|
{ ts: 1594906790729, e: `boy` }, // ککی - kakéy
|
||||||
{ ts: 1527812836, e: `village` }, // کلی - kuley, kiley
|
{ ts: 1527812836, e: `village` }, // کلی - kuley, kiley
|
||||||
{ ts: 1527816880, e: `shortage, lack, deficiency` }, // کمی - kamey
|
|
||||||
{ ts: 1610616852625, e: `echo` }, // کنګرېزی - kangrezéy
|
{ ts: 1610616852625, e: `echo` }, // کنګرېزی - kangrezéy
|
||||||
{ ts: 1527819196, e: `car, train` }, // ګاډی - gaaDey
|
{ ts: 1527819196, e: `car, train` }, // ګاډی - gaaDey
|
||||||
{ ts: 1579016593220, e: `beehive; wasps' nest` }, // ګنی - ganéy
|
{ ts: 1579016593220, e: `beehive; wasps' nest` }, // ګنی - ganéy
|
||||||
|
@ -125,17 +115,13 @@ module.exports = [
|
||||||
{ ts: 1573149568665, e: `access, availability` }, // لاسرسی - laasraséy
|
{ ts: 1573149568665, e: `access, availability` }, // لاسرسی - laasraséy
|
||||||
{ ts: 1527817464, e: `wood, timber` }, // لرګی - largey
|
{ ts: 1527817464, e: `wood, timber` }, // لرګی - largey
|
||||||
{ ts: 1527822801, e: `sleeve` }, // لستوڼی - lastóNey
|
{ ts: 1527822801, e: `sleeve` }, // لستوڼی - lastóNey
|
||||||
{ ts: 1527812416, e: `brook, rivulet, small irrigation` }, // لښتی - laxtey
|
|
||||||
{ ts: 1527814401, e: `toy` }, // لوبونی - lobawuney
|
{ ts: 1527814401, e: `toy` }, // لوبونی - lobawuney
|
||||||
{ ts: 1527814519, e: `side, direction` }, // لوری - lorey
|
{ ts: 1527814519, e: `side, direction` }, // لوری - lorey
|
||||||
{ ts: 1527823103, e: `perspective, viewpoint` }, // لیدلوری - leedlorey
|
{ ts: 1527823103, e: `perspective, viewpoint` }, // لیدلوری - leedlorey
|
||||||
{ ts: 1527819920, e: `mosquito, midge` }, // ماشی - maashey
|
{ ts: 1527819920, e: `mosquito, midge` }, // ماشی - maashey
|
||||||
{ ts: 1527820224, e: `fly swatter` }, // مچوژی - muchwajzéy
|
{ ts: 1527820224, e: `fly swatter` }, // مچوژی - muchwajzéy
|
||||||
{ ts: 1591871316865, e: `prefix (grammar)` }, // مختاړی - mukhtaaRey
|
|
||||||
{ ts: 1527817105, e: `smile, smiling` }, // مړخندی - muRkhandey
|
|
||||||
{ ts: 1527817770, e: `dead body, corpse` }, // مړی - múRey
|
{ ts: 1527817770, e: `dead body, corpse` }, // مړی - múRey
|
||||||
{ ts: 1527813189, e: `fall, autumn` }, // منی - máney
|
{ ts: 1527813189, e: `fall, autumn` }, // منی - máney
|
||||||
{ ts: 1527812925, e: `peanut` }, // مومپلی - mompaley
|
|
||||||
{ ts: 1527812421, e: `ant` }, // مېږی - meGey
|
{ ts: 1527812421, e: `ant` }, // مېږی - meGey
|
||||||
{ ts: 1527819227, e: `lack` }, // نشتوالی - nashtwaaley
|
{ ts: 1527819227, e: `lack` }, // نشتوالی - nashtwaaley
|
||||||
{ ts: 1527823577, e: `sapling, seedling, sprout, young tree` }, // نیالګی - niyaalgey
|
{ ts: 1527823577, e: `sapling, seedling, sprout, young tree` }, // نیالګی - niyaalgey
|
||||||
|
@ -143,7 +129,5 @@ module.exports = [
|
||||||
{ ts: 1527812668, e: `welcome` }, // هرکلی - hărkáley
|
{ ts: 1527812668, e: `welcome` }, // هرکلی - hărkáley
|
||||||
{ ts: 1588153218244, e: `height, elevation, tallness` }, // هسکوالی - haskwáaley
|
{ ts: 1588153218244, e: `height, elevation, tallness` }, // هسکوالی - haskwáaley
|
||||||
{ ts: 1585309922022, e: `flu, respiratory illness, influenza, cold` }, // والګی - waalgéy
|
{ ts: 1585309922022, e: `flu, respiratory illness, influenza, cold` }, // والګی - waalgéy
|
||||||
{ ts: 1527813014, e: `vein, nerve` }, // وژی - wajzey
|
|
||||||
{ ts: 1527821465, e: `shoulder` }, // ولی - wuléy
|
{ ts: 1527821465, e: `shoulder` }, // ولی - wuléy
|
||||||
{ ts: 1527814004, e: `summer` }, // ووړی - woRey
|
|
||||||
]
|
]
|
File diff suppressed because one or more lines are too long
|
@ -1,40 +1,32 @@
|
||||||
import rawWords from "./raw-words";
|
import rawWords from "./raw-words";
|
||||||
import {
|
import {
|
||||||
isAdjective,
|
isAdjective,
|
||||||
// isFemNoun,
|
|
||||||
// isMascNoun,
|
|
||||||
isNoun,
|
isNoun,
|
||||||
isVerb,
|
isVerb,
|
||||||
} from "../lib/type-predicates";
|
} from "../lib/type-predicates";
|
||||||
import { categorize, intoPatterns } from "../lib/categorize";
|
import { categorize } from "../lib/categorize";
|
||||||
|
|
||||||
export const words = categorize<Word, Words>(rawWords, {
|
const words = categorize<Word, Words>(rawWords, {
|
||||||
"nouns": isNoun,
|
"nouns": isNoun,
|
||||||
"adjectives": isAdjective,
|
"adjectives": isAdjective,
|
||||||
"verbs": isVerb,
|
"verbs": isVerb,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(
|
export default words;
|
||||||
Object.entries(
|
|
||||||
intoPatterns([
|
|
||||||
...words.nouns,
|
|
||||||
...words.adjectives
|
|
||||||
])
|
|
||||||
).reduce((ob, [key, arr]) => {
|
|
||||||
return {
|
|
||||||
...ob,
|
|
||||||
[key]: arr.map(a => `${a.f} - ${a.p} - ${a.c}`),
|
|
||||||
};
|
|
||||||
}, {})
|
|
||||||
);
|
|
||||||
|
|
||||||
// const genderedNouns = categorize<Noun, { masc: MascNoun[], fem: FemNoun[] }>(
|
export const { nouns, adjectives, verbs } = words;
|
||||||
// words.nouns,
|
|
||||||
// {
|
// console.log(
|
||||||
// "masc": isMascNoun,
|
// Object.entries(
|
||||||
// "fem": isFemNoun,
|
// intoPatterns([
|
||||||
// },
|
// ...words.nouns,
|
||||||
|
// ...words.adjectives
|
||||||
|
// ])
|
||||||
|
// ).reduce((ob, [key, arr]) => {
|
||||||
|
// return {
|
||||||
|
// ...ob,
|
||||||
|
// // @ts-ignore
|
||||||
|
// [key]: arr.map(a => a.f),
|
||||||
|
// };
|
||||||
|
// }, {})
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// console.log(genderedNouns);
|
|
||||||
|
|
||||||
|
|
|
@ -1619,10 +1619,10 @@
|
||||||
pbf "^3.2.1"
|
pbf "^3.2.1"
|
||||||
rambda "^6.7.0"
|
rambda "^6.7.0"
|
||||||
|
|
||||||
"@lingdocs/pashto-inflector@^1.2.6":
|
"@lingdocs/pashto-inflector@^1.2.8":
|
||||||
version "1.2.6"
|
version "1.2.8"
|
||||||
resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-1.2.6.tgz#41c3d8e663d4b4c1ef37bd49d7de536e05776a4d"
|
resolved "https://npm.lingdocs.com/@lingdocs%2fpashto-inflector/-/pashto-inflector-1.2.8.tgz#db1a94e3d9bcc067525d9496efa7ca591f56d373"
|
||||||
integrity sha512-7FiMasn312whe9izP+E/b2Img4pUf2wzPv8Y+ZHMqtG9AhAatlKYC/IiS8PoG+EPXJ1BoSQ8UmUMao5qmu0G+w==
|
integrity sha512-uW7JtCXYinAVJhGrD3dwwpZ198uaZ5LZJWbfg9PUac3e7PSeZPX+/UJgGRggaWOcOUdqs8ZnKuWpCM+KrgZplg==
|
||||||
dependencies:
|
dependencies:
|
||||||
classnames "^2.2.6"
|
classnames "^2.2.6"
|
||||||
pbf "^3.2.1"
|
pbf "^3.2.1"
|
||||||
|
|
Loading…
Reference in New Issue