Skip to content

Commit

Permalink
finish
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanVukovic99 committed Aug 11, 2024
1 parent 169526e commit fd7a08f
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 9 deletions.
25 changes: 16 additions & 9 deletions 3-tidy-up.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,24 +416,31 @@ function getJapaneseReadings(word, line){
if(!Array.isArray(head_templates) || head_templates.length === 0) {
return [word]; // never happens
}
if (head_templates.length > 1) {
console.log('Multiple head_templates found for Japanese word:', word, head_templates);
}
const readings = [];
for (const template of head_templates) {
let reading;
switch(template.name) {
case 'ja-noun':
case 'ja-adj':
case 'ja-verb':
const reading = template?.args?.[1];
if(!reading) {
console.log('No reading found for Japanese word:', word, template);
continue;
}
readings.push(reading);
case 'ja-verb form':
case 'ja-verb-form':
case 'ja-phrase':
reading = template?.args?.[1];
break;
case 'ja-pos':
reading = template?.args?.[2];
break;
case 'head':
case 'ja-def':
case 'ja-syllable':
continue;
default:
// console.log('Unknown head_template:', word, head_templates);
}
if(reading) {
readings.push(reading.replace(/\^| /g, ''));
}
}

return readings.length > 0 ? readings : [word];
Expand Down
7 changes: 7 additions & 0 deletions data/test/dict/ja/en/tag_bank_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,12 @@
0,
"music",
0
],
[
"phrase",
"partOfSpeech",
-1,
"phrase",
1
]
]
12 changes: 12 additions & 0 deletions data/test/dict/ja/en/term_bank_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,17 @@
],
0,
""
],
[
"お腹が空いた",
"おなかがすいた",
"phrase",
"phrase",
0,
[
"[I am / someone is] hungry"
],
0,
""
]
]
17 changes: 17 additions & 0 deletions data/test/dict/ja/en/term_bank_2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3608,5 +3608,22 @@
],
0,
""
],
[
"onaka ga suita",
"",
"non-lemma",
"",
0,
[
[
"お腹が空いた",
[
"romanization"
]
]
],
0,
""
]
]
13 changes: 13 additions & 0 deletions data/test/ipa/ja/en/term_meta_bank_1.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,18 @@
}
]
}
],
[
"お腹が空いた",
"ipa",
{
"reading": "おなかがすいた",
"transcriptions": [
{
"ipa": "[o̞na̠ka̠ ɡa̠ sɨita̠]",
"tags": []
}
]
}
]
]
1 change: 1 addition & 0 deletions data/test/kaikki/ja-en.json

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions data/test/tidy/ja-en-forms-0.json
Original file line number Diff line number Diff line change
Expand Up @@ -2833,6 +2833,28 @@
]
]
}
],
[
"お腹が空いた",
{
"_type": "map",
"map": [
[
"onaka ga suita",
{
"_type": "map",
"map": [
[
"phrase",
[
"romanization"
]
]
]
}
]
]
}
]
]
}
20 changes: 20 additions & 0 deletions data/test/tidy/ja-en-lemmas.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,5 +311,25 @@
]
}
}
},
"お腹が空いた": {
"おなかがすいた": {
"phrase": {
"ipa": [
{
"ipa": "[o̞na̠ka̠ ɡa̠ sɨita̠]",
"tags": []
}
],
"senses": [
{
"glosses": [
"[I am / someone is] hungry"
],
"tags": []
}
]
}
}
}
}

0 comments on commit fd7a08f

Please sign in to comment.