Update how pitch accent expressions are disambiguated
This commit is contained in:
parent
a339bf69d3
commit
aa2a0c09f4
@ -62,6 +62,7 @@ h2 { border-bottom-color: #2f2f2f; }
|
|||||||
|
|
||||||
.term-definition-list,
|
.term-definition-list,
|
||||||
.term-pitch-accent-group-list,
|
.term-pitch-accent-group-list,
|
||||||
|
.term-pitch-accent-expression-list,
|
||||||
.kanji-glossary-list {
|
.kanji-glossary-list {
|
||||||
color: #888888;
|
color: #888888;
|
||||||
}
|
}
|
||||||
|
@ -62,6 +62,7 @@ h2 { border-bottom-color: #eeeeee; }
|
|||||||
|
|
||||||
.term-definition-list,
|
.term-definition-list,
|
||||||
.term-pitch-accent-group-list,
|
.term-pitch-accent-group-list,
|
||||||
|
.term-pitch-accent-expression-list,
|
||||||
.kanji-glossary-list {
|
.kanji-glossary-list {
|
||||||
color: #777777;
|
color: #777777;
|
||||||
}
|
}
|
||||||
|
@ -488,14 +488,25 @@ button.action-button {
|
|||||||
.term-pitch-accent-group-tag-list {
|
.term-pitch-accent-group-tag-list {
|
||||||
margin-right: 0.375em;
|
margin-right: 0.375em;
|
||||||
}
|
}
|
||||||
.entry[data-unique-expression-count="1"] .term-pitch-accent-expression-list {
|
|
||||||
|
.term-pitch-accent-expression-list {
|
||||||
|
padding-right: 0.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.term-pitch-accent-expression-list[data-count="0"] {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
.term-pitch-accent-expression:not(:last-of-type):after {
|
|
||||||
content: "\3001";
|
.term-pitch-accent-expression-list:before {
|
||||||
|
content: "(";
|
||||||
}
|
}
|
||||||
.term-pitch-accent-expression:last-of-type:after {
|
|
||||||
content: "\FF1A";
|
.term-pitch-accent-expression-list:after {
|
||||||
|
content: " only)";
|
||||||
|
}
|
||||||
|
|
||||||
|
.term-pitch-accent-expression+.term-pitch-accent-expression:before {
|
||||||
|
content: ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
.term-pitch-accent-tag-list:not([data-count="0"]) {
|
.term-pitch-accent-tag-list:not([data-count="0"]) {
|
||||||
|
@ -304,7 +304,7 @@ class DisplayGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
createPitch(details) {
|
createPitch(details) {
|
||||||
const {expressions, reading, position, tags} = details;
|
const {exclusiveExpressions, reading, position, tags} = details;
|
||||||
const morae = jp.getKanaMorae(reading);
|
const morae = jp.getKanaMorae(reading);
|
||||||
|
|
||||||
const node = this._templateHandler.instantiate('term-pitch-accent');
|
const node = this._templateHandler.instantiate('term-pitch-accent');
|
||||||
@ -319,7 +319,7 @@ class DisplayGenerator {
|
|||||||
DisplayGenerator._appendMultiple(n, this.createTag.bind(this), tags);
|
DisplayGenerator._appendMultiple(n, this.createTag.bind(this), tags);
|
||||||
|
|
||||||
n = node.querySelector('.term-pitch-accent-expression-list');
|
n = node.querySelector('.term-pitch-accent-expression-list');
|
||||||
DisplayGenerator._appendMultiple(n, this.createPitchExpression.bind(this), expressions);
|
DisplayGenerator._appendMultiple(n, this.createPitchExpression.bind(this), exclusiveExpressions);
|
||||||
|
|
||||||
n = node.querySelector('.term-pitch-accent-characters');
|
n = node.querySelector('.term-pitch-accent-characters');
|
||||||
for (let i = 0, ii = morae.length; i < ii; ++i) {
|
for (let i = 0, ii = morae.length; i < ii; ++i) {
|
||||||
@ -481,6 +481,7 @@ class DisplayGenerator {
|
|||||||
static _getPitchInfos(definition) {
|
static _getPitchInfos(definition) {
|
||||||
const results = new Map();
|
const results = new Map();
|
||||||
|
|
||||||
|
const allExpressions = new Set();
|
||||||
const expressions = definition.expressions;
|
const expressions = definition.expressions;
|
||||||
const sources = Array.isArray(expressions) ? expressions : [definition];
|
const sources = Array.isArray(expressions) ? expressions : [definition];
|
||||||
for (const {pitches: expressionPitches, expression} of sources) {
|
for (const {pitches: expressionPitches, expression} of sources) {
|
||||||
@ -498,10 +499,22 @@ class DisplayGenerator {
|
|||||||
dictionaryResults.push(pitchInfo);
|
dictionaryResults.push(pitchInfo);
|
||||||
}
|
}
|
||||||
pitchInfo.expressions.add(expression);
|
pitchInfo.expressions.add(expression);
|
||||||
|
allExpressions.add(expression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const dictionaryResults of results.values()) {
|
||||||
|
for (const result of dictionaryResults) {
|
||||||
|
const exclusiveExpressions = [];
|
||||||
|
const resultExpressions = result.expressions;
|
||||||
|
if (!areSetsEqual(resultExpressions, allExpressions)) {
|
||||||
|
exclusiveExpressions.push(...getSetIntersection(resultExpressions, allExpressions));
|
||||||
|
}
|
||||||
|
result.exclusiveExpressions = exclusiveExpressions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return [...results.entries()];
|
return [...results.entries()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user