diff --git a/src/components/EPBuilder.tsx b/src/components/EPBuilder.tsx deleted file mode 100644 index 92204b9..0000000 --- a/src/components/EPBuilder.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { - Types as T, - EPExplorer, -} from "@lingdocs/pashto-inflector"; -import entryFeeder from "../lib/entry-feeder"; - -function EPBuilder({ opts }: { opts: T.TextOptions }) { - return
- -
; -} - -export default EPBuilder; diff --git a/src/components/PhraseBuilder.tsx b/src/components/PhraseBuilder.tsx new file mode 100644 index 0000000..1318407 --- /dev/null +++ b/src/components/PhraseBuilder.tsx @@ -0,0 +1,76 @@ +import { useStickyState } from "@lingdocs/pashto-inflector"; +import { + Types as T, + ButtonSelect, + EPExplorer, + defaultTextOptions as opts, + EntrySelect, + VPExplorer, +} from "@lingdocs/pashto-inflector"; +import { useEffect } from "react"; +import entryFeeder from "../lib/entry-feeder"; + +function PhraseBuilder() { + const [type, setType] = useStickyState<"EP" | "VP">("VP", "phraseBuilderType"); + const [entry, setEntry] = useStickyState( + undefined, + "vEntrySelect", + ); + useEffect(() => { + const params = new URLSearchParams(window.location.search); + const vp = params.get("vp"); + const ep = params.get("ep"); + if (vp) { + setType("VP"); + } else if (ep) { + setType("EP"); + } + }, [setType]); + return
+
+ +
+ {type === "EP" ?
+

Equative Phrase Builder

+ +
+ :
+

Verb Phrase Builder

+
+
Verb:
+ +
+
+ {entry + ? + :
+ Choose a verb to start building +
} +
+
} +
+} + +export default PhraseBuilder; \ No newline at end of file diff --git a/src/components/VPBuilder.tsx b/src/components/VPBuilder.tsx deleted file mode 100644 index 7f5e557..0000000 --- a/src/components/VPBuilder.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { - defaultTextOptions, - VPExplorer, - EntrySelect, - Types as T, -} from "@lingdocs/pashto-inflector"; -import { useStickyState } from "@lingdocs/pashto-inflector"; -import entryFeeder from "../lib/entry-feeder"; - -function VPBuilder() { - const [entry, setEntry] = useStickyState(undefined, "vEntrySelect"); - return
-
-
Verb:
- -
-
- {entry - ? - :
- Choose a verb to start building -
} -
-
; - -} - -export default VPBuilder; diff --git a/src/content/equatives/equative-explorer.mdx b/src/content/equatives/equative-explorer.mdx deleted file mode 100644 index ae65df1..0000000 --- a/src/content/equatives/equative-explorer.mdx +++ /dev/null @@ -1,11 +0,0 @@ ---- -title: Equative Explorer ๐ŸŒŽ -fullWidth: true ---- - -import { - defaultTextOptions, -} from "@lingdocs/pashto-inflector"; -import EPBuilder from "../../components/EPBuilder"; - - diff --git a/src/content/equatives/other-equatives.mdx b/src/content/equatives/other-equatives.mdx index 3c06200..2151c72 100644 --- a/src/content/equatives/other-equatives.mdx +++ b/src/content/equatives/other-equatives.mdx @@ -557,3 +557,7 @@ This is used to talk about:
8. "Would have been" Equative
- (given some hypothetical condition) A would have been B + +
+ +You can explore how all the equatives by browsing the charts and building equative phrases in the phrase builder. \ No newline at end of file diff --git a/src/content/index.ts b/src/content/index.ts index 7dab117..fbafe17 100644 --- a/src/content/index.ts +++ b/src/content/index.ts @@ -16,8 +16,6 @@ import * as presentEquative from "!babel-loader!@lingdocs/mdx-loader!./equatives import * as habitualEquative from "!babel-loader!@lingdocs/mdx-loader!./equatives/habitual-equative.mdx"; // @ts-ignore import * as otherEquatives from "!babel-loader!@lingdocs/mdx-loader!./equatives/other-equatives.mdx"; -// @ts-ignore -import * as equativeExplorer from "!babel-loader!@lingdocs/mdx-loader!./equatives/equative-explorer.mdx"; // @ts-ignore import * as nounsGender from "!babel-loader!@lingdocs/mdx-loader!./nouns/nouns-gender.mdx"; @@ -123,7 +121,7 @@ import * as games from "!babel-loader!@lingdocs/mdx-loader!./games.mdx"; // @ts-ignore import * as pronounPicker from "!babel-loader!@lingdocs/mdx-loader!./practice-tools/pronoun-picker.mdx"; // @ts-ignore -import * as phraseBuilder from "!babel-loader!@lingdocs/mdx-loader!./practice-tools/phrase-builder.mdx"; +import * as phraseBuilder from "!babel-loader!@lingdocs/mdx-loader!./phrase-builder.mdx"; type ChapterSection = { import: any, @@ -144,6 +142,10 @@ const contentTree: (ChapterSection | ChaptersSection)[] = [ import: games, slug: "games", }, + { + import: phraseBuilder, + slug: "phrase-builder", + }, { heading: "Equatives", subdirectory: "equatives", @@ -160,10 +162,6 @@ const contentTree: (ChapterSection | ChaptersSection)[] = [ import: otherEquatives, slug: "other-equatives", }, - { - import: equativeExplorer, - slug: "equative-explorer", - }, ], }, { diff --git a/src/content/phrase-builder.mdx b/src/content/phrase-builder.mdx new file mode 100644 index 0000000..3ab414e --- /dev/null +++ b/src/content/phrase-builder.mdx @@ -0,0 +1,12 @@ +--- +title: Phrase Builder +fullWidth: true +--- + +import PhraseBuilder from "../components/PhraseBuilder"; + +

