diff --git a/package.json b/package.json index 61e951e..5b8f07c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "3.9.0", + "version": "3.9.1", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", diff --git a/src/lib/inflection-category.ts b/src/lib/inflection-category.ts new file mode 100644 index 0000000..f8dc009 --- /dev/null +++ b/src/lib/inflection-category.ts @@ -0,0 +1,27 @@ +import { AdjectiveEntry, InflectionCategory, NounEntry } from "../types"; +import { + isFemNounEntry, + isNounEntry, + isPattern1Entry, + isPattern2Entry, + isPattern3Entry, + isPattern4Entry, + isPattern5Entry, + isPattern6FemEntry, +} from "./type-predicates"; + +export function getInflectionCategory(e: NounEntry | AdjectiveEntry): InflectionCategory { + return isPattern1Entry(e) + ? InflectionCategory.Basic + : isPattern2Entry(e) + ? InflectionCategory.UnstressedEy + : isPattern3Entry(e) + ? InflectionCategory.StressedEy + : isPattern4Entry(e) + ? InflectionCategory.Pashtun + : isPattern5Entry(e) + ? InflectionCategory.Squish + : isNounEntry(e) && isFemNounEntry(e) && isPattern6FemEntry(e) + ? InflectionCategory.FemInanEe + : InflectionCategory.None; +} \ No newline at end of file diff --git a/src/library.ts b/src/library.ts index 97f1139..fc29f4e 100644 --- a/src/library.ts +++ b/src/library.ts @@ -39,6 +39,7 @@ import Block, { NPBlock, APBlock } from "./components/blocks/Block"; import { roleIcon } from "./components/vp-explorer/VPExplorerExplanationModal"; import CompiledPTextDisplay from "./components/CompiledPTextDisplay"; import RenderedBlocksDisplay from "./components/RenderedBlocksDisplay"; +import { getInflectionCategory } from "./lib/inflection-category"; import { makePsString, removeFVarients, @@ -261,6 +262,7 @@ export { blank, kidsBlank, isPashtoScript, + getInflectionCategory, // protobuf helpers readDictionary, writeDictionary, diff --git a/src/types.ts b/src/types.ts index 298d0f8..1f0433d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -500,6 +500,16 @@ export type VerbEntry = { complement?: DictionaryEntry, }; +export enum InflectionCategory { + None = 0, + Basic = 1, + UnstressedEy = 2, + StressedEy = 3, + Pashtun = 4, + Squish = 5, + FemInanEe = 6, +}; + export type SingularEntry = T & { __brand7: "a singular noun - as opposed to an always plural noun" }; export type PluralNounEntry = T & { __brand7: "a noun that is always plural" };