inflecting adverbs
This commit is contained in:
parent
3303920b8c
commit
64265e9e20
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.1.3",
|
"version": "5.1.5",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.1.3",
|
"version": "5.1.5",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.1.4",
|
"version": "5.1.5",
|
||||||
"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",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/ps-react",
|
"name": "@lingdocs/ps-react",
|
||||||
"version": "5.1.3",
|
"version": "5.1.4",
|
||||||
"description": "Pashto inflector library module with React components",
|
"description": "Pashto inflector library module with React components",
|
||||||
"main": "dist/components/library.js",
|
"main": "dist/components/library.js",
|
||||||
"module": "dist/components/library.js",
|
"module": "dist/components/library.js",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/inflect",
|
"name": "@lingdocs/inflect",
|
||||||
"version": "5.1.3",
|
"version": "5.1.4",
|
||||||
"description": "Pashto inflector library",
|
"description": "Pashto inflector library",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/lib/library.d.ts",
|
"types": "dist/lib/library.d.ts",
|
||||||
|
|
|
@ -19,7 +19,7 @@ function chooseInflection(inflections: T.UnisexSet<T.InflectionSet>, pers: T.Per
|
||||||
return inflections[gender][infNumber];
|
return inflections[gender][infNumber];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function inflectAdjective(a: T.AdjectiveSelection, person: T.Person, inflected: boolean): T.ArrayOneOrMore<T.PsString> {
|
export function inflectAdvAdj(a: T.AdjectiveSelection | T.AdverbSelection, person: T.Person, inflected: boolean): T.ArrayOneOrMore<T.PsString> {
|
||||||
const infs = inflectWord(a.entry);
|
const infs = inflectWord(a.entry);
|
||||||
if (!infs) {
|
if (!infs) {
|
||||||
return [psStringFromEntry(a.entry)];
|
return [psStringFromEntry(a.entry)];
|
||||||
|
@ -30,6 +30,10 @@ export function inflectAdjective(a: T.AdjectiveSelection, person: T.Person, infl
|
||||||
return chooseInflection(infs.inflections, person, inflected);
|
return chooseInflection(infs.inflections, person, inflected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function inflectAdjective(a: T.AdjectiveSelection, person: T.Person, inflected: boolean): T.ArrayOneOrMore<T.PsString> {
|
||||||
|
return inflectAdvAdj(a, person, inflected)
|
||||||
|
}
|
||||||
|
|
||||||
export function renderAdjectiveSelection(a: T.AdjectiveSelection, person: T.Person, inflected: boolean, isLocationSingSandwich?: boolean): T.Rendered<T.AdjectiveSelection> {
|
export function renderAdjectiveSelection(a: T.AdjectiveSelection, person: T.Person, inflected: boolean, isLocationSingSandwich?: boolean): T.Rendered<T.AdjectiveSelection> {
|
||||||
const eWord = getEnglishWord(a.entry);
|
const eWord = getEnglishWord(a.entry);
|
||||||
const e = !eWord
|
const e = !eWord
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
import * as T from "../../../types";
|
import * as T from "../../../types";
|
||||||
import { getEnglishWord } from "../get-english-word";
|
import { getEnglishWord } from "../get-english-word";
|
||||||
import { psStringFromEntry } from "../p-text-helpers";
|
import { psStringFromEntry } from "../p-text-helpers";
|
||||||
import { renderAdverbSelection } from "./render-ep";
|
import { isAdjectiveEntry } from "../type-predicates";
|
||||||
|
import { inflectAdvAdj } from "./render-adj";
|
||||||
import { renderSandwich } from "./render-sandwich";
|
import { renderSandwich } from "./render-sandwich";
|
||||||
|
|
||||||
export function renderAPSelection({ selection }: T.APSelection): T.Rendered<T.APSelection> {
|
export function renderAPSelection({ selection }: T.APSelection, person: T.Person): T.Rendered<T.APSelection> {
|
||||||
if (selection.type === "sandwich") {
|
if (selection.type === "sandwich") {
|
||||||
return {
|
return {
|
||||||
type: "AP",
|
type: "AP",
|
||||||
|
@ -13,7 +14,7 @@ export function renderAPSelection({ selection }: T.APSelection): T.Rendered<T.AP
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: "AP",
|
type: "AP",
|
||||||
selection: renderAdverbSelection(selection),
|
selection: renderAdverbSelection(selection, person),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,3 +34,21 @@ export function renderLocativeAdverbSelection({ entry }: T.LocativeAdverbSelecti
|
||||||
role: "none",
|
role: "none",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function renderAdverbSelection(a: T.AdverbSelection, person: T.Person): T.Rendered<T.AdverbSelection> {
|
||||||
|
const ew = getEnglishWord(a.entry);
|
||||||
|
const e = typeof ew === "object"
|
||||||
|
? (ew.singular || "")
|
||||||
|
: !ew
|
||||||
|
? ""
|
||||||
|
: ew;
|
||||||
|
return {
|
||||||
|
type: "adverb",
|
||||||
|
entry: a.entry,
|
||||||
|
ps: isAdjectiveEntry(a.entry)
|
||||||
|
? inflectAdvAdj(a, person, false)
|
||||||
|
: [psStringFromEntry(a.entry)],
|
||||||
|
person,
|
||||||
|
e,
|
||||||
|
};
|
||||||
|
}
|
|
@ -6,8 +6,7 @@ import {
|
||||||
import { renderNPSelection } from "./render-np";
|
import { renderNPSelection } from "./render-np";
|
||||||
import { getPersonFromVerbForm } from "../misc-helpers";
|
import { getPersonFromVerbForm } from "../misc-helpers";
|
||||||
import { getVerbBlockPosFromPerson } from "../misc-helpers";
|
import { getVerbBlockPosFromPerson } from "../misc-helpers";
|
||||||
import { getEnglishWord } from "../get-english-word";
|
import { renderAdverbSelection } from "./render-ap";
|
||||||
import { psStringFromEntry } from "../p-text-helpers";
|
|
||||||
import { renderSandwich } from "./render-sandwich";
|
import { renderSandwich } from "./render-sandwich";
|
||||||
import { EPSBlocksAreComplete, getSubjectSelection, makeBlock, makeKid } from "./blocks-utils";
|
import { EPSBlocksAreComplete, getSubjectSelection, makeBlock, makeKid } from "./blocks-utils";
|
||||||
import { removeAccentsWLength } from "../accent-helpers";
|
import { removeAccentsWLength } from "../accent-helpers";
|
||||||
|
@ -102,12 +101,14 @@ export function getEquativeForm(tense: T.EquativeTense): { hasBa: boolean, form:
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderEPSBlocks(blocks: T.EPSBlockComplete[]): T.Block[] {
|
function renderEPSBlocks(blocks: T.EPSBlockComplete[]): T.Block[] {
|
||||||
|
const subject = getSubjectSelection(blocks).selection;
|
||||||
|
const subjectPerson = getPersonFromNP(subject);
|
||||||
return blocks.map(({ block }): T.Block => {
|
return blocks.map(({ block }): T.Block => {
|
||||||
if (block.type === "AP") {
|
if (block.type === "AP") {
|
||||||
if (block.selection.type === "adverb") {
|
if (block.selection.type === "adverb") {
|
||||||
return makeBlock({
|
return makeBlock({
|
||||||
type: "AP",
|
type: "AP",
|
||||||
selection: renderAdverbSelection(block.selection),
|
selection: renderAdverbSelection(block.selection, subjectPerson),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// if (block.selection.type === "sandwich") {
|
// if (block.selection.type === "sandwich") {
|
||||||
|
@ -135,21 +136,6 @@ function renderEquative(es: T.EquativeSelection, person: T.Person): T.EquativeRe
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function renderAdverbSelection(a: T.AdverbSelection): T.Rendered<T.AdverbSelection> {
|
|
||||||
const ew = getEnglishWord(a.entry);
|
|
||||||
const e = typeof ew === "object"
|
|
||||||
? (ew.singular || "")
|
|
||||||
: !ew
|
|
||||||
? ""
|
|
||||||
: ew;
|
|
||||||
return {
|
|
||||||
type: "adverb",
|
|
||||||
entry: a.entry,
|
|
||||||
ps: [psStringFromEntry(a.entry)],
|
|
||||||
e,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const equativeBuilders: Record<T.EquativeTense, (p: T.Person, n: boolean) => string[]> = {
|
const equativeBuilders: Record<T.EquativeTense, (p: T.Person, n: boolean) => string[]> = {
|
||||||
present: (p, n) => {
|
present: (p, n) => {
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -281,12 +281,18 @@ function shrinkServant(np: T.NPSelection): T.MiniPronoun {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderVPBlocks(blocks: T.VPSBlockComplete[], config: {
|
function renderVPBlocks(blocks: T.VPSBlockComplete[], config: {
|
||||||
inflectSubject: boolean,
|
inflectSubject: boolean,
|
||||||
inflectObject: boolean,
|
inflectObject: boolean,
|
||||||
king: "subject" | "object",
|
king: "subject" | "object",
|
||||||
complementPerson: T.Person | undefined,
|
complementPerson: T.Person | undefined,
|
||||||
}): T.Block[] {
|
}): T.Block[] {
|
||||||
|
const object = getObjectSelection(blocks);
|
||||||
|
const subject = getSubjectSelection(blocks);
|
||||||
|
const adverbPerson = typeof object.selection === "object"
|
||||||
|
? getPersonFromNP(object.selection)
|
||||||
|
: getPersonFromNP(subject.selection);
|
||||||
return blocks.reduce((blocks, { block }): T.Block[] => {
|
return blocks.reduce((blocks, { block }): T.Block[] => {
|
||||||
if (block.type === "subjectSelection") {
|
if (block.type === "subjectSelection") {
|
||||||
return [
|
return [
|
||||||
|
@ -320,7 +326,7 @@ function renderVPBlocks(blocks: T.VPSBlockComplete[], config: {
|
||||||
if (block.type === "AP") {
|
if (block.type === "AP") {
|
||||||
return [
|
return [
|
||||||
...blocks,
|
...blocks,
|
||||||
makeBlock(renderAPSelection(block)),
|
makeBlock(renderAPSelection(block, adverbPerson ?? 0)),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -744,7 +744,7 @@ export type Rendered<
|
||||||
: T extends APSelection
|
: T extends APSelection
|
||||||
? {
|
? {
|
||||||
type: "AP",
|
type: "AP",
|
||||||
selection: Rendered<APSelection["selection"]>
|
selection: Rendered<APSelection["selection"]>,
|
||||||
}
|
}
|
||||||
: T extends ComplementSelection
|
: T extends ComplementSelection
|
||||||
? {
|
? {
|
||||||
|
@ -768,6 +768,7 @@ export type Rendered<
|
||||||
? {
|
? {
|
||||||
type: "adverb",
|
type: "adverb",
|
||||||
entry: AdverbEntry,
|
entry: AdverbEntry,
|
||||||
|
person: Person,
|
||||||
ps: PsString[],
|
ps: PsString[],
|
||||||
e?: string,
|
e?: string,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue