cleanup
This commit is contained in:
parent
6e8b1113f5
commit
c708666baf
|
@ -45,7 +45,7 @@ export const nouns = wordQuery("nouns", [
|
||||||
"gaawanDay",
|
"gaawanDay",
|
||||||
"sakhtee",
|
"sakhtee",
|
||||||
"dostee",
|
"dostee",
|
||||||
"aRtiyaa",
|
"aRtyaa",
|
||||||
"DaakTar",
|
"DaakTar",
|
||||||
"laas",
|
"laas",
|
||||||
"waadu",
|
"waadu",
|
||||||
|
|
|
@ -2,5 +2,9 @@
|
||||||
* Removes ă and replaces with a
|
* Removes ă and replaces with a
|
||||||
*/
|
*/
|
||||||
export function removeAShort(s: string): string {
|
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 rawWords from "./raw-words";
|
||||||
import {
|
import {
|
||||||
removeAccents,
|
removeAccents,
|
||||||
removeFVarients,
|
removeFVarients,
|
||||||
typePredicates as tp,
|
typePredicates as tp,
|
||||||
Types as T,
|
Types as T,
|
||||||
} from "@lingdocs/ps-react";
|
} from "@lingdocs/ps-react";
|
||||||
import { categorize } from "../lib/categorize";
|
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!
|
// TODO: BIG ISSUE WITH THE LOC ADVERBS BEING LUMPED INTO THE ADVERBS!
|
||||||
const words = categorize<T.Entry, {
|
const words = categorize<
|
||||||
nouns: T.NounEntry[],
|
T.Entry,
|
||||||
adjectives: T.AdjectiveEntry[],
|
{
|
||||||
verbs: T.VerbEntry[],
|
nouns: T.NounEntry[];
|
||||||
adverbs: T.AdverbEntry[],
|
adjectives: T.AdjectiveEntry[];
|
||||||
locativeAdverbs: T.LocativeAdverbEntry[],
|
verbs: T.VerbEntry[];
|
||||||
}>(rawWords, {
|
adverbs: T.AdverbEntry[];
|
||||||
nouns: tp.isNounEntry,
|
locativeAdverbs: T.LocativeAdverbEntry[];
|
||||||
adjectives: tp.isAdjectiveEntry,
|
}
|
||||||
verbs: tp.isVerbEntry,
|
>(rawWords, {
|
||||||
adverbs: tp.isAdverbEntry,
|
nouns: tp.isNounEntry,
|
||||||
locativeAdverbs: tp.isLocativeAdverbEntry,
|
adjectives: tp.isAdjectiveEntry,
|
||||||
|
verbs: tp.isVerbEntry,
|
||||||
|
adverbs: tp.isAdverbEntry,
|
||||||
|
locativeAdverbs: tp.isLocativeAdverbEntry,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default words;
|
export default words;
|
||||||
|
@ -29,40 +31,55 @@ export default words;
|
||||||
export const { nouns, adjectives, verbs, adverbs, locativeAdverbs } = words;
|
export const { nouns, adjectives, verbs, adverbs, locativeAdverbs } = words;
|
||||||
|
|
||||||
export function wordQuery(category: "nouns", w: string[]): T.NounEntry[];
|
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: "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: "verbs", w: string[]): T.VerbEntry[];
|
||||||
export function wordQuery(
|
export function wordQuery(
|
||||||
category: "nouns" | "adjectives" | "adverbs" | "locativeAdverbs" | "verbs",
|
category: "nouns" | "adjectives" | "adverbs" | "locativeAdverbs" | "verbs",
|
||||||
w: string[],
|
w: string[]
|
||||||
): T.NounEntry[] | T.AdjectiveEntry[] | T.AdverbEntry[] | T.LocativeAdverbEntry[] | T.VerbEntry[] {
|
):
|
||||||
function queryRemoveAccents(s: string): string {
|
| T.NounEntry[]
|
||||||
return removeAShort(removeAccents(s));
|
| T.AdjectiveEntry[]
|
||||||
}
|
| T.AdverbEntry[]
|
||||||
if (category === "verbs") {
|
| T.LocativeAdverbEntry[]
|
||||||
return w.map(word => {
|
| T.VerbEntry[] {
|
||||||
const l = words[category];
|
function queryRemoveAccents(s: string): string {
|
||||||
const found = l.find(x => vMatches(x, word));
|
return removeAyn(removeAShort(removeAccents(s)));
|
||||||
if (!found) throw new Error(`${word} not found by wordQuery`);
|
}
|
||||||
return found;
|
if (category === "verbs") {
|
||||||
});
|
return w.map((word) => {
|
||||||
}
|
const l = words[category];
|
||||||
function vMatches(x: T.VerbEntry, y: string) {
|
const found = l.find((x) => vMatches(x, word));
|
||||||
return (y === x.entry.p)
|
if (!found) throw new Error(`${word} not found by wordQuery`);
|
||||||
|| (queryRemoveAccents(y) === queryRemoveAccents(removeFVarients(x.entry.f)));
|
return found;
|
||||||
}
|
|
||||||
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;
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
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(
|
// console.log(
|
||||||
|
|
Loading…
Reference in New Issue