cleanup
This commit is contained in:
parent
6e8b1113f5
commit
c708666baf
|
@ -45,7 +45,7 @@ export const nouns = wordQuery("nouns", [
|
|||
"gaawanDay",
|
||||
"sakhtee",
|
||||
"dostee",
|
||||
"aRtiyaa",
|
||||
"aRtyaa",
|
||||
"DaakTar",
|
||||
"laas",
|
||||
"waadu",
|
||||
|
|
|
@ -2,5 +2,9 @@
|
|||
* Removes ă and replaces with a
|
||||
*/
|
||||
export function removeAShort(s: string): string {
|
||||
return s.replace(/ă/g, "a");
|
||||
}
|
||||
return s.replace(/ă/g, "a");
|
||||
}
|
||||
|
||||
export function removeAyn(s: string): string {
|
||||
return s.replace(/'/g, "");
|
||||
}
|
||||
|
|
|
@ -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<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,
|
||||
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(
|
||||
|
|
Loading…
Reference in New Issue