humanReadableTense

This commit is contained in:
lingdocs 2022-08-29 17:47:51 +04:00
parent 3effddfb64
commit ad0538c737
3 changed files with 68 additions and 1 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/pashto-inflector",
"version": "3.8.0",
"version": "3.8.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",

65
src/lib/human-readable.ts Normal file
View File

@ -0,0 +1,65 @@
import * as T from "../types";
import {
isModalTense,
isPerfectTense,
isImperativeTense,
} from "./type-predicates";
function humanReadableVerbTense(tense: T.VerbTense): string {
return tense === "presentVerb"
? "present"
: tense === "subjunctiveVerb"
? "subjunctive"
: tense === "imperfectiveFuture"
? "imperfective future"
: tense === "perfectiveFuture"
? "perfective future"
: tense === "perfectivePast"
? "simple past"
: tense === "imperfectivePast"
? "continuous past"
: tense === "habitualImperfectivePast"
? "habitual simple past"
// : tense === "habitualPerfectivePast"
: "habitual continuous past";
}
function humanReadableModalTense(tense: T.ModalTense): string {
const base = tense.replace("Modal", "") as T.VerbTense;
return `${humanReadableVerbTense(base)} ability`;
}
function humanReadablePerfectTense(tense: T.PerfectTense): string {
return tense === "pastPerfect"
? "past perfect"
: tense === "futurePerfect"
? "future perfect"
: tense === "presentPerfect"
? "present perfect"
: tense === "habitualPerfect"
? "habitual perfect"
: tense === "subjunctivePerfect"
? "subjunctive perfect"
: tense === "pastSubjunctivePerfect"
? "past subjunctive perfect"
: tense === "wouldBePerfect"
? `"would be" perfect`
// : tense === "wouldHaveBeenPerfect"
: `"would have been" perfect`
}
function humanReadableImperativeTense(tense: T.ImperativeTense): string {
return tense === "imperfectiveImperative"
? "imperfective imperative"
: "perfective imperative";
}
export function humanReadableTense(tense: T.VerbTense | T.PerfectTense | T.ModalTense | T.ImperativeTense): string {
return isModalTense(tense)
? humanReadableModalTense(tense)
: isPerfectTense(tense)
? humanReadablePerfectTense(tense)
: isImperativeTense(tense)
? humanReadableImperativeTense(tense as T.ImperativeTense)
: humanReadableVerbTense(tense);
}

View File

@ -157,6 +157,7 @@ import {
import {
renderAPSelection,
} from "./lib/phrase-building/render-ap";
import { humanReadableTense } from "./lib/human-readable";
import NPPicker from "./components/np-picker/NPPicker";
import EPPicker from "./components/ep-explorer/EPPicker";
import EPExplorer from "./components/ep-explorer/EPExplorer";
@ -243,6 +244,7 @@ export {
getPashtoFromRendered,
renderAPSelection,
getEnglishVerb,
humanReadableTense,
roleIcon,
vpsReducer,
makeVPSelectionState,