Add support for returning pitch data from the database
This commit is contained in:
parent
9e8a22b08a
commit
047efaa3db
@ -490,6 +490,7 @@ class Translator {
|
|||||||
|
|
||||||
// New data
|
// New data
|
||||||
term.frequencies = [];
|
term.frequencies = [];
|
||||||
|
term.pitches = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
const metas = await this.database.findTermMetaBulk(expressionsUnique, dictionaries);
|
const metas = await this.database.findTermMetaBulk(expressionsUnique, dictionaries);
|
||||||
@ -500,6 +501,13 @@ class Translator {
|
|||||||
term.frequencies.push({expression, frequency: data, dictionary});
|
term.frequencies.push({expression, frequency: data, dictionary});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'pitch':
|
||||||
|
for (const term of termsUnique[index]) {
|
||||||
|
const pitchData = await this.getPitchData(expression, data, dictionary, term);
|
||||||
|
if (pitchData === null) { continue; }
|
||||||
|
term.pitches.push(pitchData);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -583,6 +591,20 @@ class Translator {
|
|||||||
return tagMetaList;
|
return tagMetaList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getPitchData(expression, data, dictionary, term) {
|
||||||
|
const reading = data.reading;
|
||||||
|
const termReading = term.reading || expression;
|
||||||
|
if (reading !== termReading) { return null; }
|
||||||
|
|
||||||
|
const pitches = [];
|
||||||
|
for (let {position, tags} of data.pitches) {
|
||||||
|
tags = Array.isArray(tags) ? await this.getTagMetaList(tags, dictionary) : [];
|
||||||
|
pitches.push({position, tags});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {reading, pitches, dictionary};
|
||||||
|
}
|
||||||
|
|
||||||
static createExpression(expression, reading, termTags=null, termFrequency=null) {
|
static createExpression(expression, reading, termTags=null, termFrequency=null) {
|
||||||
const furiganaSegments = jp.distributeFurigana(expression, reading);
|
const furiganaSegments = jp.distributeFurigana(expression, reading);
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user