refactor: moving words into the right location
This commit is contained in:
parent
4780129e57
commit
4a6cb93a3d
36 changed files with 92 additions and 44 deletions
89
convert
89
convert
|
@ -1,9 +1,7 @@
|
|||
#!/usr/bin/env -S deno --allow-read
|
||||
#!/usr/bin/env -S deno --allow-read --allow-write
|
||||
|
||||
import { parse, stringify } from "jsr:@std/yaml";
|
||||
import miwafu from "npm:fedran-miwafu@0.1.6";
|
||||
|
||||
console.log(miwafu);
|
||||
import miwafu from "npm:@fedran/miwafu@0.2.1";
|
||||
|
||||
// Go through all the directories and parse each one.
|
||||
let done = false;
|
||||
|
@ -52,6 +50,9 @@ for await (const rootEntry of Deno.readDir("src/dictionary")) {
|
|||
addGender(newLanguage, data.pos.verb, "verb", data.base);
|
||||
addList(newLanguage, data.pos.adv, "adv", data.base);
|
||||
addList(newLanguage, data.pos.adj, "adj", data.base);
|
||||
addList(newLanguage, data.pos.num, "num", data.base);
|
||||
addList(newLanguage, data.pos.pro, "pro", data.base);
|
||||
addList(newLanguage, data.pos.part, "particle", data.base);
|
||||
|
||||
// Write out the results.
|
||||
Deno.writeTextFile(filePath, stringify(newData));
|
||||
|
@ -73,6 +74,17 @@ function addGender(
|
|||
part: String,
|
||||
word: String,
|
||||
) {
|
||||
const m = miwafu.inflectMasculine(word);
|
||||
|
||||
console.log(
|
||||
"------",
|
||||
word,
|
||||
miwafu.splitSyllables(word),
|
||||
m,
|
||||
miwafu.inflectFeminine(word),
|
||||
miwafu.inflectNeuter(word),
|
||||
);
|
||||
|
||||
if (gender) {
|
||||
addList(lang, gender.masculine, part, miwafu.inflectMasculine(word));
|
||||
addList(lang, gender.feminine, part, miwafu.inflectFeminine(word));
|
||||
|
@ -87,10 +99,16 @@ function addPartList(
|
|||
word: String,
|
||||
) {
|
||||
if (list) {
|
||||
const p: NewPart = {
|
||||
word,
|
||||
definitions: [],
|
||||
};
|
||||
|
||||
lang.parts[part] ??= [];
|
||||
lang.parts[part].push(p);
|
||||
|
||||
for (const def of list) {
|
||||
add(lang.parts[part], def, part, word);
|
||||
add(p, def, part, word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,23 +120,48 @@ function addList(
|
|||
word: String,
|
||||
) {
|
||||
if (list) {
|
||||
lang.parts[part] ??= [];
|
||||
|
||||
for (const def of list) {
|
||||
add(lang.parts[part], def, part, word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function add(dest: NewPart[], def: OldDefinition, part: String, word: String) {
|
||||
console.log("**** def", part, word, def);
|
||||
|
||||
const newPart: NewPart = {
|
||||
word: word,
|
||||
definitions: [{ definition: def.def }],
|
||||
let p: NewPart = {
|
||||
word,
|
||||
definitions: [],
|
||||
};
|
||||
|
||||
dest.push(newPart);
|
||||
lang.parts[part] ??= [];
|
||||
lang.parts[part].push(p);
|
||||
|
||||
for (const def of list) {
|
||||
add(p, def, part, word);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function add(dest: NewPart, def: OldDefinition, part: String, word: String) {
|
||||
// Create the top-level reference.
|
||||
console.log("**** def", part, word, def);
|
||||
|
||||
const newPart = { definition: def.def };
|
||||
|
||||
dest.definitions.push(newPart);
|
||||
|
||||
// Add in the various tags.
|
||||
if (def.oow) {
|
||||
newPart.tags ??= [];
|
||||
newPart.tags.push("reality");
|
||||
}
|
||||
|
||||
// See if we have references.
|
||||
if (def.reference) {
|
||||
newPart.references = def.reference
|
||||
.map(o => {
|
||||
const ref = o.url
|
||||
?.replace("https://fedran.com/", "")
|
||||
?.replace(/\/chapter-0*(\d+)\//, "/$1");
|
||||
|
||||
return {
|
||||
ref,
|
||||
excerpt: o.excerpt?.trimEnd(),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Define the old data format.
|
||||
|
@ -177,6 +220,12 @@ interface NewLanguage {
|
|||
|
||||
interface NewPart {
|
||||
word: String;
|
||||
definitions: NewDef[];
|
||||
}
|
||||
|
||||
interface NewDef {
|
||||
definition: String;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
"dependencies": [
|
||||
"npm:@commitlint/cli@^7.2.1",
|
||||
"npm:@commitlint/config-conventional@^7.1.2",
|
||||
"npm:@fedran/miwafu@~0.2.1",
|
||||
"npm:commitizen@^3.0.5",
|
||||
"npm:cz-conventional-changelog@^2.1.0",
|
||||
"npm:fedran-miwafu@~0.1.6",
|
||||
"npm:fs-extra@^7.0.1",
|
||||
"npm:husky@^1.2.1",
|
||||
"npm:js-yaml@^3.13.1",
|
||||
|
|
37
package-lock.json
generated
37
package-lock.json
generated
|
@ -6,7 +6,7 @@
|
|||
"": {
|
||||
"name": "miwafu",
|
||||
"dependencies": {
|
||||
"fedran-miwafu": "^0.1.6"
|
||||
"@fedran/miwafu": "^0.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@commitlint/cli": "^7.2.1",
|
||||
|
@ -325,6 +325,22 @@
|
|||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/@fedran/miwafu": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@fedran/miwafu/-/miwafu-0.2.1.tgz",
|
||||
"integrity": "sha512-bj6KnNQKhOoRbewQXP25lT/cc/cFjSIsjbdiH51TvrFN41RTWGv+PHwRf0K68vURZys3Qgx82KBm59EmCueIdw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"handlebars": "^4.0.11",
|
||||
"handlebars-helpers": "^0.10.0",
|
||||
"js-yaml": "^3.10.0",
|
||||
"lodash": "^4.17.4",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"bin": {
|
||||
"fedran-miwafu": "lib/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/@marionebl/sander": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@marionebl/sander/-/sander-0.6.1.tgz",
|
||||
|
@ -2126,24 +2142,6 @@
|
|||
"integrity": "sha1-1RQsDK7msRifh9OnYREGT4bIu/I=",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/fedran-miwafu": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/fedran-miwafu/-/fedran-miwafu-0.1.6.tgz",
|
||||
"integrity": "sha512-aY6cH6a2zYgQbjeX8RCl7WL9tQRvvxGIT3ZOi4bLBSuwHGOwyqM/+mxftzY1z17GIBIJb8FX3m59K+MS54Hzyw==",
|
||||
"deprecated": "use @fedran/miwafu instead because groups are prettier",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"handlebars": "^4.0.11",
|
||||
"handlebars-helpers": "^0.10.0",
|
||||
"js-yaml": "^3.10.0",
|
||||
"lodash": "^4.17.4",
|
||||
"typescript": "^2.6.2",
|
||||
"yargs": "^10.0.3"
|
||||
},
|
||||
"bin": {
|
||||
"fedran-miwafu": "src/cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/figures": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
|
||||
|
@ -6052,6 +6050,7 @@
|
|||
"version": "2.9.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-2.9.2.tgz",
|
||||
"integrity": "sha512-Gr4p6nFNaoufRIY4NMdpQRNmgxVIGMs4Fcu/ujdYk3nAZqk7supzBE9idmvfZIlH/Cuj//dvi+019qEue9lV0w==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
|
|
|
@ -35,6 +35,6 @@
|
|||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"fedran-miwafu": "^0.1.6"
|
||||
"@fedran/miwafu": "^0.2.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,17 +6,17 @@ The basic units of Miwāfu are syllables. These are represented as a single glyp
|
|||
|
||||
# Syllable Chart
|
||||
|
||||
- | w | r | m | p | b | h | n | d | t | z | s | g | k | f |
|
||||
| \* | w | r | m | p | b | h | n | d | t | z | s | g | k | f |
|
||||
| --- | --- | --- | --- | --- | --- | --- | --- | --- | ---- | --- | ---- | --- | --- | --- |
|
||||
| a | wa | ra | ma | pa | ba | ha | na | da | ta | za | sa | ga | ka | fa |
|
||||
| e | we | re | me | pe | be | he | ne | de | te | ze | se | ge | ke | fe |
|
||||
| i | wi | ri | mi | pi | bi | hi | ni | | chi | ji | shi | gi | ki | fi |
|
||||
| o | wo | ro | mo | po | bo | ho | no | do | to | jo | so | go | ko | fo |
|
||||
| u | wu | ru | mu | pu | bu | hu | nu | | tsu | zu | su | gu | ku | fu |
|
||||
| ya | | rya | mya | pya | bya | hya | nya | | chya | jya | shya | gya | kya |
|
||||
| yo | | ryo | myo | pyo | byo | hyo | nyo | | chyo | jyo | shyo | gyo | kyo |
|
||||
| yu | | ryu | myu | pyu | byu | hyu | nyu | | chyu | jyu | shyu | gyu | kyu |
|
||||
| | | | | | | n | | | | | | |
|
||||
| ya | | rya | mya | pya | bya | hya | nya | | chya | jya | shya | gya | kya | |
|
||||
| yo | | ryo | myo | pyo | byo | hyo | nyo | | chyo | jyo | shyo | gyo | kyo | |
|
||||
| yu | | ryu | myu | pyu | byu | hyu | nyu | | chyu | jyu | shyu | gyu | kyu | |
|
||||
| | | | | | | | n | | | | | | | |
|
||||
|
||||
# Penultimate Accents
|
||||
|
||||
|
|
Loading…
Reference in a new issue