From 488966e0fde21d660c19d5a505f15a74099146b0 Mon Sep 17 00:00:00 2001 From: adueck Date: Thu, 26 Jan 2023 14:52:42 +0500 Subject: [PATCH] handle sandwiches in word split --- package-lock.json | 4 ++-- package.json | 2 +- src/components/package.json | 2 +- src/lib/package.json | 2 +- src/lib/src/splitPsString.test.ts | 4 ++++ src/lib/src/splitPsString.ts | 19 ++++++++++++------- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index 823c27e..aad7780 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/package.json b/package.json index 948c18f..5a89247 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/components/package.json b/src/components/package.json index f53fd1d..a5c7c79 100644 --- a/src/components/package.json +++ b/src/components/package.json @@ -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", diff --git a/src/lib/package.json b/src/lib/package.json index b500072..8d4f8b3 100644 --- a/src/lib/package.json +++ b/src/lib/package.json @@ -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", diff --git a/src/lib/src/splitPsString.test.ts b/src/lib/src/splitPsString.test.ts index b77fd56..230d313 100644 --- a/src/lib/src/splitPsString.test.ts +++ b/src/lib/src/splitPsString.test.ts @@ -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", () => { diff --git a/src/lib/src/splitPsString.ts b/src/lib/src/splitPsString.ts index 6da783b..834be0d 100644 --- a/src/lib/src/splitPsString.ts +++ b/src/lib/src/splitPsString.ts @@ -34,16 +34,21 @@ export function splitPsString(ps: T.PsStringNoFVars): T.PsWord[] { fIndex++; } while (pIndex < pWords.length && fIndex < fWords.length) { - if (fWords[fIndex].includes("-")) { - processHyphen(); - } else { - psWords.push({ - p: pWords[pIndex], - f: fWords[fIndex], - }); + if (fWords[fIndex] === "..." && pWords[pIndex] === "...") { pIndex++; fIndex++; + continue; } + if (fWords[fIndex].includes("-")) { + processHyphen(); + continue; + } + psWords.push({ + p: pWords[pIndex], + f: fWords[fIndex], + }); + pIndex++; + fIndex++; } // should have processed all the p an f words if (pIndex !== pWords.length || fIndex !== fWords.length) {