handle sandwiches in word split

This commit is contained in:
adueck 2023-01-26 14:52:42 +05:00
parent 752482b00a
commit 488966e0fd
6 changed files with 21 additions and 12 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "pashto-inflector",
"version": "5.7.1",
"version": "5.7.2",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "pashto-inflector",
"version": "5.7.1",
"version": "5.7.2",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {

View File

@ -1,6 +1,6 @@
{
"name": "pashto-inflector",
"version": "5.7.1",
"version": "5.7.2",
"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",

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/ps-react",
"version": "5.7.1",
"version": "5.7.2",
"description": "Pashto inflector library module with React components",
"main": "dist/components/library.js",
"module": "dist/components/library.js",

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/inflect",
"version": "5.7.1",
"version": "5.7.2",
"description": "Pashto inflector library",
"main": "dist/index.js",
"types": "dist/lib/library.d.ts",

View File

@ -86,6 +86,10 @@ const toTest: {
f: "kawul",
}],
},
{
input: { p: "د ... په شان", f: "du ... pu shaan" },
result: [{ p: "د", f: "du" }, { p: "په", f: "pu" }, { p: "شان", f: "shaan" }],
},
];
test("splitPsString should work", () => {

View File

@ -34,9 +34,15 @@ export function splitPsString(ps: T.PsStringNoFVars): T.PsWord[] {
fIndex++;
}
while (pIndex < pWords.length && fIndex < fWords.length) {
if (fWords[fIndex] === "..." && pWords[pIndex] === "...") {
pIndex++;
fIndex++;
continue;
}
if (fWords[fIndex].includes("-")) {
processHyphen();
} else {
continue;
}
psWords.push({
p: pWords[pIndex],
f: fWords[fIndex],
@ -44,7 +50,6 @@ export function splitPsString(ps: T.PsStringNoFVars): T.PsWord[] {
pIndex++;
fIndex++;
}
}
// should have processed all the p an f words
if (pIndex !== pWords.length || fIndex !== fWords.length) {
throw new Error("spacing discrepency");