Fix pitch accent info gathering using new data format (#1081)

This commit is contained in:
toasted-nutbread 2020-12-05 21:16:24 -05:00 committed by GitHub
parent 95b225462a
commit 0fc8578dee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,20 +17,17 @@
class DictionaryDataUtil {
static getPitchAccentInfos(definition) {
const {type} = definition;
if (type === 'kanji') { return []; }
if (definition.type === 'kanji') { return []; }
const results = new Map();
const allExpressions = new Set();
const allReadings = new Set();
const sources = [definition];
for (const {pitches: expressionPitches, expression} of sources) {
for (const {expression, reading, pitches: expressionPitches} of definition.expressions) {
allExpressions.add(expression);
for (const {reading, pitches, dictionary} of expressionPitches) {
allReadings.add(reading);
for (const {pitches, dictionary} of expressionPitches) {
let dictionaryResults = results.get(dictionary);
if (typeof dictionaryResults === 'undefined') {
dictionaryResults = [];