update for r field

This commit is contained in:
adueck 2022-11-25 19:25:40 +05:00
parent 68c1a70ecc
commit ab865b9fe2
8 changed files with 43 additions and 42 deletions

View File

@ -9,7 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"@lingdocs/inflect": "5.1.10",
"@lingdocs/inflect": "5.2.1",
"base64url": "^3.0.1",
"bcryptjs": "^2.4.3",
"connect-redis": "^6.0.0",
@ -124,9 +124,9 @@
}
},
"node_modules/@lingdocs/inflect": {
"version": "5.1.10",
"resolved": "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.1.10.tgz",
"integrity": "sha512-LPJqXSnb2zLWLfMXMTCs/1NOGYQnzPHbKu5h/SdvFYobCxnk2tgngtSWcCmeqYbNXKqQvbDwqmseLlcnUZKysA==",
"version": "5.2.1",
"resolved": "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.2.1.tgz",
"integrity": "sha512-A2Is03lIx8od0JfnHjAbreNeI1jsoRARRXnNhqaJ+Hw7DMPMXEkOlpZnY/luvTcUA7/E5FHKEEAtBOng//zcog==",
"license": "MIT",
"dependencies": {
"pbf": "^3.2.1",
@ -2741,9 +2741,9 @@
}
},
"@lingdocs/inflect": {
"version": "5.1.10",
"resolved": "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.1.10.tgz",
"integrity": "sha512-LPJqXSnb2zLWLfMXMTCs/1NOGYQnzPHbKu5h/SdvFYobCxnk2tgngtSWcCmeqYbNXKqQvbDwqmseLlcnUZKysA==",
"version": "5.2.1",
"resolved": "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.2.1.tgz",
"integrity": "sha512-A2Is03lIx8od0JfnHjAbreNeI1jsoRARRXnNhqaJ+Hw7DMPMXEkOlpZnY/luvTcUA7/E5FHKEEAtBOng//zcog==",
"requires": {
"pbf": "^3.2.1",
"rambda": "^7.3.0"

View File

@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@lingdocs/inflect": "5.1.10",
"@lingdocs/inflect": "5.2.1",
"base64url": "^3.0.1",
"bcryptjs": "^2.4.3",
"connect-redis": "^6.0.0",

View File

@ -45,10 +45,10 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@lingdocs/inflect@5.1.10":
"integrity" "sha512-LPJqXSnb2zLWLfMXMTCs/1NOGYQnzPHbKu5h/SdvFYobCxnk2tgngtSWcCmeqYbNXKqQvbDwqmseLlcnUZKysA=="
"resolved" "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.1.10.tgz"
"version" "5.1.10"
"@lingdocs/inflect@5.2.1":
"integrity" "sha512-A2Is03lIx8od0JfnHjAbreNeI1jsoRARRXnNhqaJ+Hw7DMPMXEkOlpZnY/luvTcUA7/E5FHKEEAtBOng//zcog=="
"resolved" "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.2.1.tgz"
"version" "5.2.1"
dependencies:
"pbf" "^3.2.1"
"rambda" "^7.3.0"

View File

@ -7,7 +7,7 @@
"name": "functions",
"dependencies": {
"@google-cloud/storage": "^5.8.1",
"@lingdocs/inflect": "5.1.10",
"@lingdocs/inflect": "5.2.1",
"@types/cors": "^2.8.10",
"@types/google-spreadsheet": "^3.0.2",
"@types/react": "^18.0.21",
@ -391,9 +391,9 @@
}
},
"node_modules/@lingdocs/inflect": {
"version": "5.1.10",
"resolved": "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.1.10.tgz",
"integrity": "sha512-LPJqXSnb2zLWLfMXMTCs/1NOGYQnzPHbKu5h/SdvFYobCxnk2tgngtSWcCmeqYbNXKqQvbDwqmseLlcnUZKysA==",
"version": "5.2.1",
"resolved": "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.2.1.tgz",
"integrity": "sha512-A2Is03lIx8od0JfnHjAbreNeI1jsoRARRXnNhqaJ+Hw7DMPMXEkOlpZnY/luvTcUA7/E5FHKEEAtBOng//zcog==",
"license": "MIT",
"dependencies": {
"pbf": "^3.2.1",
@ -3499,9 +3499,9 @@
}
},
"@lingdocs/inflect": {
"version": "5.1.10",
"resolved": "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.1.10.tgz",
"integrity": "sha512-LPJqXSnb2zLWLfMXMTCs/1NOGYQnzPHbKu5h/SdvFYobCxnk2tgngtSWcCmeqYbNXKqQvbDwqmseLlcnUZKysA==",
"version": "5.2.1",
"resolved": "https://npm.lingdocs.com/@lingdocs%2finflect/-/inflect-5.2.1.tgz",
"integrity": "sha512-A2Is03lIx8od0JfnHjAbreNeI1jsoRARRXnNhqaJ+Hw7DMPMXEkOlpZnY/luvTcUA7/E5FHKEEAtBOng//zcog==",
"requires": {
"pbf": "^3.2.1",
"rambda": "^7.3.0"

View File

@ -14,7 +14,7 @@
"main": "lib/functions/src/index.js",
"dependencies": {
"@google-cloud/storage": "^5.8.1",
"@lingdocs/inflect": "5.1.10",
"@lingdocs/inflect": "5.2.1",
"@types/cors": "^2.8.10",
"@types/google-spreadsheet": "^3.0.2",
"@types/react": "^18.0.21",

View File

@ -26,8 +26,8 @@ const title = "LingDocs Pashto Dictionary"
const license = "Copyright © 2021 lingdocs.com All Rights Reserved - Licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License - https://creativecommons.org/licenses/by-nc-sa/4.0/";
const bucketName = "lingdocs";
const baseUrl = `https://storage.googleapis.com/${bucketName}/`;
const dictionaryFilename = "dictionary";
const dictionaryInfoFilename = "dictionary-info";
const dictionaryFilename = "dict";
const dictionaryInfoFilename = "dict-info";
const hunspellAffFileFilename = "ps_AFF.aff";
const hunspellDicFileFilename = "ps_AFF.dic";
const url = `${baseUrl}${dictionaryFilename}`;
@ -84,29 +84,30 @@ async function doHunspell(entries: T.DictionaryEntry[]) {
* @returns
*
*/
async function getRawEntries(): Promise<T.DictionaryEntry[]> {
const doc = new GoogleSpreadsheet(
functions.config().sheet.id,
);
await doc.useServiceAccountAuth({
client_email: functions.config().serviceacct.email,
private_key: functions.config().serviceacct.key,
});
await doc.loadInfo();
const sheet = doc.sheetsByIndex[0];
const rows = await sheet.getRows();
let rows: GoogleSpreadsheetRow[] = []
async function getRows() {
const doc = new GoogleSpreadsheet(
functions.config().sheet.id,
);
await doc.useServiceAccountAuth({
client_email: functions.config().serviceacct.email,
private_key: functions.config().serviceacct.key,
});
await doc.loadInfo();
const sheet = doc.sheetsByIndex[0];
rows = await sheet.getRows();
rows.sort((a, b) => a.ts > b.ts ? -1 : a.ts < b.ts ? 1 : 0);
}
getRows()
async function deleteRow(i: number) {
console.log("WILL DELETE ROW", rows[i].p, rows[i].ts, rows[i].f);
await rows[i].delete();
}
return await makeEntries(rows, deleteRow);
}
async function makeEntries(rows: GoogleSpreadsheetRow[], deleteRow: (i: number) => Promise<void>): Promise<T.DictionaryEntry[]> {
const entries: T.DictionaryEntry[] = [];
let sheetIndex = 0;
// get the rows in order of ts for easy detection of duplicate entries
rows.sort((a, b) => a.ts > b.ts ? -1 : a.ts < b.ts ? 1 : 0);
for (let i = 0; i < rows.length; i++) {
function sameEntry(a: any, b: any): boolean {
return a.p === b.p && a.f === b.f && a.e === b.e;

View File

@ -7,7 +7,7 @@
"private": true,
"dependencies": {
"@fortawesome/fontawesome-free": "^5.15.2",
"@lingdocs/ps-react": "5.1.10",
"@lingdocs/ps-react": "5.2.1",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",

View File

@ -2349,10 +2349,10 @@
"@jridgewell/resolve-uri" "^3.0.3"
"@jridgewell/sourcemap-codec" "^1.4.10"
"@lingdocs/ps-react@5.1.10":
version "5.1.10"
resolved "https://npm.lingdocs.com/@lingdocs%2fps-react/-/ps-react-5.1.10.tgz#155646c436c7dc2644c60815cef6b914ba7fef69"
integrity sha512-3PtfEZBmNCa6ptlWezLXpHrngcRmPc8QKguGiXI48TnVxSvAaSH63FTwRQJIDznYasq3bnDSH/7Sta8SX8vvBA==
"@lingdocs/ps-react@5.2.1":
version "5.2.1"
resolved "https://npm.lingdocs.com/@lingdocs%2fps-react/-/ps-react-5.2.1.tgz#e483ced9d12a1913564831f8b37fdb843b912e80"
integrity sha512-2gG2GVNISgjgiyOjyt1rjCPeJ+Bd+FWKZMPXHV98KFSWuuUEX5Jhf8K2FXzv0CGdTOviI++V1O07y86iCSlaXA==
dependencies:
"@formkit/auto-animate" "^1.0.0-beta.3"
classnames "^2.2.6"