add a filed to entries for audio

This commit is contained in:
adueck 2023-12-04 14:04:44 +04:00
parent ef120b13aa
commit 17fd8a4d05
9 changed files with 163 additions and 120 deletions

4
package-lock.json generated
View File

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

View File

@ -1,6 +1,6 @@
{
"name": "pashto-inflector",
"version": "6.0.12",
"version": "7.0.0",
"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,12 +1,12 @@
{
"name": "@lingdocs/ps-react",
"version": "6.0.12",
"version": "7.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@lingdocs/ps-react",
"version": "6.0.12",
"version": "7.0.0",
"license": "MIT",
"dependencies": {
"@formkit/auto-animate": "^1.0.0-beta.3",

View File

@ -1,6 +1,6 @@
{
"name": "@lingdocs/ps-react",
"version": "6.0.12",
"version": "7.0.0",
"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": "6.0.12",
"version": "7.0.0",
"description": "Pashto inflector library",
"main": "dist/index.js",
"types": "dist/lib/library.d.ts",

View File

@ -1,12 +1,23 @@
// eslint-disable-next-line
'use strict'; // code generated by pbf v3.2.1
"use strict"; // code generated by pbf v3.2.1
// DictionaryInfo ========================================
var DictionaryInfo = exports.DictionaryInfo = {};
var DictionaryInfo = (exports.DictionaryInfo = {});
DictionaryInfo.read = function (pbf, end) {
return pbf.readFields(DictionaryInfo._readField, {title: "", license: "", release: 0, numberOfEntries: 0, url: "", infoUrl: ""}, end);
return pbf.readFields(
DictionaryInfo._readField,
{
title: "",
license: "",
release: 0,
numberOfEntries: 0,
url: "",
infoUrl: "",
},
end
);
};
DictionaryInfo._readField = function (tag, obj, pbf) {
if (tag === 1) obj.title = pbf.readString();
@ -27,10 +38,14 @@ DictionaryInfo.write = function (obj, pbf) {
// Entry ========================================
var Entry = exports.Entry = {};
var Entry = (exports.Entry = {});
Entry.read = function (pbf, end) {
return pbf.readFields(Entry._readField, {ts: 0, i: 0, p: "", f: "", g: "", e: ""}, end);
return pbf.readFields(
Entry._readField,
{ ts: 0, i: 0, p: "", f: "", g: "", e: "" },
end
);
};
Entry._readField = function (tag, obj, pbf) {
if (tag === 1) obj.ts = pbf.readVarint(true);
@ -69,6 +84,7 @@ Entry._readField = function (tag, obj, pbf) {
else if (tag === 34) obj.diacExcept = pbf.readBoolean();
else if (tag === 35) obj.ec = pbf.readString();
else if (tag === 36) obj.ep = pbf.readString();
else if (tag === 37) obj.a = pbf.readVarint();
};
Entry.write = function (obj, pbf) {
if (obj.ts) pbf.writeVarintField(1, obj.ts);
@ -107,20 +123,29 @@ Entry.write = function (obj, pbf) {
if (obj.diacExcept) pbf.writeBooleanField(34, obj.diacExcept);
if (obj.ec) pbf.writeStringField(35, obj.ec);
if (obj.ep) pbf.writeStringField(36, obj.ep);
if (obj.a) pbf.writeVarintField(37, obj.a);
};
// Dictionary ========================================
var Dictionary = exports.Dictionary = {};
var Dictionary = (exports.Dictionary = {});
Dictionary.read = function (pbf, end) {
return pbf.readFields(Dictionary._readField, {info: null, entries: []}, end);
return pbf.readFields(
Dictionary._readField,
{ info: null, entries: [] },
end
);
};
Dictionary._readField = function (tag, obj, pbf) {
if (tag === 1) obj.info = DictionaryInfo.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 2) obj.entries.push(Entry.read(pbf, pbf.readVarint() + pbf.pos));
if (tag === 1)
obj.info = DictionaryInfo.read(pbf, pbf.readVarint() + pbf.pos);
else if (tag === 2)
obj.entries.push(Entry.read(pbf, pbf.readVarint() + pbf.pos));
};
Dictionary.write = function (obj, pbf) {
if (obj.info) pbf.writeMessage(1, DictionaryInfo.write, obj.info);
if (obj.entries) for (var i = 0; i < obj.entries.length; i++) pbf.writeMessage(2, Entry.write, obj.entries[i]);
if (obj.entries)
for (var i = 0; i < obj.entries.length; i++)
pbf.writeMessage(2, Entry.write, obj.entries[i]);
};

View File

@ -46,6 +46,7 @@ message Entry {
bool diacExcept = 34;
string ec = 35;
string ep = 36;
int32 a = 37;
}
message Dictionary {

View File

@ -18,11 +18,25 @@ const sampleDictionaryInfo: T.DictionaryInfo = {
const sampleDictionary: T.Dictionary = {
info: sampleDictionaryInfo,
entries: [
{"i":616,"ts":1527813108,"p":"اظهار","f":"izháar","g":"izhaar","e":"expression, statement, declaration","c":"n. m.","ec":"cool"},
{
i: 616,
ts: 1527813108,
p: "اظهار",
f: "izháar",
g: "izhaar",
e: "expression, statement, declaration",
c: "n. m.",
ec: "cool",
a: 1,
},
],
}
};
test("should encode and decode", () => {
expect(readDictionaryInfo(writeDictionaryInfo(sampleDictionaryInfo) as Uint8Array)).toEqual(sampleDictionaryInfo);
expect(readDictionary(writeDictionary(sampleDictionary) as Uint8Array)).toEqual(sampleDictionary);
expect(
readDictionaryInfo(writeDictionaryInfo(sampleDictionaryInfo) as Uint8Array)
).toEqual(sampleDictionaryInfo);
expect(
readDictionary(writeDictionary(sampleDictionary) as Uint8Array)
).toEqual(sampleDictionary);
});

View File

@ -149,6 +149,9 @@ export type DictionaryEntry = {
ec?: string;
/** the English partical of a English phrasal verb - or the english irregular plural of a noun */
ep?: string;
/** If there is a recording [TS NUMBER].mp3 available for this entry, marked true with a 1 */
a?: number;
};
export type DictionaryEntryNoFVars = DictionaryEntry & {