add getInflectionCategory

This commit is contained in:
lingdocs 2022-09-12 18:56:37 +04:00
parent 54b42b7e70
commit cc2e5fe0bc
4 changed files with 40 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@lingdocs/pashto-inflector", "name": "@lingdocs/pashto-inflector",
"version": "3.9.0", "version": "3.9.1",
"author": "lingdocs.com", "author": "lingdocs.com",
"description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations",
"homepage": "https://verbs.lingdocs.com", "homepage": "https://verbs.lingdocs.com",

View File

@ -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;
}

View File

@ -39,6 +39,7 @@ import Block, { NPBlock, APBlock } from "./components/blocks/Block";
import { roleIcon } from "./components/vp-explorer/VPExplorerExplanationModal"; import { roleIcon } from "./components/vp-explorer/VPExplorerExplanationModal";
import CompiledPTextDisplay from "./components/CompiledPTextDisplay"; import CompiledPTextDisplay from "./components/CompiledPTextDisplay";
import RenderedBlocksDisplay from "./components/RenderedBlocksDisplay"; import RenderedBlocksDisplay from "./components/RenderedBlocksDisplay";
import { getInflectionCategory } from "./lib/inflection-category";
import { import {
makePsString, makePsString,
removeFVarients, removeFVarients,
@ -261,6 +262,7 @@ export {
blank, blank,
kidsBlank, kidsBlank,
isPashtoScript, isPashtoScript,
getInflectionCategory,
// protobuf helpers // protobuf helpers
readDictionary, readDictionary,
writeDictionary, writeDictionary,

View File

@ -500,6 +500,16 @@ export type VerbEntry = {
complement?: DictionaryEntry, complement?: DictionaryEntry,
}; };
export enum InflectionCategory {
None = 0,
Basic = 1,
UnstressedEy = 2,
StressedEy = 3,
Pashtun = 4,
Squish = 5,
FemInanEe = 6,
};
export type SingularEntry<T extends NounEntry> = T & { __brand7: "a singular noun - as opposed to an always plural noun" }; export type SingularEntry<T extends NounEntry> = T & { __brand7: "a singular noun - as opposed to an always plural noun" };
export type PluralNounEntry<T extends NounEntry> = T & { __brand7: "a noun that is always plural" }; export type PluralNounEntry<T extends NounEntry> = T & { __brand7: "a noun that is always plural" };