2021-03-06 10:40:31 +00:00
|
|
|
const fs = require("fs");
|
|
|
|
const fetch = require("node-fetch");
|
|
|
|
const path = require("path");
|
2021-04-17 10:58:49 +00:00
|
|
|
const { readDictionary } = require("@lingdocs/pashto-inflector");
|
2021-03-06 10:40:31 +00:00
|
|
|
const verbsPath = path.join(".", "src", "words");
|
|
|
|
|
2021-04-17 10:58:49 +00:00
|
|
|
fetch(process.env.LINGDOCS_DICTIONARY_URL).then(res => res.arrayBuffer()).then(data => {
|
|
|
|
const { entries } = readDictionary(data);
|
2021-03-06 10:40:31 +00:00
|
|
|
const filtered = entries.filter(e => (
|
2021-11-01 17:50:17 +00:00
|
|
|
e.c?.includes("loc. adv.")
|
2021-03-06 10:40:31 +00:00
|
|
|
));
|
|
|
|
const content = `module.exports = [
|
|
|
|
${filtered.reduce((text, entry) => (
|
2021-08-31 16:33:44 +00:00
|
|
|
text + `{ ts: ${entry.ts}, e: \`${entry.e.replace(/"/g, '\\"')}\` }, // ${entry.p} - ${entry.f}
|
2021-03-06 10:40:31 +00:00
|
|
|
`), "")}
|
|
|
|
];`;
|
2021-09-01 13:22:37 +00:00
|
|
|
fs.writeFileSync(path.join(verbsPath, "query-results.js"), content);
|
2021-03-06 10:40:31 +00:00
|
|
|
});
|