touchup inflection part

This commit is contained in:
lingdocs 2022-02-27 16:27:36 +04:00
parent f4a4e6eac5
commit 0458e081e2
8 changed files with 112 additions and 3258 deletions

View File

@ -54,18 +54,18 @@ const pChars = [
fetch(process.env.LINGDOCS_DICTIONARY_URL).then(res => res.arrayBuffer()).then(data => { fetch(process.env.LINGDOCS_DICTIONARY_URL).then(res => res.arrayBuffer()).then(data => {
const { entries } = readDictionary(data); const { entries } = readDictionary(data);
const filtered = shuffle(entries.filter(e => ( const filtered = shuffle(entries.filter(e => (
e.p.length === 5 && e.p.split("").every((char) => pChars.includes(char)) e.c?.includes("n. f.") && e.p.endsWith("ي")
))); )));
// const content = `module.exports = [ const content = `module.exports = [
// ${filtered.reduce((text, entry) => ( ${filtered.reduce((text, entry) => (
// text + `{ ts: ${entry.ts}, e: \`${entry.e.replace(/"/g, '\\"')}\` }, // ${entry.p} - ${entry.f} text + `{ ts: ${entry.ts}, e: \`${entry.e.replace(/"/g, '\\"')}\` }, // ${entry.p} - ${entry.f}
// `), "")} `), "")}
// ];`;
const content = `export const WORDS = [
${filtered.map((entry) => (entry.p.replace("آ", "ا"))).reduce((text, p) => (
text + `"${p}",\n`
), "")}
];`; ];`;
// const content = `export const WORDS = [
// ${filtered.map((entry) => (entry.p.replace("آ", "ا"))).reduce((text, p) => (
// text + `"${p}",\n`
// ), "")}
// ];`;
fs.writeFileSync(path.join(verbsPath, "wordle-words.ts"), content); fs.writeFileSync(path.join(verbsPath, "wordle-words.ts"), content);

View File

@ -7,8 +7,7 @@
*/ */
* { * {
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
} }
.table-of-contents { .table-of-contents {

View File

@ -1,7 +1,9 @@
import PronounPicker from "./NPPronounPicker"; import PronounPicker from "./NPPronounPicker";
import { getEnglishPronoun } from "../../lib/english-pronoun-tools";
// import { ButtonSelect } from "@lingdocs/pashto-inflector"; // import { ButtonSelect } from "@lingdocs/pashto-inflector";
import { randomPerson } from "../../lib/np-tools"; import { randomPerson } from "../../lib/np-tools";
import { useState } from "react"; import { useState } from "react";
import { capitalizeFirstLetter } from "../../lib/text-tools";
const npTypes: NPType[] = ["noun", "pronoun", "participle"]; const npTypes: NPType[] = ["noun", "pronoun", "participle"];
@ -14,10 +16,11 @@ function NPPicker({ np, onChange }: { onChange: (nps: NPSelection | undefined) =
} }
function handleNPTypeChange(ntp: NPType) { function handleNPTypeChange(ntp: NPType) {
if (ntp === "pronoun") { if (ntp === "pronoun") {
const person = randomPerson();
const pronoun: PronounSelection = { const pronoun: PronounSelection = {
type: "pronoun", type: "pronoun",
e: "not done", e: capitalizeFirstLetter(getEnglishPronoun(person, "subject")),
person: randomPerson(), person,
distance: "far", distance: "far",
}; };
onChange(pronoun); onChange(pronoun);

View File

@ -2,6 +2,8 @@ import {
Types as T, Types as T,
ButtonSelect, ButtonSelect,
} from "@lingdocs/pashto-inflector"; } from "@lingdocs/pashto-inflector";
import { getEnglishPronoun } from "../../lib/english-pronoun-tools";
import { capitalizeFirstLetter } from "../../lib/text-tools";
import useStickyState from "../../useStickyState"; import useStickyState from "../../useStickyState";
const gColors = { const gColors = {
@ -50,27 +52,24 @@ function pickerStateToPerson(s: PickerState): T.Person {
+ (6 * s.col); + (6 * s.col);
} }
function PronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onChange: (p: PronounSelection) => void }) { function NPPronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onChange: (p: PronounSelection) => void }) {
const [display, setDisplay] = useStickyState<"persons" | "p" | "e">("persons", "prounoun-picker-display"); const [display, setDisplay] = useStickyState<"persons" | "p" | "e">("persons", "prounoun-picker-display");
const p = personToPickerState(pronoun.person); const p = personToPickerState(pronoun.person);
function handleClick(row: number, col: number) { function handleClick(row: number, col: number) {
const person = pickerStateToPerson({ ...p, row, col });
onChange({ onChange({
...pronoun, ...pronoun,
person: pickerStateToPerson({ e: capitalizeFirstLetter(getEnglishPronoun(person, "subject")),
...p, person,
row,
col,
}),
}); });
} }
function handleGenderChange(gender: T.Gender) { function handleGenderChange(gender: T.Gender) {
const person = pickerStateToPerson({ ...p, gender });
onChange({ onChange({
...pronoun, ...pronoun,
person: pickerStateToPerson({ e: capitalizeFirstLetter(getEnglishPronoun(person, "subject")),
...p, person,
gender,
}),
}); });
} }
function handlePronounTypeChange(distance: "far" | "near") { function handlePronounTypeChange(distance: "far" | "near") {
@ -89,7 +88,7 @@ function PronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onCha
} }
const prs = labels[display]; const prs = labels[display];
const pSpec = "near" in prs ? prs[pronoun.distance] : prs; const pSpec = "near" in prs ? prs[pronoun.distance] : prs;
return <div> return <div style={{ maxWidth: "225px" }}>
<div className="d-flex flex-row justify-content-around mb-3"> <div className="d-flex flex-row justify-content-around mb-3">
<ButtonSelect <ButtonSelect
xSmall xSmall
@ -133,4 +132,4 @@ function PronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onCha
</div>; </div>;
}; };
export default PronounPicker; export default NPPronounPicker;

View File

@ -35,6 +35,7 @@ import InflectionCarousel from "../../components/InflectionCarousel";
import { nouns, adjectives } 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";
import psmd from "../../lib/psmd";
export const words = [ export const words = [
...nouns.filter(isUnisexNounEntry), ...nouns.filter(isUnisexNounEntry),
@ -64,28 +65,28 @@ These words always end in:
<details> <details>
<summary> <summary>
<strong>Note</strong>: In sandwiches staring with <InlinePs opts={opts} ps={{ p: "په", f: "pu" }} /> the first inflection is normally not used. But it may be used in some dialects/colloquial speech. <strong>Note</strong>: In sandwiches like <InlinePs opts={opts} ps={{ p: "په ... کې", f: "pu ... ke" }} /> describing <strong>location</strong> the first inflection of nouns in this pattern is not used.
</summary> </summary>
For example using the word <InlinePs opts={opts} ps={{ p: "کوټه", f: "koTá", e: "room" }} />: For example using the word <InlinePs opts={opts} ps={{ p: "کوټه", f: "koTá", e: "room" }} />:
<Examples opts={opts}>{[ <Examples opts={opts}>{psmd([
{ {
p: "زه په کوټه کې ناست یم", p: "زه **په کوټه کې** ناست یم",
f: "zu pu koTá ke naast yum", f: "zu **pu koTá ke** naast yum",
e: "I am sitting in the room", e: "I am sitting **in the room**.",
} }
]}</Examples> ])}</Examples>
Notice how it does not use the first feminine inflection <InlinePs opts={opts} ps={{ p: "کوټې", f: "koTe" }} />, as it does with a different sandwich: In any other kind of sandwich the first inflection would be used.
<Examples opts={opts}>{[ <Examples opts={opts}>{psmd([
{ {
p: "زه کوټې ته ځم", p: "زه **کوټې ته** ځم",
f: "zu koTé ta dzum", f: "zu **koTé ta** dzum",
e: "I'm going to the room", e: "I'm going to the room",
}, },
]}</Examples> ])}</Examples>
</details> </details>
@ -117,7 +118,39 @@ These words are a little irregular but you can see a common patten based around:
"پښتون", "پښتون",
)} /> )} />
**Note**: Nouns in this pattern will often only use the first inflection for the plural. Adjectives will use the 1st inflection for all 3 reasons. **Note**:
<details>
<summary>
<strong>Note</strong>: <strong>Animate nouns</strong> in this pattern will often only use the first inflection for the plural.
</summary>
For example, if we put a singular (animate) word <InlinePs opts={opts} ps={{ p: "پښټون", f: "puxtoon" }} /> in a sandwich, most of the time people will not inflect it.
<Examples opts={opts}>{psmd([
{
p: "**د پښتون** نوم څه دی؟",
f: "**du puxtoon** noom tsu dey?",
e: "What is the **Pashtun's** name",
}
])}</Examples>
But it will of course inflect for the plural.
<Examples opts={opts}>{psmd([
{
p: "دلته **پښتانه** اوسېږي",
f: "dalta **puxtaanu** oseGee",
e: "**Pashtuns** live here",
},
{
p: "دا **د پښتنو** رواج دی",
f: "daa **du puxtano** rawaaj dey",
e: "This is **the Pashtuns'** custom"
},
])}</Examples>
</details>
## 5. Shorter words that squish ## 5. Shorter words that squish

View File

@ -0,0 +1,36 @@
import { Types as T } from "@lingdocs/pashto-inflector";
const englishPronouns = {
subject: [
"I (m.)",
"I (f.)",
"you (m.)",
"you (f.)",
"he/it (m.)",
"she/it (m.)",
"we (m.)",
"we (f.)",
"you (m. pl.)",
"you (f. pl.)",
"they (m. pl.)",
"they (f. pl.)",
],
object: [
"me (m.)",
"me (f.)",
"you (m.)",
"you (f.)",
"him/it (m.)",
"her/it (m.)",
"us (m.)",
"us (f.)",
"you (m. pl.)",
"you (f. pl.)",
"them (m. pl.)",
"them (f. pl.)",
],
};
export function getEnglishPronoun(person: T.Person, type: "subject" | "object"): string {
return englishPronouns[type][person];
}

View File

@ -12,4 +12,8 @@ export function psStringFromEntry(entry: T.PsString): T.PsString {
p: entry.p, p: entry.p,
f: removeFVarients(entry.f), f: removeFVarients(entry.f),
}; };
}
export function capitalizeFirstLetter(string: string) {
return string.charAt(0).toUpperCase() + string.slice(1);
} }

File diff suppressed because it is too large Load Diff