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 => {
const { entries } = readDictionary(data);
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 = [
// ${filtered.reduce((text, entry) => (
// 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 = `module.exports = [
${filtered.reduce((text, entry) => (
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`
// ), "")}
// ];`;
fs.writeFileSync(path.join(verbsPath, "wordle-words.ts"), content);

View File

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

View File

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

View File

@ -2,6 +2,8 @@ import {
Types as T,
ButtonSelect,
} from "@lingdocs/pashto-inflector";
import { getEnglishPronoun } from "../../lib/english-pronoun-tools";
import { capitalizeFirstLetter } from "../../lib/text-tools";
import useStickyState from "../../useStickyState";
const gColors = {
@ -50,27 +52,24 @@ function pickerStateToPerson(s: PickerState): T.Person {
+ (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 p = personToPickerState(pronoun.person);
function handleClick(row: number, col: number) {
const person = pickerStateToPerson({ ...p, row, col });
onChange({
...pronoun,
person: pickerStateToPerson({
...p,
row,
col,
}),
e: capitalizeFirstLetter(getEnglishPronoun(person, "subject")),
person,
});
}
function handleGenderChange(gender: T.Gender) {
const person = pickerStateToPerson({ ...p, gender });
onChange({
...pronoun,
person: pickerStateToPerson({
...p,
gender,
}),
e: capitalizeFirstLetter(getEnglishPronoun(person, "subject")),
person,
});
}
function handlePronounTypeChange(distance: "far" | "near") {
@ -89,7 +88,7 @@ function PronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onCha
}
const prs = labels[display];
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">
<ButtonSelect
xSmall
@ -133,4 +132,4 @@ function PronounPicker({ onChange, pronoun }: { pronoun: PronounSelection, onCha
</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 { startingWord } from "../../lib/starting-word";
import Link from "../../components/Link";
import psmd from "../../lib/psmd";
export const words = [
...nouns.filter(isUnisexNounEntry),
@ -64,28 +65,28 @@ These words always end in:
<details>
<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>
For example using the word <InlinePs opts={opts} ps={{ p: "کوټه", f: "koTá", e: "room" }} />:
<Examples opts={opts}>{[
<Examples opts={opts}>{psmd([
{
p: "زه په کوټه کې ناست یم",
f: "zu pu koTá ke naast yum",
e: "I am sitting in the room",
p: "زه **په کوټه کې** ناست یم",
f: "zu **pu koTá ke** naast yum",
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: "زه کوټې ته ځم",
f: "zu koTé ta dzum",
p: "زه **کوټې ته** ځم",
f: "zu **koTé ta** dzum",
e: "I'm going to the room",
},
]}</Examples>
])}</Examples>
</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

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,
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