summaryrefslogtreecommitdiff
path: root/ext/js/display/display-generator.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/display/display-generator.js')
-rw-r--r--ext/js/display/display-generator.js26
1 files changed, 12 insertions, 14 deletions
diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js
index eef58bb0..01f6f38b 100644
--- a/ext/js/display/display-generator.js
+++ b/ext/js/display/display-generator.js
@@ -18,11 +18,11 @@
import {ExtensionError} from '../core/extension-error.js';
import {isObject} from '../core/utilities.js';
-import {DictionaryDataUtil} from '../dictionary/dictionary-data-util.js';
+import {getDisambiguations, getGroupedPronunciations, getTermFrequency, groupKanjiFrequencies, groupTermFrequencies, groupTermTags, isNonNounVerbOrAdjective} from '../dictionary/dictionary-data-util.js';
import {HtmlTemplateCollection} from '../dom/html-template-collection.js';
import {distributeFurigana, getKanaMorae, getPitchCategory, isCodePointKanji, isStringPartiallyJapanese} from '../language/japanese.js';
import {yomitan} from '../yomitan.js';
-import {PronunciationGenerator} from './sandbox/pronunciation-generator.js';
+import {createPronunciationDownstepPosition, createPronunciationGraph, createPronunciationText} from './sandbox/pronunciation-generator.js';
import {StructuredContentGenerator} from './sandbox/structured-content-generator.js';
export class DisplayGenerator {
@@ -38,8 +38,6 @@ export class DisplayGenerator {
this._templates = new HtmlTemplateCollection();
/** @type {StructuredContentGenerator} */
this._structuredContentGenerator = new StructuredContentGenerator(this._contentManager, document);
- /** @type {PronunciationGenerator} */
- this._pronunciationGenerator = new PronunciationGenerator();
}
/** */
@@ -73,10 +71,10 @@ export class DisplayGenerator {
const headwordTagsContainer = this._querySelector(node, '.headword-list-tag-list');
const {headwords, type, inflectionRuleChainCandidates, definitions, frequencies, pronunciations} = dictionaryEntry;
- const groupedPronunciations = DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry);
+ const groupedPronunciations = getGroupedPronunciations(dictionaryEntry);
const pronunciationCount = groupedPronunciations.reduce((i, v) => i + v.pronunciations.length, 0);
- const groupedFrequencies = DictionaryDataUtil.groupTermFrequencies(dictionaryEntry);
- const termTags = DictionaryDataUtil.groupTermTags(dictionaryEntry);
+ const groupedFrequencies = groupTermFrequencies(dictionaryEntry);
+ const termTags = groupTermTags(dictionaryEntry);
/** @type {Set<string>} */
const uniqueTerms = new Set();
@@ -166,7 +164,7 @@ export class DisplayGenerator {
const dictionaryIndicesContainer = this._querySelector(node, '.kanji-dictionary-indices');
this._setTextContent(glyphContainer, dictionaryEntry.character, 'ja');
- const groupedFrequencies = DictionaryDataUtil.groupKanjiFrequencies(dictionaryEntry.frequencies);
+ const groupedFrequencies = groupKanjiFrequencies(dictionaryEntry.frequencies);
const dictionaryTag = this._createDictionaryTag(dictionaryEntry.dictionary);
@@ -334,7 +332,7 @@ export class DisplayGenerator {
node.dataset.isPrimary = `${isPrimaryAny}`;
node.dataset.readingIsSame = `${reading === term}`;
- node.dataset.frequency = DictionaryDataUtil.getTermFrequency(tags);
+ node.dataset.frequency = getTermFrequency(tags);
node.dataset.matchTypes = [...matchTypes].join(' ');
node.dataset.matchSources = [...matchSources].join(' ');
@@ -415,7 +413,7 @@ export class DisplayGenerator {
*/
_createTermDefinition(definition, dictionaryTag, headwords, uniqueTerms, uniqueReadings) {
const {dictionary, tags, headwordIndices, entries} = definition;
- const disambiguations = DictionaryDataUtil.getDisambiguations(headwords, headwordIndices, uniqueTerms, uniqueReadings);
+ const disambiguations = getDisambiguations(headwords, headwordIndices, uniqueTerms, uniqueReadings);
const node = this._instantiate('definition-item');
@@ -742,15 +740,15 @@ export class DisplayGenerator {
this._createPronunciationDisambiguations(n, exclusiveTerms, exclusiveReadings);
n = this._querySelector(node, '.pronunciation-downstep-notation-container');
- n.appendChild(this._pronunciationGenerator.createPronunciationDownstepPosition(position));
+ n.appendChild(createPronunciationDownstepPosition(position));
n = this._querySelector(node, '.pronunciation-text-container');
n.lang = 'ja';
- n.appendChild(this._pronunciationGenerator.createPronunciationText(morae, position, nasalPositions, devoicePositions));
+ n.appendChild(createPronunciationText(morae, position, nasalPositions, devoicePositions));
n = this._querySelector(node, '.pronunciation-graph-container');
- n.appendChild(this._pronunciationGenerator.createPronunciationGraph(morae, position));
+ n.appendChild(createPronunciationGraph(morae, position));
return node;
}
@@ -1040,7 +1038,7 @@ export class DisplayGenerator {
*/
_getPronunciationCategories(reading, termPronunciations, wordClasses, headwordIndex) {
if (termPronunciations.length === 0) { return null; }
- const isVerbOrAdjective = DictionaryDataUtil.isNonNounVerbOrAdjective(wordClasses);
+ const isVerbOrAdjective = isNonNounVerbOrAdjective(wordClasses);
/** @type {Set<import('japanese-util').PitchCategory>} */
const categories = new Set();
for (const termPronunciation of termPronunciations) {