aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language/translator.js
diff options
context:
space:
mode:
authorStefanVukovic99 <stefanvukovic44@gmail.com>2023-12-28 06:39:19 +0100
committerGitHub <noreply@github.com>2023-12-28 05:39:19 +0000
commitfc2123a45b3ceacc2ec887d24e5e752dca59bb4f (patch)
tree3a5105a6bff7a1755582c0cb9d38996933044b2b /ext/js/language/translator.js
parent60cd218663f62f79394e9c0247e0fe40de6589b6 (diff)
add phonetic transcriptions term meta type (#434)
* move dictionary files to dictionary folder * wip * move dictionary files to dictionary folder * add ipa term meta * wip * fixing comments wip * fixing comments wip * fixing comments wip * fixing comments wip * fixing comments wip * fixing comments wip * fix comments * fix comments * update test data * fix gitignore * engines * add tests * update database test * fix test
Diffstat (limited to 'ext/js/language/translator.js')
-rw-r--r--ext/js/language/translator.js44
1 files changed, 39 insertions, 5 deletions
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index 45909940..733955c2 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -964,7 +964,7 @@ export class Translator {
case 'pitch':
{
if (data.reading !== reading) { continue; }
- /** @type {import('dictionary').TermPitch[]} */
+ /** @type {import('dictionary').PitchAccent[]} */
const pitches = [];
for (const {position, tags, nasal, devoice} of data.pitches) {
/** @type {import('dictionary').Tag[]} */
@@ -974,7 +974,13 @@ export class Translator {
}
const nasalPositions = this._toNumberArray(nasal);
const devoicePositions = this._toNumberArray(devoice);
- pitches.push({position, nasalPositions, devoicePositions, tags: tags2});
+ pitches.push({
+ type: 'pitch-accent',
+ position,
+ nasalPositions,
+ devoicePositions,
+ tags: tags2
+ });
}
for (const {pronunciations, headwordIndex} of targets) {
pronunciations.push(this._createTermPronunciation(
@@ -988,6 +994,34 @@ export class Translator {
}
}
break;
+ case 'ipa':
+ {
+ if (data.reading !== reading) { continue; }
+ /** @type {import('dictionary').PhoneticTranscription[]} */
+ const phoneticTranscriptions = [];
+ for (const {ipa, tags} of data.transcriptions) {
+ /** @type {import('dictionary').Tag[]} */
+ const tags2 = [];
+ if (Array.isArray(tags)) {
+ tagAggregator.addTags(tags2, dictionary, tags);
+ }
+ phoneticTranscriptions.push({
+ type: 'phonetic-transcription',
+ ipa,
+ tags: tags2
+ });
+ }
+ for (const {pronunciations, headwordIndex} of targets) {
+ pronunciations.push(this._createTermPronunciation(
+ pronunciations.length,
+ headwordIndex,
+ dictionary,
+ dictionaryIndex,
+ dictionaryPriority,
+ phoneticTranscriptions
+ ));
+ }
+ }
}
}
}
@@ -1341,11 +1375,11 @@ export class Translator {
* @param {string} dictionary
* @param {number} dictionaryIndex
* @param {number} dictionaryPriority
- * @param {import('dictionary').TermPitch[]} pitches
+ * @param {import('dictionary').Pronunciation[]} pronunciations
* @returns {import('dictionary').TermPronunciation}
*/
- _createTermPronunciation(index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches) {
- return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pitches};
+ _createTermPronunciation(index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations) {
+ return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, pronunciations};
}
/**