also added validation for all the variations in the optional fields
This commit is contained in:
parent
b59709bc1c
commit
66989dee67
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.6.0",
|
"version": "5.7.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.6.0",
|
"version": "5.7.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "pashto-inflector",
|
"name": "pashto-inflector",
|
||||||
"version": "5.6.0",
|
"version": "5.7.0",
|
||||||
"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.6.0",
|
"version": "5.7.0",
|
||||||
"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.6.0",
|
"version": "5.7.0",
|
||||||
"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",
|
||||||
|
|
|
@ -253,6 +253,32 @@ const toTest: {
|
||||||
erroneousFields: ["f"],
|
erroneousFields: ["f"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
input: {"ts":1527815870,"i":183,"p":"اثر","f":"asar","g":"asar","e":"influence, impression, tracks, affect","r":4,"c":"n. m.","app":"اثرات, آثار","apf":"asráat, aasáar"},
|
||||||
|
output: { ok: true },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: {"ts":1527815870,"i":183,"p":"اثر","f":"asar","g":"asar","e":"influence, impression, tracks, affect","r":4,"c":"n. m.","app":"اثرات, آثار","apf":"asráat, aa sáar"},
|
||||||
|
output: {
|
||||||
|
errors: ["spacing discrepency between app and apf"],
|
||||||
|
p: "اثر",
|
||||||
|
f: "asar",
|
||||||
|
e: "influence, impression, tracks, affect",
|
||||||
|
ts: 1527815870,
|
||||||
|
erroneousFields: ["app", "apf"],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
input: {"ts":1527815870,"i":183,"p":"اثر","f":"asar","g":"asar","e":"influence, impression, tracks, affect","r":4,"c":"n. m.","app":"اثرات, آثار","apf":"asráat"},
|
||||||
|
output: {
|
||||||
|
errors: ["difference in variation length between app and apf", "script and phonetics do not match for app and apf"],
|
||||||
|
p: "اثر",
|
||||||
|
f: "asar",
|
||||||
|
e: "influence, impression, tracks, affect",
|
||||||
|
ts: 1527815870,
|
||||||
|
erroneousFields: ["app", "apf"],
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
test("validateEntry should work", () => {
|
test("validateEntry should work", () => {
|
||||||
|
|
|
@ -83,9 +83,24 @@ export function validateEntry(entry: T.DictionaryEntry): T.DictionaryEntryError
|
||||||
erroneousFields.add(errField);
|
erroneousFields.add(errField);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!isRequired && p.includes(", ")) {
|
||||||
|
const pVars = p.split(", ");
|
||||||
|
const fVars = f.split(", ");
|
||||||
|
if (pVars.length !== fVars.length) {
|
||||||
|
errors.add(`difference in variation length between ${pField} and ${fField}`);
|
||||||
|
erroneousFields.add(pField);
|
||||||
|
erroneousFields.add(fField);
|
||||||
|
}
|
||||||
|
pVars.forEach((pVar, i) => {
|
||||||
|
checkPhoneticsAndSpacing(pVar, fVars[i] || "");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
checkPhoneticsAndSpacing(p, f);
|
||||||
|
}
|
||||||
|
function checkPhoneticsAndSpacing(p: string, f: string) {
|
||||||
if (!phoneticsToDiacritics(p, f) && !entry.diacExcept) {
|
if (!phoneticsToDiacritics(p, f) && !entry.diacExcept) {
|
||||||
errors.add(`script and phonetics do not match for ${pField} and ${fField}`);
|
errors.add(`script and phonetics do not match for ${pField} and ${fField}`);
|
||||||
erroneousFields.add(pField)
|
erroneousFields.add(pField);
|
||||||
erroneousFields.add(fField);
|
erroneousFields.add(fField);
|
||||||
}
|
}
|
||||||
const firstF = removeFVarients(f);
|
const firstF = removeFVarients(f);
|
||||||
|
@ -111,6 +126,7 @@ export function validateEntry(entry: T.DictionaryEntry): T.DictionaryEntryError
|
||||||
erroneousFields.add(fField);
|
erroneousFields.add(fField);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if ((entry.separationAtP && !entry.separationAtF)) {
|
if ((entry.separationAtP && !entry.separationAtF)) {
|
||||||
errors.add("missing separationAtF");
|
errors.add("missing separationAtF");
|
||||||
|
|
Loading…
Reference in New Issue