To build phrases with a full dictionary of words, see the phrase builder included in the LingDocs Pashto Dictionary.

+ +
+ + \ No newline at end of file diff --git a/src/content/practice-tools/phrase-builder.mdx b/src/content/practice-tools/phrase-builder.mdx deleted file mode 100644 index a9876f1..0000000 --- a/src/content/practice-tools/phrase-builder.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: Phrase Builder -fullWidth: true ---- - -import VPBuilder from "../../components/VPBuilder"; - - \ No newline at end of file diff --git a/src/lib/categorize.ts b/src/lib/categorize.ts index 40c42ca..3155bfb 100644 --- a/src/lib/categorize.ts +++ b/src/lib/categorize.ts @@ -62,15 +62,16 @@ export function categorize>( // go through each item in the array and add it to the category based on // the first predicate it matches arr.forEach((item) => { + let placed: boolean = false; for (const p of Object.keys(preds)) { // @ts-ignore if ((preds[p] !== "leftovers") && preds[p](item)) { o[p].push(item); - return; + placed = true; } } // doesn't fit a predicate, add it to the leftovers - if (leftoverKey) { + if (!placed && leftoverKey) { o[leftoverKey].push(item); } }); diff --git a/src/lib/entry-feeder.ts b/src/lib/entry-feeder.ts index f44698c..b20dfc8 100644 --- a/src/lib/entry-feeder.ts +++ b/src/lib/entry-feeder.ts @@ -7,6 +7,8 @@ import { adverbs, } from "../words/words"; +console.log({ locativeAdverbs }); + const entryFeeder: T.EntryFeeder = { nouns, verbs, diff --git a/src/lib/game-utils.ts b/src/lib/game-utils.ts index f563a90..cd449f3 100644 --- a/src/lib/game-utils.ts +++ b/src/lib/game-utils.ts @@ -6,6 +6,7 @@ import { standardizePhonetics, flattenLengths, } from "@lingdocs/pashto-inflector"; +import { removeAShort } from "./misc-helpers"; export function getPercentageDone(current: number, total: number): number { return Math.round( @@ -22,12 +23,14 @@ export function getPercentageDone(current: number, total: number): number { * @param answer - the correct answer in phonetics */ export function compareF(input: string, answer: string): boolean { - return input === (hasAccents(input) ? answer : removeAccents(answer)); + const inp = removeAShort(input); + const ans = removeAShort(answer); + return inp === (hasAccents(inp) ? ans : removeAccents(ans)); } export function comparePs(input: string, answer: T.SingleOrLengthOpts): boolean { if ("long" in answer) { - return comparePs(input, flattenLengths(answer)) + return comparePs(input, flattenLengths(answer)); } if (Array.isArray(answer)) { return answer.some(a => comparePs(input, a)); diff --git a/src/lib/misc-helpers.ts b/src/lib/misc-helpers.ts new file mode 100644 index 0000000..49b8e15 --- /dev/null +++ b/src/lib/misc-helpers.ts @@ -0,0 +1,6 @@ +/** + * Removes ฤƒ and replaces with a + */ +export function removeAShort(s: string): string { + return s.replace(/ฤƒ/g, "a"); +} \ No newline at end of file diff --git a/src/pages/LandingPage.tsx b/src/pages/LandingPage.tsx index 0fba0f4..c020359 100644 --- a/src/pages/LandingPage.tsx +++ b/src/pages/LandingPage.tsx @@ -33,7 +33,7 @@ const content: { title: "Experiment with the Phrase Builder ๐Ÿงช", subTitle: "Interactive Phrase Structure Analysis", description: "Build your own phrases in the interactive phrase builder. See how the words change and interact as you explore different tenses and forms.", - link: "/practice-tools/phrase-builder/", + link: "/phrase-builder/", linkDescription: "Phrase Builder", }, ]; diff --git a/src/words/words.ts b/src/words/words.ts index 883ebe5..93bddd3 100644 --- a/src/words/words.ts +++ b/src/words/words.ts @@ -6,6 +6,7 @@ import { Types as T, } from "@lingdocs/pashto-inflector"; import { categorize } from "../lib/categorize"; +import { removeAShort } from "../lib/misc-helpers"; // TODO: BIG ISSUE WITH THE LOC ADVERBS BEING LUMPED INTO THE ADVERBS! @@ -36,6 +37,9 @@ 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]; @@ -46,11 +50,11 @@ export function wordQuery( } function vMatches(x: T.VerbEntry, y: string) { return (y === x.entry.p) - || (removeAccents(y) === removeAccents(removeFVarients(x.entry.f))); + || (queryRemoveAccents(y) === queryRemoveAccents(removeFVarients(x.entry.f))); } function wMatches(x: T.DictionaryEntry, y: string) { return (y === x.p) - || (removeAccents(y) === removeAccents(removeFVarients(x.f))); + || (queryRemoveAccents(y) === queryRemoveAccents(removeFVarients(x.f))); } return w.map(word => { const l = words[category];