countsylabbles
This commit is contained in:
parent
9e094105c0
commit
09d9ea5737
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@lingdocs/pashto-inflector",
|
"name": "@lingdocs/pashto-inflector",
|
||||||
"version": "1.2.7",
|
"version": "1.2.8",
|
||||||
"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",
|
||||||
|
|
|
@ -14,6 +14,7 @@ import {
|
||||||
accentOnNFromEnd,
|
accentOnNFromEnd,
|
||||||
splitUpSyllables,
|
splitUpSyllables,
|
||||||
hasAccents,
|
hasAccents,
|
||||||
|
countSyllables,
|
||||||
} from "./accent-helpers";
|
} from "./accent-helpers";
|
||||||
|
|
||||||
const toAccentFront = [
|
const toAccentFront = [
|
||||||
|
@ -60,6 +61,16 @@ test(`splitUpSyllables should work`, () => {
|
||||||
expect(splitUpSyllables("akheestul")).toEqual(["akh", "eest", "ul"]);
|
expect(splitUpSyllables("akheestul")).toEqual(["akh", "eest", "ul"]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("countSyllables", () => {
|
||||||
|
expect(countSyllables("saRéy")).toEqual(2);
|
||||||
|
expect(countSyllables("saRey")).toEqual(2);
|
||||||
|
expect(countSyllables("zRú")).toEqual(1);
|
||||||
|
expect(countSyllables("zRu")).toEqual(1);
|
||||||
|
expect(countSyllables("zRU")).toEqual(1);
|
||||||
|
expect(countSyllables("tbtkz")).toEqual(0);
|
||||||
|
expect(countSyllables({ p: "اونۍ", f: "onúy, ownúy" })).toEqual(2);
|
||||||
|
});
|
||||||
|
|
||||||
test(`accentOnFSylsOnNFromEnd should work`, () => {
|
test(`accentOnFSylsOnNFromEnd should work`, () => {
|
||||||
expect(accentFSylsOnNFromEnd(["pu", "xtaa", "nu"], 0)).toBe("puxtaanú");
|
expect(accentFSylsOnNFromEnd(["pu", "xtaa", "nu"], 0)).toBe("puxtaanú");
|
||||||
expect(accentFSylsOnNFromEnd(["leed", "ul", "ey"], 1)).toBe("leedúley");
|
expect(accentFSylsOnNFromEnd(["leed", "ul", "ey"], 1)).toBe("leedúley");
|
||||||
|
|
|
@ -55,7 +55,7 @@ export function accentPastParticiple(s: T.PsString): T.PsString {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function splitUpSyllables(f: string): string[] {
|
export function splitUpSyllables(f: string): string[] {
|
||||||
return f.match(/ |([^a|e|i|o|u| ]*(aa|a|ey|ee|e|oo|o|i|u)[^a|e|i|o|u| ]*)/g) || [] as string[];
|
return f.match(/ |([^a|e|i|o|u| ]*(aa|a|ey|ee|e|oo|o|i|u)[^a|e|i|o|u| ]*)/ig) || [] as string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export function countSyllables(f: T.PsString | string): number {
|
export function countSyllables(f: T.PsString | string): number {
|
||||||
|
|
Loading…
Reference in New Issue