diff --git a/src/games/sub-cores/PluralNounGame.tsx b/src/games/sub-cores/PluralNounGame.tsx index 775e586..df192a8 100644 --- a/src/games/sub-cores/PluralNounGame.tsx +++ b/src/games/sub-cores/PluralNounGame.tsx @@ -45,7 +45,7 @@ export const nouns = wordQuery("nouns", [ "gaawanDay", "sakhtee", "dostee", - "aRtiyaa", + "aRtyaa", "DaakTar", "laas", "waadu", diff --git a/src/lib/misc-helpers.ts b/src/lib/misc-helpers.ts index 49b8e15..589ca61 100644 --- a/src/lib/misc-helpers.ts +++ b/src/lib/misc-helpers.ts @@ -2,5 +2,9 @@ * Removes ă and replaces with a */ export function removeAShort(s: string): string { - return s.replace(/ă/g, "a"); -} \ No newline at end of file + return s.replace(/ă/g, "a"); +} + +export function removeAyn(s: string): string { + return s.replace(/'/g, ""); +} diff --git a/src/words/words.ts b/src/words/words.ts index dc5bc5a..77d1d21 100644 --- a/src/words/words.ts +++ b/src/words/words.ts @@ -1,27 +1,29 @@ import rawWords from "./raw-words"; import { - removeAccents, - removeFVarients, - typePredicates as tp, - Types as T, + removeAccents, + removeFVarients, + typePredicates as tp, + Types as T, } from "@lingdocs/ps-react"; import { categorize } from "../lib/categorize"; -import { removeAShort } from "../lib/misc-helpers"; - +import { removeAShort, removeAyn } from "../lib/misc-helpers"; // TODO: BIG ISSUE WITH THE LOC ADVERBS BEING LUMPED INTO THE ADVERBS! -const words = categorize(rawWords, { - nouns: tp.isNounEntry, - adjectives: tp.isAdjectiveEntry, - verbs: tp.isVerbEntry, - adverbs: tp.isAdverbEntry, - locativeAdverbs: tp.isLocativeAdverbEntry, +const words = categorize< + T.Entry, + { + nouns: T.NounEntry[]; + adjectives: T.AdjectiveEntry[]; + verbs: T.VerbEntry[]; + adverbs: T.AdverbEntry[]; + locativeAdverbs: T.LocativeAdverbEntry[]; + } +>(rawWords, { + nouns: tp.isNounEntry, + adjectives: tp.isAdjectiveEntry, + verbs: tp.isVerbEntry, + adverbs: tp.isAdverbEntry, + locativeAdverbs: tp.isLocativeAdverbEntry, }); export default words; @@ -29,40 +31,55 @@ export default words; export const { nouns, adjectives, verbs, adverbs, locativeAdverbs } = words; export function wordQuery(category: "nouns", w: string[]): T.NounEntry[]; -export function wordQuery(category: "adjectives", w: string[]): T.AdjectiveEntry[]; +export function wordQuery( + category: "adjectives", + w: string[] +): T.AdjectiveEntry[]; export function wordQuery(category: "adverbs", w: string[]): T.AdverbEntry[]; -export function wordQuery(category: "locativeAdverbs", w: string[]): T.LocativeAdverbEntry[]; +export function wordQuery( + category: "locativeAdverbs", + w: string[] +): T.LocativeAdverbEntry[]; export function wordQuery(category: "verbs", w: string[]): T.VerbEntry[]; export function wordQuery( - category: "nouns" | "adjectives" | "adverbs" | "locativeAdverbs" | "verbs", - w: string[], -): T.NounEntry[] | T.AdjectiveEntry[] | T.AdverbEntry[] | T.LocativeAdverbEntry[] | T.VerbEntry[] { - function queryRemoveAccents(s: string): string { - return removeAShort(removeAccents(s)); - } - if (category === "verbs") { - return w.map(word => { - const l = words[category]; - const found = l.find(x => vMatches(x, word)); - if (!found) throw new Error(`${word} not found by wordQuery`); - return found; - }); - } - function vMatches(x: T.VerbEntry, y: string) { - return (y === x.entry.p) - || (queryRemoveAccents(y) === queryRemoveAccents(removeFVarients(x.entry.f))); - } - function wMatches(x: T.DictionaryEntry, y: string) { - return (y === x.p) - || (queryRemoveAccents(y) === queryRemoveAccents(removeFVarients(x.f))); - } - return w.map(word => { - const l = words[category]; - // @ts-ignore - const found = l.find(x => wMatches(x, word)); - if (!found) throw new Error(`${word} not found by wordQuery`); - return found; + category: "nouns" | "adjectives" | "adverbs" | "locativeAdverbs" | "verbs", + w: string[] +): + | T.NounEntry[] + | T.AdjectiveEntry[] + | T.AdverbEntry[] + | T.LocativeAdverbEntry[] + | T.VerbEntry[] { + function queryRemoveAccents(s: string): string { + return removeAyn(removeAShort(removeAccents(s))); + } + if (category === "verbs") { + return w.map((word) => { + const l = words[category]; + const found = l.find((x) => vMatches(x, word)); + if (!found) throw new Error(`${word} not found by wordQuery`); + return found; }); + } + function vMatches(x: T.VerbEntry, y: string) { + return ( + y === x.entry.p || + queryRemoveAccents(y) === queryRemoveAccents(removeFVarients(x.entry.f)) + ); + } + function wMatches(x: T.DictionaryEntry, y: string) { + return ( + y === x.p || + queryRemoveAccents(y) === queryRemoveAccents(removeFVarients(x.f)) + ); + } + return w.map((word) => { + const l = words[category]; + // @ts-ignore + const found = l.find((x) => wMatches(x, word)); + if (!found) throw new Error(`${word} not found by wordQuery`); + return found; + }); } // console.log(