From b45c9025e32d64bb1780898df3bf501314773504 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Mon, 25 Dec 2023 20:12:17 +0100 Subject: [PATCH 01/28] wip --- ext/css/display.css | 9 ++-- .../dictionary-term-bank-v3-schema.json | 22 ++++++-- ext/display-templates.html | 3 +- ext/js/dictionary/dictionary-database.js | 12 +++-- ext/js/dictionary/dictionary-importer.js | 4 +- ext/js/display/display-generator.js | 17 ++++-- ext/js/language/translator.js | 52 ++++++++++++++++--- types/ext/dictionary-data.d.ts | 5 ++ types/ext/dictionary-database.d.ts | 4 ++ types/ext/dictionary.d.ts | 2 +- 10 files changed, 106 insertions(+), 24 deletions(-) diff --git a/ext/css/display.css b/ext/css/display.css index 49aeaaa5d0..0726655e74 100644 --- a/ext/css/display.css +++ b/ext/css/display.css @@ -809,14 +809,17 @@ button.action-button:active { /* Inflections */ -.inflection-list { +.inflection-hypotheses-list{ + padding-inline-start: 20px; +} +.inflection-hypothesis { display: inline-block; color: var(--reason-text-color); } -.inflection-list:empty { +.inflection-hypothesis:empty { display: none; } -.inflection-list>.inflection+.inflection-separator+.inflection::before { +.inflection-hypothesis>.inflection+.inflection-separator+.inflection::before { content: var(--inflection-separator); padding: 0 0.25em; } diff --git a/ext/data/schemas/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json index 547bde49ed..8e1d2575d1 100644 --- a/ext/data/schemas/dictionary-term-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-bank-v3-schema.json @@ -1,5 +1,5 @@ { - "$id": "dictionaryTermBankV3", + "$id": "dictionaryTermBankV4", "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "structuredContent": { @@ -319,7 +319,7 @@ "type": "array", "description": "Information about a single term.", "minItems": 8, - "maxItems": 8, + "maxItems": 10, "additionalItems": false, "items": [ { @@ -336,7 +336,7 @@ }, { "type": "string", - "description": "String of space-separated rule identifiers for the definition which is used to validate delinflection. Valid rule identifiers are: v1: ichidan verb; v5: godan verb; vs: suru verb; vk: kuru verb; adj-i: i-adjective. An empty string corresponds to words which aren't inflected, such as nouns." + "description": "String of space-separated rule identifiers for the definition which is used to validate deinflection. An empty string should be used for words which aren't inflected." }, { "type": "number", @@ -482,6 +482,22 @@ { "type": "string", "description": "String of space-separated tags for the term. An empty string is treated as no tags." + }, + { + "type": ["string"], + "description": "Lemma (uninflected) form of the term. Empty for lemmas." + }, + { + "type": ["array"], + "description": "Array of possible inflection combinations that produce the term. Empty for lemmas.", + "items": { + "type": "array", + "description": "An inflection combination.", + "items": { + "type": "string", + "description": "An inflection." + } + } } ] } diff --git a/ext/display-templates.html b/ext/display-templates.html index ed0037bb6d..32d9e59a69 100644 --- a/ext/display-templates.html +++ b/ext/display-templates.html @@ -32,7 +32,7 @@
-
+
@@ -77,6 +77,7 @@ + diff --git a/ext/js/dictionary/dictionary-database.js b/ext/js/dictionary/dictionary-database.js index 45c5c6fdb9..e49f617262 100644 --- a/ext/js/dictionary/dictionary-database.js +++ b/ext/js/dictionary/dictionary-database.js @@ -578,21 +578,23 @@ export class DictionaryDatabase { * @returns {import('dictionary-database').TermEntry} */ _createTerm(matchSource, matchType, row, index) { - const {sequence} = row; + const {sequence, reading, score, dictionary, formOf, inflectionHypotheses} = row; return { index, matchType, matchSource, term: row.expression, - reading: row.reading, + reading, definitionTags: this._splitField(row.definitionTags || row.tags), termTags: this._splitField(row.termTags), rules: this._splitField(row.rules), definitions: row.glossary, - score: row.score, - dictionary: row.dictionary, + score, + dictionary, id: row.id, - sequence: typeof sequence === 'number' ? sequence : -1 + sequence: typeof sequence === 'number' ? sequence : -1, + formOf, + inflectionHypotheses }; } diff --git a/ext/js/dictionary/dictionary-importer.js b/ext/js/dictionary/dictionary-importer.js index 2c0c7e9c2e..b5d040d4a3 100644 --- a/ext/js/dictionary/dictionary-importer.js +++ b/ext/js/dictionary/dictionary-importer.js @@ -613,10 +613,10 @@ export class DictionaryImporter { * @returns {import('dictionary-database').DatabaseTermEntry} */ _convertTermBankEntryV3(entry, dictionary) { - let [expression, reading, definitionTags, rules, score, glossary, sequence, termTags] = entry; + let [expression, reading, definitionTags, rules, score, glossary, sequence, termTags, formOf, inflectionHypotheses] = entry; expression = this._normalizeTermOrReading(expression); reading = this._normalizeTermOrReading(reading.length > 0 ? reading : expression); - return {expression, reading, definitionTags, rules, score, glossary, sequence, termTags, dictionary}; + return {expression, reading, definitionTags, rules, score, glossary, sequence, termTags, formOf, inflectionHypotheses, dictionary}; } /** diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 920d2c94c1..d3adaee5ab 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -67,13 +67,13 @@ export class DisplayGenerator { const node = this._instantiate('term-entry'); const headwordsContainer = this._querySelector(node, '.headword-list'); - const inflectionsContainer = this._querySelector(node, '.inflection-list'); + const inflectionHypothesesContainer = this._querySelector(node, '.inflection-hypotheses'); const groupedPronunciationsContainer = this._querySelector(node, '.pronunciation-group-list'); const frequencyGroupListContainer = this._querySelector(node, '.frequency-group-list'); const definitionsContainer = this._querySelector(node, '.definition-list'); const headwordTagsContainer = this._querySelector(node, '.headword-list-tag-list'); - const {headwords, type, inflections, definitions, frequencies, pronunciations} = dictionaryEntry; + const {headwords, type, inflectionHypotheses, definitions, frequencies, pronunciations} = dictionaryEntry; const groupedPronunciations = DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry); const pronunciationCount = groupedPronunciations.reduce((i, v) => i + v.pronunciations.length, 0); const groupedFrequencies = DictionaryDataUtil.groupTermFrequencies(dictionaryEntry); @@ -112,7 +112,7 @@ export class DisplayGenerator { } headwordsContainer.dataset.count = `${headwords.length}`; - this._appendMultiple(inflectionsContainer, this._createTermInflection.bind(this), inflections); + this._appendMultiple(inflectionHypothesesContainer, this._createInflectionHypothesis.bind(this), inflectionHypotheses); this._appendMultiple(frequencyGroupListContainer, this._createFrequencyGroup.bind(this), groupedFrequencies, false); this._appendMultiple(groupedPronunciationsContainer, this._createGroupedPronunciation.bind(this), groupedPronunciations); this._appendMultiple(headwordTagsContainer, this._createTermTag.bind(this), termTags, headwords.length); @@ -356,6 +356,17 @@ export class DisplayGenerator { return node; } + /** + * @param {import('dictionary-data').InflectionHypothesis} inflectionHypothesis + * @returns {DocumentFragment} + */ + _createInflectionHypothesis(inflectionHypothesis) { + const fragment = this._templates.instantiateFragment('inflection-hypothesis'); + const node = this._querySelector(fragment, '.inflection-hypothesis'); + this._appendMultiple(node, this._createTermInflection.bind(this), inflectionHypothesis); + return fragment; + } + /** * @param {string} inflection * @returns {DocumentFragment} diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 4590994039..90e560e9c6 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -70,7 +70,7 @@ export class Translator { async findTerms(mode, text, options) { const {enabledDictionaryMap, excludeDictionaryDefinitions, sortFrequencyDictionary, sortFrequencyDictionaryOrder} = options; const tagAggregator = new TranslatorTagAggregator(); - let {dictionaryEntries, originalTextLength} = await this._findTermsInternalWrapper(text, enabledDictionaryMap, options, tagAggregator); + let {dictionaryEntries, originalTextLength} = await this._findTermsInternal(text, enabledDictionaryMap, options, tagAggregator); switch (mode) { case 'group': @@ -208,7 +208,7 @@ export class Translator { * @param {TranslatorTagAggregator} tagAggregator * @returns {Promise} */ - async _findTermsInternalWrapper(text, enabledDictionaryMap, options, tagAggregator) { + async _findTermsInternal(text, enabledDictionaryMap, options, tagAggregator) { if (options.removeNonJapaneseCharacters) { text = this._getJapaneseOnlyText(text); } @@ -216,9 +216,10 @@ export class Translator { return {dictionaryEntries: [], originalTextLength: 0}; } - const deinflections = await this._findTermsInternal(text, enabledDictionaryMap, options); + const deinflections = await this._getDeinflections(text, enabledDictionaryMap, options); let originalTextLength = 0; + /** @type {import('dictionary').TermDictionaryEntry[]} */ const dictionaryEntries = []; const ids = new Set(); for (const {databaseEntries, originalText, transformedText, deinflectedText, reasons} of deinflections) { @@ -226,8 +227,23 @@ export class Translator { originalTextLength = Math.max(originalTextLength, originalText.length); for (const databaseEntry of databaseEntries) { const {id} = databaseEntry; - if (ids.has(id)) { continue; } - const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, reasons, true, enabledDictionaryMap, tagAggregator); + if (ids.has(id)) { + const existingEntry = dictionaryEntries.find((entry) => { + return entry.definitions.some((definition) => definition.id === id); + }); + if (existingEntry) { + if ( + !this._isHypothesisInHypotheses(existingEntry, reasons) && + existingEntry.headwords[0].sources[0].transformedText.length <= transformedText.length + ) { + existingEntry.inflectionHypotheses.push(reasons); + } + continue; + } + // TODO: make configurable + if (databaseEntry.formOf) { continue; } + } + const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, [reasons], true, enabledDictionaryMap, tagAggregator); dictionaryEntries.push(dictionaryEntry); ids.add(id); } @@ -236,13 +252,37 @@ export class Translator { return {dictionaryEntries, originalTextLength}; } + /** + * @param {import('dictionary').TermDictionaryEntry} existingEntry + * @param {import('dictionary-data').InflectionHypothesis} hypothesis + * @returns {boolean} + */ + _isHypothesisInHypotheses({inflectionHypotheses}, hypothesis) { + return inflectionHypotheses.some((h) => Translator.areArraysEqual(h, hypothesis)); + } + + /** + * @template [T=unknown] + * @param {T[]} array1 + * @param {T[]} array2 + * @returns {boolean} + */ + static areArraysEqual(array1, array2) { + const ii = array1.length; + if (ii !== array2.length) { return false; } + for (let i = 0; i < ii; ++i) { + if (array1[i] !== array2[i]) { return false; } + } + return true; + } + /** * @param {string} text * @param {Map} enabledDictionaryMap * @param {import('translation').FindTermsOptions} options * @returns {Promise} */ - async _findTermsInternal(text, enabledDictionaryMap, options) { + async _getDeinflections(text, enabledDictionaryMap, options) { const deinflections = ( options.deinflect ? this._getAllDeinflections(text, options) : diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index b194c190cd..60f3665118 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -66,8 +66,13 @@ export type TermV3 = [ glossary: TermGlossary[], sequence: number, termTags: string, + formOf: string, + inflectionHypotheses: InflectionHypothesis[], ]; +export type InflectionHypothesis = string[]; + + export type KanjiV1Array = KanjiV1[]; export type KanjiV1 = [ diff --git a/types/ext/dictionary-database.d.ts b/types/ext/dictionary-database.d.ts index 3202ef6017..b96eac10c1 100644 --- a/types/ext/dictionary-database.d.ts +++ b/types/ext/dictionary-database.d.ts @@ -51,6 +51,8 @@ export type DatabaseTermEntry = { glossary: DictionaryData.TermGlossary[]; sequence?: number; termTags?: string; + formOf?: string; + inflectionHypotheses?: DictionaryData.InflectionHypothesis[]; dictionary: string; }; @@ -70,6 +72,8 @@ export type TermEntry = { dictionary: string; id: number; sequence: number; + formOf?: string; + inflectionHypotheses?: DictionaryData.InflectionHypothesis[]; }; export type DatabaseKanjiEntry = { diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 3e90dec0e1..104c892a1a 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -210,7 +210,7 @@ export type TermDictionaryEntry = { /** * A list of inflections that was applied to get the term. */ - inflections: string[]; + inflectionHypotheses: DictionaryData.InflectionHypothesis[]; /** * A score for the dictionary entry. */ From 18320bd0a8d477c75e11ce08e889a2cf0c7995af Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Tue, 2 Jan 2024 22:31:07 +0100 Subject: [PATCH 02/28] wip --- ext/js/language/translator.js | 170 +++++++++++++++++++--------- types/ext/dictionary-data.d.ts | 1 - types/ext/dictionary.d.ts | 7 +- types/ext/translation-internal.d.ts | 3 +- 4 files changed, 125 insertions(+), 56 deletions(-) diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index cd7901cb91..1aaef897d5 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -222,7 +222,7 @@ export class Translator { /** @type {import('dictionary').TermDictionaryEntry[]} */ const dictionaryEntries = []; const ids = new Set(); - for (const {databaseEntries, originalText, transformedText, deinflectedText, reasons} of deinflections) { + for (const {databaseEntries, originalText, transformedText, deinflectedText, inflectionHypotheses} of deinflections) { if (databaseEntries.length === 0) { continue; } originalTextLength = Math.max(originalTextLength, originalText.length); for (const databaseEntry of databaseEntries) { @@ -231,19 +231,34 @@ export class Translator { const existingEntry = dictionaryEntries.find((entry) => { return entry.definitions.some((definition) => definition.id === id); }); - if (existingEntry) { - if ( - !this._isHypothesisInHypotheses(existingEntry, reasons) && - existingEntry.headwords[0].sources[0].transformedText.length <= transformedText.length - ) { - existingEntry.inflectionHypotheses.push(reasons); - } - continue; + if (!existingEntry) { continue; } + if (transformedText.length >= existingEntry.headwords[0].sources[0].transformedText.length) { + const existingHypotheses = existingEntry.inflectionHypotheses; + + /** @type {import('dictionary').InflectionHypothesis[]} */ + const newHypotheses = []; + + inflectionHypotheses.forEach(({source, inflections}) => { + const duplicate = existingHypotheses.find((hypothesis) => this._areInflectionHyphothesesEqual(hypothesis.inflections, inflections)); + if (!duplicate) { + newHypotheses.push({source, inflections}); + } else if (duplicate.source !== source) { + duplicate.source = 'both'; + } + }); + + existingEntry.inflectionHypotheses = [ + ...existingEntry.inflectionHypotheses, + ...newHypotheses + ]; } - // TODO: make configurable - if (databaseEntry.formOf) { continue; } + + continue; } - const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, [reasons], true, enabledDictionaryMap, tagAggregator); + // TODO: make configurable + if (databaseEntry.formOf) { continue; } + + const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionHypotheses, true, enabledDictionaryMap, tagAggregator); dictionaryEntries.push(dictionaryEntry); ids.add(id); } @@ -253,27 +268,15 @@ export class Translator { } /** - * @param {import('dictionary').TermDictionaryEntry} existingEntry - * @param {import('dictionary-data').InflectionHypothesis} hypothesis + * @param {import('dictionary-data').InflectionHypothesis} hypothesis1 + * @param {import('dictionary-data').InflectionHypothesis} hypothesis2 * @returns {boolean} */ - _isHypothesisInHypotheses({inflectionHypotheses}, hypothesis) { - return inflectionHypotheses.some((h) => Translator.areArraysEqual(h, hypothesis)); - } + _areInflectionHyphothesesEqual(hypothesis1, hypothesis2) { + const set1 = new Set(hypothesis1); + const set2 = new Set(hypothesis2); - /** - * @template [T=unknown] - * @param {T[]} array1 - * @param {T[]} array2 - * @returns {boolean} - */ - static areArraysEqual(array1, array2) { - const ii = array1.length; - if (ii !== array2.length) { return false; } - for (let i = 0; i < ii; ++i) { - if (array1[i] !== array2[i]) { return false; } - } - return true; + return set1.size === set2.size && [...set1].every((x) => set2.has(x)); } /** @@ -283,42 +286,103 @@ export class Translator { * @returns {Promise} */ async _getDeinflections(text, enabledDictionaryMap, options) { - const deinflections = ( + let deinflections = ( options.deinflect ? - this._getAllDeinflections(text, options) : + this._getAlgorithmDeinflections(text, options) : [this._createDeinflection(text, text, text, 0, [])] ); if (deinflections.length === 0) { return []; } - const uniqueDeinflectionTerms = []; - const uniqueDeinflectionArrays = []; - const uniqueDeinflectionsMap = new Map(); - for (const deinflection of deinflections) { - const term = deinflection.deinflectedText; - let deinflectionArray = uniqueDeinflectionsMap.get(term); - if (typeof deinflectionArray === 'undefined') { - deinflectionArray = []; - uniqueDeinflectionTerms.push(term); - uniqueDeinflectionArrays.push(deinflectionArray); - uniqueDeinflectionsMap.set(term, deinflectionArray); - } - deinflectionArray.push(deinflection); + const {matchType} = options; + + await this._addEntriesToDeinflections(deinflections, enabledDictionaryMap, matchType); + + deinflections = deinflections.filter((deinflection) => deinflection.databaseEntries.length > 0); + + if (options.deinflectionSource !== 'algorithm') { + const dictionaryDeinflections = await this._getDictionaryDeinflections(deinflections, enabledDictionaryMap, matchType); + deinflections.push(...dictionaryDeinflections); } + return deinflections; + } + + /** + * @param {import('translation-internal').DatabaseDeinflection[]} deinflections + * @param {Map} enabledDictionaryMap + * @param {import('dictionary').TermSourceMatchType} matchType + * @returns {Promise} + */ + async _getDictionaryDeinflections(deinflections, enabledDictionaryMap, matchType) { + /** @type {import('translation-internal').DatabaseDeinflection[]} */ + const dictionaryDeinflections = []; + deinflections.forEach((deinflection) => { + const {originalText, transformedText, inflectionHypotheses: algHypotheses, databaseEntries} = deinflection; + databaseEntries.forEach((entry) => { + const {formOf, inflectionHypotheses} = entry; + if (formOf) { + const hypotheses = (inflectionHypotheses || []) + .flatMap((hypothesis) => algHypotheses.map(({inflections}) => { + return { + source: inflections.length === 0 ? 'dictionary' : 'both', + inflections: [...inflections, ...hypothesis] + }; + })); + + const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, hypotheses); + dictionaryDeinflections.push(dictionaryDeinflection); + } + }); + }); + + await this._addEntriesToDeinflections(dictionaryDeinflections, enabledDictionaryMap, matchType, false); + + return dictionaryDeinflections; + } + + /** + * @param {import('translation-internal').DatabaseDeinflection[]} deinflections + * @param {Map} enabledDictionaryMap + * @param {import('dictionary').TermSourceMatchType} matchType + * @param {boolean} partsOfSpeechFilter + */ + async _addEntriesToDeinflections(deinflections, enabledDictionaryMap, matchType, partsOfSpeechFilter = true) { + const uniqueDeinflectionsMap = this._groupDeinflectionsByTerm(deinflections); + const uniqueDeinflectionArrays = Object.values(uniqueDeinflectionsMap); + const uniqueDeinflectionTerms = Object.keys(uniqueDeinflectionsMap); - const {matchType} = options; const databaseEntries = await this._database.findTermsBulk(uniqueDeinflectionTerms, enabledDictionaryMap, matchType); + this._matchEntriesToDeinflections(databaseEntries, uniqueDeinflectionArrays, partsOfSpeechFilter); + } + /** + * @param {import('translation-internal').DatabaseDeinflection[]} deinflections + * @returns {Map} + */ + _groupDeinflectionsByTerm(deinflections) { + return deinflections.reduce((map, deinflection) => { + const term = deinflection.deinflectedText; + const deinflectionArray = map.get(term) || []; + deinflectionArray.push(deinflection); + map.set(term, deinflectionArray); + return map; + }, /** @type {Map} */ new Map()); + } + + /** + * @param {import('dictionary-database').TermEntry[]} databaseEntries + * @param {import('translation-internal').DatabaseDeinflection[][]} uniqueDeinflectionArrays + * @param {boolean} partsOfSpeechFilter + */ + _matchEntriesToDeinflections(databaseEntries, uniqueDeinflectionArrays, partsOfSpeechFilter) { for (const databaseEntry of databaseEntries) { const definitionRules = Deinflector.rulesToRuleFlags(databaseEntry.rules); for (const deinflection of uniqueDeinflectionArrays[databaseEntry.index]) { const deinflectionRules = deinflection.rules; - if (deinflectionRules === 0 || (definitionRules & deinflectionRules) !== 0) { + if (!partsOfSpeechFilter || deinflectionRules === 0 || (definitionRules & deinflectionRules) !== 0) { deinflection.databaseEntries.push(databaseEntry); } } } - - return deinflections; } // Deinflections and text transformations @@ -328,7 +392,7 @@ export class Translator { * @param {import('translation').FindTermsOptions} options * @returns {import('translation-internal').DatabaseDeinflection[]} */ - _getAllDeinflections(text, options) { + _getAlgorithmDeinflections(text, options) { /** @type {import('translation-internal').TextDeinflectionOptionsArrays} */ const textOptionVariantArray = [ this._getTextReplacementsVariants(options), @@ -472,11 +536,11 @@ export class Translator { * @param {string} transformedText * @param {string} deinflectedText * @param {import('translation-internal').DeinflectionRuleFlags} rules - * @param {string[]} reasons + * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses * @returns {import('translation-internal').DatabaseDeinflection} */ - _createDeinflection(originalText, transformedText, deinflectedText, rules, reasons) { - return {originalText, transformedText, deinflectedText, rules, reasons, databaseEntries: []}; + _createDeinflection(originalText, transformedText, deinflectedText, rules, inflectionHypotheses) { + return {originalText, transformedText, deinflectedText, rules, inflectionHypotheses, databaseEntries: []}; } // Term dictionary entry grouping diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index 7b040f0b23..057913edc1 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -72,7 +72,6 @@ export type TermV3 = [ export type InflectionHypothesis = string[]; - export type KanjiV1Array = KanjiV1[]; export type KanjiV1 = [ diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 596c1edc74..efa1f1b76e 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -210,7 +210,7 @@ export type TermDictionaryEntry = { /** * A list of inflections that was applied to get the term. */ - inflectionHypotheses: DictionaryData.InflectionHypothesis[]; + inflectionHypotheses: InflectionHypothesis[]; /** * A score for the dictionary entry. */ @@ -253,6 +253,11 @@ export type TermDictionaryEntry = { frequencies: TermFrequency[]; }; +export type InflectionHypothesis = { + source: string; + inflections: DictionaryData.InflectionHypothesis; +}; + /** * A term headword is a combination of a term, reading, and auxiliary information. */ diff --git a/types/ext/translation-internal.d.ts b/types/ext/translation-internal.d.ts index 5845b45d44..572e6aeb58 100644 --- a/types/ext/translation-internal.d.ts +++ b/types/ext/translation-internal.d.ts @@ -16,6 +16,7 @@ */ import type * as DictionaryDatabase from './dictionary-database'; +import type * as Dictionary from './dictionary'; import type * as Translation from './translation'; export type TextDeinflectionOptions = [ @@ -60,6 +61,6 @@ export type DatabaseDeinflection = { transformedText: string; deinflectedText: string; rules: DeinflectionRuleFlags; - reasons: string[]; + inflectionHypotheses: Dictionary.InflectionHypothesis[]; databaseEntries: DictionaryDatabase.TermEntry[]; }; From e3ed96ce0d8578fbef74659acd15575b89e4ee23 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Tue, 2 Jan 2024 22:50:10 +0100 Subject: [PATCH 03/28] fix v3 --- ext/data/schemas/dictionary-term-bank-v3-schema.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ext/data/schemas/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json index cce0d1a9ab..c6b3145eba 100644 --- a/ext/data/schemas/dictionary-term-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-bank-v3-schema.json @@ -1,5 +1,5 @@ { - "$id": "dictionaryTermBankV4", + "$id": "dictionaryTermBankV3", "$schema": "http://json-schema.org/draft-07/schema#", "definitions": { "structuredContent": { @@ -545,11 +545,11 @@ "description": "String of space-separated tags for the term. An empty string is treated as no tags." }, { - "type": ["string"], + "type": "string", "description": "Lemma (uninflected) form of the term. Empty for lemmas." }, { - "type": ["array"], + "type": "array", "description": "Array of possible inflection combinations that produce the term. Empty for lemmas.", "items": { "type": "array", From 3cd200e0ff507eac895b710984b072d62631ca07 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 12:38:36 +0100 Subject: [PATCH 04/28] wip --- ext/css/display.css | 6 +-- ext/data/schemas/options-schema.json | 7 ++- ext/js/background/backend.js | 11 +++-- ext/js/data/options-util.js | 12 +++++ ext/js/display/display-generator.js | 39 +++++++++++++-- ext/js/language/translator.js | 47 +++++++++++-------- .../pages/settings/dictionary-controller.js | 12 ++++- ext/settings.html | 18 +++++++ test/data/translator-test-inputs.json | 3 +- test/options-util.test.js | 3 +- types/ext/dictionary.d.ts | 4 +- types/ext/settings.d.ts | 1 + types/ext/translation.d.ts | 4 ++ 13 files changed, 130 insertions(+), 37 deletions(-) diff --git a/ext/css/display.css b/ext/css/display.css index 0726655e74..e44deb944a 100644 --- a/ext/css/display.css +++ b/ext/css/display.css @@ -809,11 +809,11 @@ button.action-button:active { /* Inflections */ -.inflection-hypotheses-list{ - padding-inline-start: 20px; +.inflection-hypotheses{ + padding-inline-start: 0; + list-style-type: none; } .inflection-hypothesis { - display: inline-block; color: var(--reason-text-color); } .inflection-hypothesis:empty { diff --git a/ext/data/schemas/options-schema.json b/ext/data/schemas/options-schema.json index 65c4102e93..0aab6e697e 100644 --- a/ext/data/schemas/options-schema.json +++ b/ext/data/schemas/options-schema.json @@ -822,7 +822,8 @@ "priority", "enabled", "allowSecondarySearches", - "definitionsCollapsible" + "definitionsCollapsible", + "useDeinflections" ], "properties": { "name": { @@ -845,6 +846,10 @@ "type": "string", "enum": ["not-collapsible", "expanded", "collapsed", "force-collapsed", "force-expanded"], "default": "not-collapsible" + }, + "useDeinflections": { + "type": "boolean", + "default": true } } } diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 481567b55f..a9f18b516f 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -2427,7 +2427,8 @@ export class Backend { enabledDictionaryMap.set(mainDictionary, { index: enabledDictionaryMap.size, priority: 0, - allowSecondarySearches: false + allowSecondarySearches: false, + useDeinflections: true }); excludeDictionaryDefinitions = new Set(); excludeDictionaryDefinitions.add(mainDictionary); @@ -2473,10 +2474,12 @@ export class Backend { const enabledDictionaryMap = new Map(); for (const dictionary of options.dictionaries) { if (!dictionary.enabled) { continue; } - enabledDictionaryMap.set(dictionary.name, { + const {name, priority, allowSecondarySearches, useDeinflections} = dictionary; + enabledDictionaryMap.set(name, { index: enabledDictionaryMap.size, - priority: dictionary.priority, - allowSecondarySearches: dictionary.allowSecondarySearches + priority, + allowSecondarySearches, + useDeinflections }); } return enabledDictionaryMap; diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index c6acf37309..9d7fa636bb 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -1144,6 +1144,18 @@ export class OptionsUtil { return options; } + /** + * - Added dictionaries[].useDeinflections. + * @type {import('options-util').UpdateFunction} + */ + _updateVersion23(options) { + for (const {options: profileOptions} of options.profiles) { + for (const dictionary of profileOptions.dictionaries) { + dictionary.useDeinflections = true; + } + } + } + /** * @param {string} url * @returns {Promise} diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 2ec5a7f434..fef2a230c8 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -357,16 +357,45 @@ export class DisplayGenerator { } /** - * @param {import('dictionary-data').InflectionHypothesis} inflectionHypothesis - * @returns {DocumentFragment} + * @param {import('dictionary').InflectionHypothesis} inflectionHypothesis + * @returns {?HTMLElement} */ _createInflectionHypothesis(inflectionHypothesis) { - const fragment = this._templates.instantiateFragment('inflection-hypothesis'); - const node = this._querySelector(fragment, '.inflection-hypothesis'); - this._appendMultiple(node, this._createTermInflection.bind(this), inflectionHypothesis); + const {source, inflections} = inflectionHypothesis; + if (!Array.isArray(inflections) || inflections.length === 0) { return null; } + const fragment = this._instantiate('inflection-hypothesis'); + + const sourceIcon = this._getInflectionSourceIcon(source); + + fragment.appendChild(sourceIcon); + + this._appendMultiple(fragment, this._createTermInflection.bind(this), inflections); return fragment; } + /** + * @param {import('dictionary').InflectionSource} source + * @returns {HTMLElement} + */ + _getInflectionSourceIcon(source) { + const icon = document.createElement('span'); + icon.style.marginRight = '0.5em'; + switch (source) { + case 'dictionary': + icon.textContent = '📖'; + icon.title = 'Dictionary Deinflection'; + return icon; + case 'algorithm': + icon.textContent = '🧩'; + icon.title = 'Algorithm Deinflection'; + return icon; + case 'both': + icon.textContent = '📖🧩'; + icon.title = 'Dictionary and Algorithm Deinflection'; + return icon; + } + } + /** * @param {string} inflection * @returns {DocumentFragment} diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 1aaef897d5..726ff40ebc 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -299,10 +299,9 @@ export class Translator { deinflections = deinflections.filter((deinflection) => deinflection.databaseEntries.length > 0); - if (options.deinflectionSource !== 'algorithm') { - const dictionaryDeinflections = await this._getDictionaryDeinflections(deinflections, enabledDictionaryMap, matchType); - deinflections.push(...dictionaryDeinflections); - } + const dictionaryDeinflections = await this._getDictionaryDeinflections(deinflections, enabledDictionaryMap, matchType); + deinflections.push(...dictionaryDeinflections); + return deinflections; } @@ -318,12 +317,16 @@ export class Translator { deinflections.forEach((deinflection) => { const {originalText, transformedText, inflectionHypotheses: algHypotheses, databaseEntries} = deinflection; databaseEntries.forEach((entry) => { + const entryDictionary = enabledDictionaryMap.get(entry.dictionary); + const useDeinflections = entryDictionary?.useDeinflections ?? true; + if (!useDeinflections) { return; } + const {formOf, inflectionHypotheses} = entry; if (formOf) { const hypotheses = (inflectionHypotheses || []) .flatMap((hypothesis) => algHypotheses.map(({inflections}) => { return { - source: inflections.length === 0 ? 'dictionary' : 'both', + source: /** @type {import('dictionary').InflectionSource} */ (inflections.length === 0 ? 'dictionary' : 'both'), inflections: [...inflections, ...hypothesis] }; })); @@ -347,8 +350,8 @@ export class Translator { */ async _addEntriesToDeinflections(deinflections, enabledDictionaryMap, matchType, partsOfSpeechFilter = true) { const uniqueDeinflectionsMap = this._groupDeinflectionsByTerm(deinflections); - const uniqueDeinflectionArrays = Object.values(uniqueDeinflectionsMap); - const uniqueDeinflectionTerms = Object.keys(uniqueDeinflectionsMap); + const uniqueDeinflectionArrays = Array.from(uniqueDeinflectionsMap.values()); + const uniqueDeinflectionTerms = Array.from(uniqueDeinflectionsMap.keys()); const databaseEntries = await this._database.findTermsBulk(uniqueDeinflectionTerms, enabledDictionaryMap, matchType); this._matchEntriesToDeinflections(databaseEntries, uniqueDeinflectionArrays, partsOfSpeechFilter); @@ -359,13 +362,14 @@ export class Translator { * @returns {Map} */ _groupDeinflectionsByTerm(deinflections) { - return deinflections.reduce((map, deinflection) => { + const result = deinflections.reduce((map, deinflection) => { const term = deinflection.deinflectedText; const deinflectionArray = map.get(term) || []; deinflectionArray.push(deinflection); map.set(term, deinflectionArray); return map; }, /** @type {Map} */ new Map()); + return result; } /** @@ -443,7 +447,12 @@ export class Translator { used.add(source); const rawSource = sourceMap.source.substring(0, sourceMap.getSourceLength(i)); for (const {term, rules, reasons} of /** @type {Deinflector} */ (this._deinflector).deinflect(source)) { - deinflections.push(this._createDeinflection(rawSource, source, term, rules, reasons)); + /** @type {import('dictionary').InflectionHypothesis} */ + const inflectionHypothesis = { + source: 'algorithm', + inflections: reasons + }; + deinflections.push(this._createDeinflection(rawSource, source, term, rules, [inflectionHypothesis])); } } } @@ -698,8 +707,8 @@ export class Translator { _groupDictionaryEntriesByHeadword(dictionaryEntries, tagAggregator) { const groups = new Map(); for (const dictionaryEntry of dictionaryEntries) { - const {inflections, headwords: [{term, reading}]} = dictionaryEntry; - const key = this._createMapKey([term, reading, ...inflections]); + const {inflectionHypotheses, headwords: [{term, reading}]} = dictionaryEntry; + const key = this._createMapKey([term, reading, ...inflectionHypotheses]); let groupDictionaryEntries = groups.get(key); if (typeof groupDictionaryEntries === 'undefined') { groupDictionaryEntries = []; @@ -1522,7 +1531,7 @@ export class Translator { /** * @param {boolean} isPrimary - * @param {string[]} inflections + * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses * @param {number} score * @param {number} dictionaryIndex * @param {number} dictionaryPriority @@ -1532,11 +1541,11 @@ export class Translator { * @param {import('dictionary').TermDefinition[]} definitions * @returns {import('dictionary').TermDictionaryEntry} */ - _createTermDictionaryEntry(isPrimary, inflections, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { + _createTermDictionaryEntry(isPrimary, inflectionHypotheses, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { return { type: 'term', isPrimary, - inflections, + inflectionHypotheses, score, frequencyOrder: 0, dictionaryIndex, @@ -1555,13 +1564,13 @@ export class Translator { * @param {string} originalText * @param {string} transformedText * @param {string} deinflectedText - * @param {string[]} reasons + * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses * @param {boolean} isPrimary * @param {Map} enabledDictionaryMap * @param {TranslatorTagAggregator} tagAggregator * @returns {import('dictionary').TermDictionaryEntry} */ - _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, reasons, isPrimary, enabledDictionaryMap, tagAggregator) { + _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionHypotheses, isPrimary, enabledDictionaryMap, tagAggregator) { const {matchType, matchSource, term, reading: rawReading, definitionTags, termTags, definitions, score, dictionary, id, sequence: rawSequence, rules} = databaseEntry; const reading = (rawReading.length > 0 ? rawReading : term); const {index: dictionaryIndex, priority: dictionaryPriority} = this._getDictionaryOrder(dictionary, enabledDictionaryMap); @@ -1580,7 +1589,7 @@ export class Translator { return this._createTermDictionaryEntry( isPrimary, - reasons, + inflectionHypotheses, score, dictionaryIndex, dictionaryPriority, @@ -1631,7 +1640,7 @@ export class Translator { if (dictionaryEntry.isPrimary) { isPrimary = true; maxTransformedTextLength = Math.max(maxTransformedTextLength, dictionaryEntry.maxTransformedTextLength); - const dictionaryEntryInflections = dictionaryEntry.inflections; + const dictionaryEntryInflections = dictionaryEntry.inflectionHypotheses; if (inflections === null || dictionaryEntryInflections.length < inflections.length) { inflections = dictionaryEntryInflections; } @@ -1843,7 +1852,7 @@ export class Translator { if (i !== 0) { return i; } // Sort by the number of inflection reasons - i = v1.inflections.length - v2.inflections.length; + i = v1.inflectionHypotheses.length - v2.inflectionHypotheses.length; if (i !== 0) { return i; } // Sort by how many terms exactly match the source (e.g. for exact kana prioritization) diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 0132fe9e18..e71e1126c6 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -164,7 +164,7 @@ class DictionaryEntry { /** */ _showDetails() { - const {title, revision, version, prefixWildcardsSupported} = this._dictionaryInfo; + const {title, revision, version, counts, prefixWildcardsSupported} = this._dictionaryInfo; const modal = this._dictionaryController.modalController.getModal('dictionary-details'); if (modal === null) { return; } @@ -181,12 +181,19 @@ class DictionaryEntry { const wildcardSupportedElement = querySelectorNotNull(modal.node, '.dictionary-prefix-wildcard-searches-supported'); /** @type {HTMLElement} */ const detailsTableElement = querySelectorNotNull(modal.node, '.dictionary-details-table'); + /** @type {HTMLElement} */ + const useDeinflectionsSetting = querySelectorNotNull(modal.node, '.dictionary-use-deinflections-setting'); + /** @type {HTMLElement} */ + const useDeinflectionsToggle = querySelectorNotNull(useDeinflectionsSetting, '.dictionary-use-deinflections-toggle'); titleElement.textContent = title; versionElement.textContent = `rev.${revision}`; outdateElement.hidden = (version >= 3); countsElement.textContent = this._counts !== null ? JSON.stringify(this._counts, null, 4) : ''; wildcardSupportedElement.checked = prefixWildcardsSupported; + useDeinflectionsSetting.hidden = !counts.terms.total; + useDeinflectionsToggle.dataset.setting = `dictionaries[${this._index}].partsOfSpeechFilter`; + this._setupDetails(detailsTableElement); modal.setVisible(true); @@ -513,7 +520,8 @@ export class DictionaryController { priority: 0, enabled, allowSecondarySearches: false, - definitionsCollapsible: 'not-collapsible' + definitionsCollapsible: 'not-collapsible', + useDeinflections: true }; } diff --git a/ext/settings.html b/ext/settings.html index 8f432eb45f..a8e6a54e08 100644 --- a/ext/settings.html +++ b/ext/settings.html @@ -2673,6 +2673,24 @@

Yomitan Settings

Hide…

+ +
diff --git a/test/data/translator-test-inputs.json b/test/data/translator-test-inputs.json index ec7f1a1121..063e6d85d3 100644 --- a/test/data/translator-test-inputs.json +++ b/test/data/translator-test-inputs.json @@ -34,7 +34,8 @@ { "index": 0, "priority": 0, - "allowSecondarySearches": false + "allowSecondarySearches": false, + "useDeinflections": true } ] ] diff --git a/test/options-util.test.js b/test/options-util.test.js index daffe886f5..24349f1bf0 100644 --- a/test/options-util.test.js +++ b/test/options-util.test.js @@ -425,7 +425,8 @@ function createProfileOptionsUpdatedTestData1() { priority: 0, enabled: true, allowSecondarySearches: false, - definitionsCollapsible: 'not-collapsible' + definitionsCollapsible: 'not-collapsible', + useDeinflections: true } ], parsing: { diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index efa1f1b76e..468a8034db 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -254,10 +254,12 @@ export type TermDictionaryEntry = { }; export type InflectionHypothesis = { - source: string; + source: InflectionSource; inflections: DictionaryData.InflectionHypothesis; }; +export type InflectionSource = 'algorithm' | 'dictionary' | 'both'; + /** * A term headword is a combination of a term, reading, and auxiliary information. */ diff --git a/types/ext/settings.d.ts b/types/ext/settings.d.ts index 25ea46d9fc..acb2622389 100644 --- a/types/ext/settings.d.ts +++ b/types/ext/settings.d.ts @@ -258,6 +258,7 @@ export type DictionaryOptions = { enabled: boolean; allowSecondarySearches: boolean; definitionsCollapsible: DictionaryDefinitionsCollapsible; + useDeinflections: boolean; }; export type ParsingOptions = { diff --git a/types/ext/translation.d.ts b/types/ext/translation.d.ts index c8938e0001..4adfe9f1d0 100644 --- a/types/ext/translation.d.ts +++ b/types/ext/translation.d.ts @@ -173,6 +173,10 @@ export type FindTermDictionary = { * Whether or not secondary term searches are allowed for this dictionary. */ allowSecondarySearches: boolean; + /** + * Whether to use the deinflections from this dictionary. + */ + useDeinflections: boolean; }; export type TermEnabledDictionaryMap = Map; From 41a5c4bec5363c499faab0f82e1e860640fce4ba Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 15:52:05 +0100 Subject: [PATCH 05/28] fix tests --- .../dictionary-term-bank-v3-schema.json | 35 +- .../default-anki-field-templates.handlebars | 19 +- ext/js/data/sandbox/anki-note-data-creator.js | 4 +- ext/js/dictionary/dictionary-database.js | 6 +- ext/js/dictionary/dictionary-importer.js | 6 +- ext/js/language/translator.js | 25 +- .../translator-test-results-note-data1.json | 678 +++++++++++++--- test/data/translator-test-results.json | 756 ++++++++++++++---- types/ext/anki-templates.d.ts | 2 +- types/ext/dictionary-data.d.ts | 10 +- types/ext/dictionary-database.d.ts | 4 - types/ext/dictionary.d.ts | 2 +- 12 files changed, 1231 insertions(+), 316 deletions(-) diff --git a/ext/data/schemas/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json index c6b3145eba..4a79d3598f 100644 --- a/ext/data/schemas/dictionary-term-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-bank-v3-schema.json @@ -380,7 +380,6 @@ "type": "array", "description": "Information about a single term.", "minItems": 8, - "maxItems": 10, "additionalItems": false, "items": [ { @@ -532,6 +531,24 @@ } } ] + }, + { + "type":"array", + "description": "Deinflection of the term to a non-inflected term.", + "items": [ + { + "type": "string", + "description": "The deinflected term." + }, + { + "type": "array", + "description": "A possible inflection combination that produced the inflected term", + "items": { + "type": "string", + "description": "An inflection." + } + } + ] } ] } @@ -543,22 +560,6 @@ { "type": "string", "description": "String of space-separated tags for the term. An empty string is treated as no tags." - }, - { - "type": "string", - "description": "Lemma (uninflected) form of the term. Empty for lemmas." - }, - { - "type": "array", - "description": "Array of possible inflection combinations that produce the term. Empty for lemmas.", - "items": { - "type": "array", - "description": "An inflection combination.", - "items": { - "type": "string", - "description": "An inflection." - } - } } ] } diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index f23b9d0be9..9ae37573e7 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -261,11 +261,20 @@ {{/inline}} {{#*inline "conjugation"}} - {{~#if definition.reasons~}} - {{~#each definition.reasons~}} - {{~#if (op ">" @index 0)}} « {{/if~}} - {{.}} - {{~/each~}} + {{~#if (op ">" definition.inflectionHypotheses.length 0)~}} + {{~#if (op ">" definition.inflectionHypotheses.length 1)~}} + {{~set "multiple" true~}} + {{~/if~}} + {{~#if (get "multiple")~}}
    {{/if~}} + {{~#each definition.inflectionHypotheses~}} + {{~#if (get "multiple")~}}
  • {{/if~}} + {{~#each inflections~}} + {{~#if (op ">" @index 0)}} « {{/if~}} + {{.}} + {{~/each~}} + {{~#if (get "multiple")~}}
  • {{/if~}} + {{~/each~}} + {{~#if (get "multiple")~}}
{{/if~}} {{~/if~}} {{/inline}} diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index c0a1186980..da1f80a0d5 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -376,7 +376,7 @@ export class AnkiNoteDataCreator { case 'merge': type = 'termMerged'; break; } - const {inflections, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry; + const {inflectionHypotheses, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry; let {url} = context; if (typeof url !== 'string') { url = ''; } @@ -401,7 +401,7 @@ export class AnkiNoteDataCreator { source: (primarySource !== null ? primarySource.transformedText : null), rawSource: (primarySource !== null ? primarySource.originalText : null), sourceTerm: (type !== 'termMerged' ? (primarySource !== null ? primarySource.deinflectedText : null) : void 0), - reasons: inflections, + inflectionHypotheses, score, isPrimary: (type === 'term' ? dictionaryEntry.isPrimary : void 0), get sequence() { return self.getCachedValue(sequence); }, diff --git a/ext/js/dictionary/dictionary-database.js b/ext/js/dictionary/dictionary-database.js index fb3a7757a1..1668d2b93f 100644 --- a/ext/js/dictionary/dictionary-database.js +++ b/ext/js/dictionary/dictionary-database.js @@ -578,7 +578,7 @@ export class DictionaryDatabase { * @returns {import('dictionary-database').TermEntry} */ _createTerm(matchSource, matchType, row, index) { - const {sequence, reading, score, dictionary, formOf, inflectionHypotheses} = row; + const {sequence, reading, score, dictionary} = row; return { index, matchType, @@ -592,9 +592,7 @@ export class DictionaryDatabase { score, dictionary, id: row.id, - sequence: typeof sequence === 'number' ? sequence : -1, - formOf, - inflectionHypotheses + sequence: typeof sequence === 'number' ? sequence : -1 }; } diff --git a/ext/js/dictionary/dictionary-importer.js b/ext/js/dictionary/dictionary-importer.js index b5d040d4a3..05b30eae35 100644 --- a/ext/js/dictionary/dictionary-importer.js +++ b/ext/js/dictionary/dictionary-importer.js @@ -159,7 +159,7 @@ export class DictionaryImporter { const glossaryList = entry.glossary; for (let j = 0, jj = glossaryList.length; j < jj; ++j) { const glossary = glossaryList[j]; - if (typeof glossary !== 'object' || glossary === null) { continue; } + if (typeof glossary !== 'object' || glossary === null || Array.isArray(glossary)) { continue; } glossaryList[j] = this._formatDictionaryTermGlossaryObject(glossary, entry, requirements); } if ((i % formatProgressInterval) === 0) { @@ -613,10 +613,10 @@ export class DictionaryImporter { * @returns {import('dictionary-database').DatabaseTermEntry} */ _convertTermBankEntryV3(entry, dictionary) { - let [expression, reading, definitionTags, rules, score, glossary, sequence, termTags, formOf, inflectionHypotheses] = entry; + let [expression, reading, definitionTags, rules, score, glossary, sequence, termTags] = entry; expression = this._normalizeTermOrReading(expression); reading = this._normalizeTermOrReading(reading.length > 0 ? reading : expression); - return {expression, reading, definitionTags, rules, score, glossary, sequence, termTags, formOf, inflectionHypotheses, dictionary}; + return {expression, reading, definitionTags, rules, score, glossary, sequence, termTags, dictionary}; } /** diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 726ff40ebc..a08e799ffe 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -255,8 +255,6 @@ export class Translator { continue; } - // TODO: make configurable - if (databaseEntry.formOf) { continue; } const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionHypotheses, true, enabledDictionaryMap, tagAggregator); dictionaryEntries.push(dictionaryEntry); @@ -317,22 +315,25 @@ export class Translator { deinflections.forEach((deinflection) => { const {originalText, transformedText, inflectionHypotheses: algHypotheses, databaseEntries} = deinflection; databaseEntries.forEach((entry) => { - const entryDictionary = enabledDictionaryMap.get(entry.dictionary); + const {dictionary, definitions} = entry; + const entryDictionary = enabledDictionaryMap.get(dictionary); const useDeinflections = entryDictionary?.useDeinflections ?? true; if (!useDeinflections) { return; } + for (const definition of definitions) { + if (Array.isArray(definition)) { + const [formOf, inflections] = definition; + if (!formOf) { continue; } - const {formOf, inflectionHypotheses} = entry; - if (formOf) { - const hypotheses = (inflectionHypotheses || []) - .flatMap((hypothesis) => algHypotheses.map(({inflections}) => { + const inflectionHypotheses = algHypotheses.map(({inflections: algInflections}) => { return { - source: /** @type {import('dictionary').InflectionSource} */ (inflections.length === 0 ? 'dictionary' : 'both'), - inflections: [...inflections, ...hypothesis] + source: /** @type {import('dictionary').InflectionSource} */ (algInflections.length === 0 ? 'dictionary' : 'both'), + inflections: [...algInflections, ...inflections] }; - })); + }); - const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, hypotheses); - dictionaryDeinflections.push(dictionaryDeinflection); + const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, inflectionHypotheses); + dictionaryDeinflections.push(dictionaryDeinflection); + } } }); }); diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index 1342a63fed..224844030d 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -341,7 +341,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 1, @@ -647,7 +652,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 2, @@ -967,7 +977,12 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 3, @@ -1273,7 +1288,12 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 3, @@ -1579,7 +1599,12 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 3, @@ -1885,7 +1910,12 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 3, @@ -2191,7 +2221,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 1, @@ -2497,7 +2532,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 2, @@ -2817,7 +2857,12 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 4, @@ -3231,7 +3276,12 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 4, @@ -3645,7 +3695,12 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 4, @@ -4059,7 +4114,12 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 4, @@ -4473,8 +4533,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -4781,8 +4846,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -5089,8 +5159,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -5397,8 +5472,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -5705,7 +5785,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 1, @@ -6011,7 +6096,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 2, @@ -6331,7 +6421,12 @@ "source": "画像", "rawSource": "画像", "sourceTerm": "画像", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 5, @@ -6485,7 +6580,12 @@ "source": "だ", "rawSource": "だ", "sourceTerm": "だ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 1, @@ -6796,7 +6896,12 @@ "source": "ダース", "rawSource": "ダース", "sourceTerm": "ダース", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 2, @@ -7116,7 +7221,12 @@ "source": "うつ", "rawSource": "うつ", "sourceTerm": "うつ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 3, @@ -7422,7 +7532,12 @@ "source": "うつ", "rawSource": "うつ", "sourceTerm": "うつ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 3, @@ -7733,7 +7848,12 @@ "source": "ぶつ", "rawSource": "ぶつ", "sourceTerm": "ぶつ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 3, @@ -8039,7 +8159,12 @@ "source": "ぶつ", "rawSource": "ぶつ", "sourceTerm": "ぶつ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 3, @@ -8350,7 +8475,12 @@ "source": "うちこむ", "rawSource": "うちこむ", "sourceTerm": "うちこむ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 4, @@ -8764,7 +8894,12 @@ "source": "うちこむ", "rawSource": "うちこむ", "sourceTerm": "うちこむ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 4, @@ -9178,8 +9313,13 @@ "source": "うち", "rawSource": "うち", "sourceTerm": "うつ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -9486,8 +9626,13 @@ "source": "うち", "rawSource": "うち", "sourceTerm": "うつ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -9799,7 +9944,12 @@ "source": "ぶちこむ", "rawSource": "ぶちこむ", "sourceTerm": "ぶちこむ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 4, @@ -10213,7 +10363,12 @@ "source": "ぶちこむ", "rawSource": "ぶちこむ", "sourceTerm": "ぶちこむ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 4, @@ -10627,8 +10782,13 @@ "source": "ぶち", "rawSource": "ぶち", "sourceTerm": "ぶつ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -10935,8 +11095,13 @@ "source": "ぶち", "rawSource": "ぶち", "sourceTerm": "ぶつ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -11248,7 +11413,12 @@ "source": "がぞう", "rawSource": "がぞう", "sourceTerm": "がぞう", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 5, @@ -11413,7 +11583,12 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "sequence": 4, "dictionary": "Test Dictionary 2", @@ -11850,7 +12025,12 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "sequence": 4, "dictionary": "Test Dictionary 2", @@ -12287,8 +12467,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "sequence": 3, @@ -12626,8 +12811,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "sequence": 3, @@ -12965,7 +13155,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "sequence": 1, "dictionary": "Test Dictionary 2", @@ -13269,7 +13464,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "sequence": 2, "dictionary": "Test Dictionary 2", @@ -13586,7 +13786,12 @@ "type": "termMerged", "source": "打ち込む", "rawSource": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "sequence": 4, "dictionary": "Test Dictionary 2", @@ -14351,8 +14556,13 @@ "type": "termMerged", "source": "打ち", "rawSource": "打ち", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "sequence": 3, @@ -14923,7 +15133,12 @@ "type": "termMerged", "source": "打", "rawSource": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "sequence": 1, "dictionary": "Test Dictionary 2", @@ -15220,7 +15435,12 @@ "type": "termMerged", "source": "打", "rawSource": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "sequence": 2, "dictionary": "Test Dictionary 2", @@ -15533,10 +15753,15 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "reasons": [ - "-te", - "progressive or perfect", - "polite past negative" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "-te", + "progressive or perfect", + "polite past negative" + ] + } ], "score": 10, "isPrimary": true, @@ -15951,10 +16176,15 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "reasons": [ - "-te", - "progressive or perfect", - "polite past negative" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "-te", + "progressive or perfect", + "polite past negative" + ] + } ], "score": 10, "isPrimary": true, @@ -16369,10 +16599,15 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "reasons": [ - "-te", - "progressive or perfect", - "polite past negative" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "-te", + "progressive or perfect", + "polite past negative" + ] + } ], "score": 1, "isPrimary": true, @@ -16787,10 +17022,15 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "reasons": [ - "-te", - "progressive or perfect", - "polite past negative" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "-te", + "progressive or perfect", + "polite past negative" + ] + } ], "score": 1, "isPrimary": true, @@ -17205,8 +17445,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -17513,8 +17758,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -17821,8 +18071,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -18129,8 +18384,13 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -18437,7 +18697,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 1, @@ -18743,7 +19008,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 2, @@ -19063,7 +19333,12 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 4, @@ -19477,7 +19752,12 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 4, @@ -19891,7 +20171,12 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 4, @@ -20305,7 +20590,12 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 4, @@ -20719,8 +21009,13 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -21027,8 +21322,13 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -21335,8 +21635,13 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -21643,8 +21948,13 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -21951,7 +22261,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 1, @@ -22257,7 +22572,12 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 2, @@ -22577,7 +22897,12 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 4, @@ -22991,7 +23316,12 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "isPrimary": true, "sequence": 4, @@ -23405,7 +23735,12 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 4, @@ -23819,7 +24154,12 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 4, @@ -24233,8 +24573,13 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -24541,8 +24886,13 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "isPrimary": true, @@ -24849,8 +25199,13 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -25157,8 +25512,13 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "isPrimary": true, @@ -25465,7 +25825,12 @@ "source": "打", "rawSource": "(打)", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 1, @@ -25771,7 +26136,12 @@ "source": "打", "rawSource": "(打)", "sourceTerm": "打", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 2, @@ -26091,8 +26461,13 @@ "source": "よみ", "rawSource": "test", "sourceTerm": "よむ", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 100, "isPrimary": true, @@ -26245,7 +26620,12 @@ "source": "つよみ", "rawSource": "つtest", "sourceTerm": "つよみ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 90, "isPrimary": true, "sequence": 7, @@ -26397,8 +26777,13 @@ "source": "よみました", "rawSource": "testました", "sourceTerm": "よむ", - "reasons": [ - "polite past" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "polite past" + ] + } ], "score": 100, "isPrimary": true, @@ -26549,7 +26934,12 @@ "type": "termMerged", "source": "うちこむ", "rawSource": "うちこむ", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "sequence": 4, "dictionary": "Test Dictionary 2", @@ -27314,8 +27704,13 @@ "type": "termMerged", "source": "うち", "rawSource": "うち", - "reasons": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "sequence": 3, @@ -27893,7 +28288,12 @@ "source": "お手前", "rawSource": "お手前", "sourceTerm": "お手前", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 9, @@ -28221,7 +28621,12 @@ "source": "番号", "rawSource": "番号", "sourceTerm": "番号", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 10, @@ -28401,7 +28806,12 @@ "source": "中腰", "rawSource": "中腰", "sourceTerm": "中腰", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 11, @@ -28581,7 +28991,12 @@ "source": "所業", "rawSource": "所業", "sourceTerm": "所業", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 12, @@ -28761,7 +29176,12 @@ "source": "土木工事", "rawSource": "土木工事", "sourceTerm": "土木工事", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 13, @@ -28941,7 +29361,12 @@ "source": "好き", "rawSource": "好き", "sourceTerm": "好き", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "isPrimary": true, "sequence": 14, @@ -29149,7 +29574,12 @@ "source": "構造", "rawSource": "構造", "sourceTerm": "構造", - "reasons": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 35, "isPrimary": true, "sequence": 101, diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index 50d97775c0..8c33c61b55 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -291,7 +291,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -454,7 +459,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -636,7 +646,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -801,7 +816,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -966,7 +986,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -1131,7 +1156,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -1296,7 +1326,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -1459,7 +1494,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -1641,7 +1681,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -1830,7 +1875,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -2019,7 +2069,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -2208,7 +2263,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -2397,8 +2457,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -2564,8 +2629,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -2731,8 +2801,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -2898,8 +2973,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -3065,7 +3145,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -3228,7 +3313,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -3410,7 +3500,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -3523,7 +3618,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -3692,7 +3792,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -3874,7 +3979,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -4039,7 +4149,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -4210,7 +4325,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -4375,7 +4495,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -4546,7 +4671,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -4735,7 +4865,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -4924,8 +5059,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -5091,8 +5231,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -5264,7 +5409,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -5453,7 +5603,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -5642,8 +5797,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -5809,8 +5969,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -5982,7 +6147,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -6105,7 +6275,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -6162,7 +6337,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -6219,7 +6399,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -6276,7 +6461,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -6333,8 +6523,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -6392,8 +6587,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -6451,8 +6651,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -6510,8 +6715,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -6569,7 +6779,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -6626,7 +6841,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -6689,7 +6909,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -6926,7 +7151,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -7163,8 +7393,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -7378,8 +7613,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -7593,7 +7833,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -7756,7 +8001,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -7938,7 +8188,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -8393,8 +8648,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -8803,7 +9063,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -8966,7 +9231,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -9148,10 +9418,15 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "-te", - "progressive or perfect", - "polite past negative" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "-te", + "progressive or perfect", + "polite past negative" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -9341,10 +9616,15 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "-te", - "progressive or perfect", - "polite past negative" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "-te", + "progressive or perfect", + "polite past negative" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -9534,10 +9814,15 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "-te", - "progressive or perfect", - "polite past negative" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "-te", + "progressive or perfect", + "polite past negative" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -9727,10 +10012,15 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "-te", - "progressive or perfect", - "polite past negative" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "-te", + "progressive or perfect", + "polite past negative" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -9920,8 +10210,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -10087,8 +10382,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -10254,8 +10554,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -10421,8 +10726,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -10588,7 +10898,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -10751,7 +11066,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -10933,7 +11253,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -11122,7 +11447,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -11311,7 +11641,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -11500,7 +11835,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -11689,8 +12029,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -11856,8 +12201,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -12023,8 +12373,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -12190,8 +12545,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -12357,7 +12717,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -12520,7 +12885,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -12702,7 +13072,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -12891,7 +13266,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -13080,7 +13460,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -13269,7 +13654,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -13458,8 +13848,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -13625,8 +14020,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -13792,8 +14192,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -13959,8 +14364,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 1, "frequencyOrder": 0, @@ -14126,7 +14536,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -14289,7 +14704,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -14471,8 +14891,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 100, "frequencyOrder": 0, @@ -14576,7 +15001,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 90, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -14679,8 +15109,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "polite past" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "polite past" + ] + } ], "score": 100, "frequencyOrder": 0, @@ -14784,7 +15219,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 10, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -15239,8 +15679,13 @@ { "type": "term", "isPrimary": true, - "inflections": [ - "masu stem" + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [ + "masu stem" + ] + } ], "score": 10, "frequencyOrder": 0, @@ -15655,7 +16100,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -15804,7 +16254,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -15899,7 +16354,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -15994,7 +16454,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -16089,7 +16554,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -16184,7 +16654,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 1, "frequencyOrder": 0, "dictionaryIndex": 0, @@ -16296,7 +16771,12 @@ { "type": "term", "isPrimary": true, - "inflections": [], + "inflectionHypotheses": [ + { + "source": "algorithm", + "inflections": [] + } + ], "score": 35, "frequencyOrder": 0, "dictionaryIndex": 0, diff --git a/types/ext/anki-templates.d.ts b/types/ext/anki-templates.d.ts index 098873e622..9b868436d5 100644 --- a/types/ext/anki-templates.d.ts +++ b/types/ext/anki-templates.d.ts @@ -172,7 +172,7 @@ export type TermDictionaryEntry = { source: string | null; rawSource: string | null; sourceTerm?: string | null; - reasons: string[]; + inflectionHypotheses: Dictionary.InflectionHypothesis[]; score: number; isPrimary?: boolean; readonly sequence: number; diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index 057913edc1..e5e59e2c9c 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -66,12 +66,8 @@ export type TermV3 = [ glossary: TermGlossary[], sequence: number, termTags: string, - formOf: string, - inflectionHypotheses: InflectionHypothesis[], ]; -export type InflectionHypothesis = string[]; - export type KanjiV1Array = KanjiV1[]; export type KanjiV1 = [ @@ -97,13 +93,17 @@ export type TermGlossary = ( TermGlossaryString | TermGlossaryText | TermGlossaryImage | - TermGlossaryStructuredContent + TermGlossaryStructuredContent | + TermGlossaryDeinflection ); export type TermGlossaryString = string; export type TermGlossaryText = {type: 'text', text: string}; export type TermGlossaryImage = {type: 'image'} & TermImage; export type TermGlossaryStructuredContent = {type: 'structured-content', content: StructuredContent.Content}; +export type TermGlossaryDeinflection = [formOf: string, InflectionHypothesis: InflectionHypothesis]; + +export type InflectionHypothesis = string[]; export type TermImage = StructuredContent.ImageElementBase & { // Compatibility properties diff --git a/types/ext/dictionary-database.d.ts b/types/ext/dictionary-database.d.ts index 93eb6144c5..3cf68543cf 100644 --- a/types/ext/dictionary-database.d.ts +++ b/types/ext/dictionary-database.d.ts @@ -51,8 +51,6 @@ export type DatabaseTermEntry = { glossary: DictionaryData.TermGlossary[]; sequence?: number; termTags?: string; - formOf?: string; - inflectionHypotheses?: DictionaryData.InflectionHypothesis[]; dictionary: string; }; @@ -72,8 +70,6 @@ export type TermEntry = { dictionary: string; id: number; sequence: number; - formOf?: string; - inflectionHypotheses?: DictionaryData.InflectionHypothesis[]; }; export type DatabaseKanjiEntry = { diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 468a8034db..6e462ae53e 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -255,7 +255,7 @@ export type TermDictionaryEntry = { export type InflectionHypothesis = { source: InflectionSource; - inflections: DictionaryData.InflectionHypothesis; + inflections: string[]; }; export type InflectionSource = 'algorithm' | 'dictionary' | 'both'; From c225ff1ff90d154a69f3e42660342b8a59802034 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 15:56:04 +0100 Subject: [PATCH 06/28] fix maxitems --- ext/data/schemas/dictionary-term-bank-v3-schema.json | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/data/schemas/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json index 4a79d3598f..d40ea8117a 100644 --- a/ext/data/schemas/dictionary-term-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-bank-v3-schema.json @@ -380,6 +380,7 @@ "type": "array", "description": "Information about a single term.", "minItems": 8, + "maxItems": 8, "additionalItems": false, "items": [ { From ec801d65859e82ea1e4b83be33e651585576a582 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 16:22:40 +0100 Subject: [PATCH 07/28] hide deinflection definitions --- .../templates/default-anki-field-templates.handlebars | 2 +- ext/js/language/translator.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 9ae37573e7..d27ee09818 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -272,7 +272,7 @@ {{~#if (op ">" @index 0)}} « {{/if~}} {{.}} {{~/each~}} - {{~#if (get "multiple")~}}
  • {{/if~}} + {{~#if (get "multiple")~}}
  • {{/if~}} {{~/each~}} {{~#if (get "multiple")~}}{{/if~}} {{~/if~}} diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index a08e799ffe..937e2a81b6 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -295,11 +295,17 @@ export class Translator { await this._addEntriesToDeinflections(deinflections, enabledDictionaryMap, matchType); - deinflections = deinflections.filter((deinflection) => deinflection.databaseEntries.length > 0); - const dictionaryDeinflections = await this._getDictionaryDeinflections(deinflections, enabledDictionaryMap, matchType); deinflections.push(...dictionaryDeinflections); + deinflections.forEach((deinflection) => { + deinflection.databaseEntries.forEach((entry) => { + entry.definitions = entry.definitions.filter((definition) => !Array.isArray(definition)); + }); + deinflection.databaseEntries = deinflection.databaseEntries.filter((entry) => entry.definitions.length); + }); + deinflections = deinflections.filter((deinflection) => deinflection.databaseEntries.length); + return deinflections; } From a70955e54ed1ebf2c81a8e51ba53b86f5c6bcc0b Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 16:41:49 +0100 Subject: [PATCH 08/28] fix anki template --- .../default-anki-field-templates.handlebars | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index d27ee09818..f26f923e71 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -267,12 +267,14 @@ {{~/if~}} {{~#if (get "multiple")~}}
      {{/if~}} {{~#each definition.inflectionHypotheses~}} - {{~#if (get "multiple")~}}
    • {{/if~}} - {{~#each inflections~}} - {{~#if (op ">" @index 0)}} « {{/if~}} - {{.}} - {{~/each~}} - {{~#if (get "multiple")~}}
    • {{/if~}} + {{~#if (op ">" inflections.length 0)~}} + {{~#if (get "multiple")~}}
    • {{/if~}} + {{~#each inflections~}} + {{~#if (op ">" @index 0)}} « {{/if~}} + {{.}} + {{~/each~}} + {{~#if (get "multiple")~}}
    • {{/if~}} + {{~/if~}} {{~/each~}} {{~#if (get "multiple")~}}
    {{/if~}} {{~/if~}} From e6fd45304e4d69943c3f32e1264cc734892eb2d2 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 16:48:08 +0100 Subject: [PATCH 09/28] undo unnecessary change --- ext/js/dictionary/dictionary-database.js | 8 ++++---- ext/js/pages/settings/dictionary-controller.js | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ext/js/dictionary/dictionary-database.js b/ext/js/dictionary/dictionary-database.js index 1668d2b93f..02db6322a0 100644 --- a/ext/js/dictionary/dictionary-database.js +++ b/ext/js/dictionary/dictionary-database.js @@ -578,19 +578,19 @@ export class DictionaryDatabase { * @returns {import('dictionary-database').TermEntry} */ _createTerm(matchSource, matchType, row, index) { - const {sequence, reading, score, dictionary} = row; + const {sequence} = row; return { index, matchType, matchSource, term: row.expression, - reading, + reading: row.reading, definitionTags: this._splitField(row.definitionTags || row.tags), termTags: this._splitField(row.termTags), rules: this._splitField(row.rules), definitions: row.glossary, - score, - dictionary, + score: row.score, + dictionary: row.dictionary, id: row.id, sequence: typeof sequence === 'number' ? sequence : -1 }; diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index e71e1126c6..6ae14414d4 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -164,6 +164,7 @@ class DictionaryEntry { /** */ _showDetails() { + console.log(this._dictionaryInfo); const {title, revision, version, counts, prefixWildcardsSupported} = this._dictionaryInfo; const modal = this._dictionaryController.modalController.getModal('dictionary-details'); @@ -192,7 +193,7 @@ class DictionaryEntry { countsElement.textContent = this._counts !== null ? JSON.stringify(this._counts, null, 4) : ''; wildcardSupportedElement.checked = prefixWildcardsSupported; useDeinflectionsSetting.hidden = !counts.terms.total; - useDeinflectionsToggle.dataset.setting = `dictionaries[${this._index}].partsOfSpeechFilter`; + useDeinflectionsToggle.dataset.setting = `dictionaries[${this._index}].useDeinflections`; this._setupDetails(detailsTableElement); From 6c97c2677a7f43d75b74a9a4f7bc127fd27d74dc Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 16:49:43 +0100 Subject: [PATCH 10/28] delete console.log --- ext/js/pages/settings/dictionary-controller.js | 1 - 1 file changed, 1 deletion(-) diff --git a/ext/js/pages/settings/dictionary-controller.js b/ext/js/pages/settings/dictionary-controller.js index 6ae14414d4..5beda2df82 100644 --- a/ext/js/pages/settings/dictionary-controller.js +++ b/ext/js/pages/settings/dictionary-controller.js @@ -164,7 +164,6 @@ class DictionaryEntry { /** */ _showDetails() { - console.log(this._dictionaryInfo); const {title, revision, version, counts, prefixWildcardsSupported} = this._dictionaryInfo; const modal = this._dictionaryController.modalController.getModal('dictionary-details'); From 8fecd1134e8f4ecfdac188c59ec36c9e40ea07f4 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 17:06:00 +0100 Subject: [PATCH 11/28] refactor --- ext/js/language/translator.js | 39 ++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 937e2a81b6..e5a7440e6b 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -231,26 +231,9 @@ export class Translator { const existingEntry = dictionaryEntries.find((entry) => { return entry.definitions.some((definition) => definition.id === id); }); - if (!existingEntry) { continue; } - if (transformedText.length >= existingEntry.headwords[0].sources[0].transformedText.length) { - const existingHypotheses = existingEntry.inflectionHypotheses; - - /** @type {import('dictionary').InflectionHypothesis[]} */ - const newHypotheses = []; - - inflectionHypotheses.forEach(({source, inflections}) => { - const duplicate = existingHypotheses.find((hypothesis) => this._areInflectionHyphothesesEqual(hypothesis.inflections, inflections)); - if (!duplicate) { - newHypotheses.push({source, inflections}); - } else if (duplicate.source !== source) { - duplicate.source = 'both'; - } - }); - existingEntry.inflectionHypotheses = [ - ...existingEntry.inflectionHypotheses, - ...newHypotheses - ]; + if (existingEntry && transformedText.length >= existingEntry.headwords[0].sources[0].transformedText.length) { + this._mergeInflectionHypotheses(existingEntry, inflectionHypotheses); } continue; @@ -265,6 +248,24 @@ export class Translator { return {dictionaryEntries, originalTextLength}; } + /** + * + * @param {import('dictionary').TermDictionaryEntry} existingEntry + * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses + */ + _mergeInflectionHypotheses(existingEntry, inflectionHypotheses) { + const existingHypotheses = existingEntry.inflectionHypotheses; + + inflectionHypotheses.forEach(({source, inflections}) => { + const duplicate = existingHypotheses.find((hypothesis) => this._areInflectionHyphothesesEqual(hypothesis.inflections, inflections)); + if (!duplicate) { + existingEntry.inflectionHypotheses.push({source, inflections}); + } else if (duplicate.source !== source) { + duplicate.source = 'both'; + } + }); + } + /** * @param {import('dictionary-data').InflectionHypothesis} hypothesis1 * @param {import('dictionary-data').InflectionHypothesis} hypothesis2 From 0ad389daa969f283a37a9df618eb4f16906c565e Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 17:34:16 +0100 Subject: [PATCH 12/28] add set false to handlebars --- ext/data/templates/default-anki-field-templates.handlebars | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index f26f923e71..83876c4f0d 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -262,6 +262,7 @@ {{#*inline "conjugation"}} {{~#if (op ">" definition.inflectionHypotheses.length 0)~}} + {{~set "multiple" false~}} {{~#if (op ">" definition.inflectionHypotheses.length 1)~}} {{~set "multiple" true~}} {{~/if~}} From ad57485bdab6ba1780ec89482874cbffa1a8e577 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 17:36:33 +0100 Subject: [PATCH 13/28] lint --- ext/data/schemas/dictionary-term-bank-v3-schema.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/data/schemas/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json index d40ea8117a..fd3455ca14 100644 --- a/ext/data/schemas/dictionary-term-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-bank-v3-schema.json @@ -534,7 +534,7 @@ ] }, { - "type":"array", + "type": "array", "description": "Deinflection of the term to a non-inflected term.", "items": [ { From a17a46af8497919c26cc889dfe3007e6e9474ad9 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 3 Jan 2024 17:54:08 +0100 Subject: [PATCH 14/28] fix tests --- ext/css/display.css | 2 +- ext/js/language/translator.js | 4 ++-- types/ext/dictionary-data.d.ts | 6 +----- types/ext/dictionary.d.ts | 4 +++- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/ext/css/display.css b/ext/css/display.css index e44deb944a..6b688886ec 100644 --- a/ext/css/display.css +++ b/ext/css/display.css @@ -809,7 +809,7 @@ button.action-button:active { /* Inflections */ -.inflection-hypotheses{ +.inflection-hypotheses { padding-inline-start: 0; list-style-type: none; } diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index e5a7440e6b..e1d01e50e3 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -267,8 +267,8 @@ export class Translator { } /** - * @param {import('dictionary-data').InflectionHypothesis} hypothesis1 - * @param {import('dictionary-data').InflectionHypothesis} hypothesis2 + * @param {import('dictionary').Inflections} hypothesis1 + * @param {import('dictionary').Inflections} hypothesis2 * @returns {boolean} */ _areInflectionHyphothesesEqual(hypothesis1, hypothesis2) { diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index e5e59e2c9c..0e0edd5c46 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -93,17 +93,13 @@ export type TermGlossary = ( TermGlossaryString | TermGlossaryText | TermGlossaryImage | - TermGlossaryStructuredContent | - TermGlossaryDeinflection + TermGlossaryStructuredContent ); export type TermGlossaryString = string; export type TermGlossaryText = {type: 'text', text: string}; export type TermGlossaryImage = {type: 'image'} & TermImage; export type TermGlossaryStructuredContent = {type: 'structured-content', content: StructuredContent.Content}; -export type TermGlossaryDeinflection = [formOf: string, InflectionHypothesis: InflectionHypothesis]; - -export type InflectionHypothesis = string[]; export type TermImage = StructuredContent.ImageElementBase & { // Compatibility properties diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 6e462ae53e..54172f2a8d 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -255,9 +255,11 @@ export type TermDictionaryEntry = { export type InflectionHypothesis = { source: InflectionSource; - inflections: string[]; + inflections: Inflections; }; +export type Inflections = string[]; + export type InflectionSource = 'algorithm' | 'dictionary' | 'both'; /** From 1bb59d34e75ab46a342026686316660c660aae3a Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Fri, 5 Jan 2024 09:39:02 +0100 Subject: [PATCH 15/28] fix comments --- ext/js/dictionary/dictionary-data-util.js | 8 ++-- ext/js/language/translator.js | 47 +++++++++-------------- 2 files changed, 23 insertions(+), 32 deletions(-) diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index 50ae4b1194..c27e377e86 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -331,8 +331,8 @@ export class DictionaryDataUtil { const pitchAccent2 = /** @type {import('dictionary').PitchAccent} */ (pronunciation2); return ( pronunciation1.position === pitchAccent2.position && - this._areArraysEqual(pronunciation1.nasalPositions, pitchAccent2.nasalPositions) && - this._areArraysEqual(pronunciation1.devoicePositions, pitchAccent2.devoicePositions) + this.areArraysEqual(pronunciation1.nasalPositions, pitchAccent2.nasalPositions) && + this.areArraysEqual(pronunciation1.devoicePositions, pitchAccent2.devoicePositions) ); } case 'phonetic-transcription': @@ -351,7 +351,7 @@ export class DictionaryDataUtil { * @param {T[]} array2 * @returns {boolean} */ - static _areArraysEqual(array1, array2) { + static areArraysEqual(array1, array2) { const ii = array1.length; if (ii !== array2.length) { return false; } for (let i = 0; i < ii; ++i) { @@ -372,7 +372,7 @@ export class DictionaryDataUtil { for (let i = 0; i < ii; ++i) { const tag1 = tagList1[i]; const tag2 = tagList2[i]; - if (tag1.name !== tag2.name || !this._areArraysEqual(tag1.dictionaries, tag2.dictionaries)) { + if (tag1.name !== tag2.name || !this.areArraysEqual(tag1.dictionaries, tag2.dictionaries)) { return false; } } diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index e1d01e50e3..07ddecccd2 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -16,10 +16,10 @@ * along with this program. If not, see . */ +import {DictionaryDataUtil} from '../dictionary/dictionary-data-util.js'; import {RegexUtil} from '../general/regex-util.js'; import {TextSourceMap} from '../general/text-source-map.js'; import {Deinflector} from './deinflector.js'; - /** * Class which finds term and kanji dictionary entries for text. */ @@ -256,26 +256,14 @@ export class Translator { _mergeInflectionHypotheses(existingEntry, inflectionHypotheses) { const existingHypotheses = existingEntry.inflectionHypotheses; - inflectionHypotheses.forEach(({source, inflections}) => { - const duplicate = existingHypotheses.find((hypothesis) => this._areInflectionHyphothesesEqual(hypothesis.inflections, inflections)); + for (const {source, inflections} of inflectionHypotheses) { + const duplicate = existingHypotheses.find((hypothesis) => DictionaryDataUtil.areArraysEqual(hypothesis.inflections.sort(), inflections.sort())); if (!duplicate) { existingEntry.inflectionHypotheses.push({source, inflections}); } else if (duplicate.source !== source) { duplicate.source = 'both'; } - }); - } - - /** - * @param {import('dictionary').Inflections} hypothesis1 - * @param {import('dictionary').Inflections} hypothesis2 - * @returns {boolean} - */ - _areInflectionHyphothesesEqual(hypothesis1, hypothesis2) { - const set1 = new Set(hypothesis1); - const set2 = new Set(hypothesis2); - - return set1.size === set2.size && [...set1].every((x) => set2.has(x)); + } } /** @@ -299,12 +287,12 @@ export class Translator { const dictionaryDeinflections = await this._getDictionaryDeinflections(deinflections, enabledDictionaryMap, matchType); deinflections.push(...dictionaryDeinflections); - deinflections.forEach((deinflection) => { - deinflection.databaseEntries.forEach((entry) => { + for (const deinflection of deinflections) { + for (const entry of deinflection.databaseEntries) { entry.definitions = entry.definitions.filter((definition) => !Array.isArray(definition)); - }); + } deinflection.databaseEntries = deinflection.databaseEntries.filter((entry) => entry.definitions.length); - }); + } deinflections = deinflections.filter((deinflection) => deinflection.databaseEntries.length); return deinflections; @@ -358,8 +346,8 @@ export class Translator { */ async _addEntriesToDeinflections(deinflections, enabledDictionaryMap, matchType, partsOfSpeechFilter = true) { const uniqueDeinflectionsMap = this._groupDeinflectionsByTerm(deinflections); - const uniqueDeinflectionArrays = Array.from(uniqueDeinflectionsMap.values()); - const uniqueDeinflectionTerms = Array.from(uniqueDeinflectionsMap.keys()); + const uniqueDeinflectionArrays = [...uniqueDeinflectionsMap.values()]; + const uniqueDeinflectionTerms = [...uniqueDeinflectionsMap.keys()]; const databaseEntries = await this._database.findTermsBulk(uniqueDeinflectionTerms, enabledDictionaryMap, matchType); this._matchEntriesToDeinflections(databaseEntries, uniqueDeinflectionArrays, partsOfSpeechFilter); @@ -370,13 +358,16 @@ export class Translator { * @returns {Map} */ _groupDeinflectionsByTerm(deinflections) { - const result = deinflections.reduce((map, deinflection) => { - const term = deinflection.deinflectedText; - const deinflectionArray = map.get(term) || []; + const result = new Map(); + for (const deinflection of deinflections) { + const {deinflectedText} = deinflection; + let deinflectionArray = result.get(deinflectedText); + if (typeof deinflectionArray === 'undefined') { + deinflectionArray = []; + result.set(deinflectedText, deinflectionArray); + } deinflectionArray.push(deinflection); - map.set(term, deinflectionArray); - return map; - }, /** @type {Map} */ new Map()); + } return result; } From 33fc672c1bc6dfc359ecc5360c20a015e3eb23ea Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Fri, 5 Jan 2024 09:55:12 +0100 Subject: [PATCH 16/28] fix --- ext/js/language/translator.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 07ddecccd2..afc40d19b2 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -257,7 +257,10 @@ export class Translator { const existingHypotheses = existingEntry.inflectionHypotheses; for (const {source, inflections} of inflectionHypotheses) { - const duplicate = existingHypotheses.find((hypothesis) => DictionaryDataUtil.areArraysEqual(hypothesis.inflections.sort(), inflections.sort())); + const duplicate = existingHypotheses.find((hypothesis) => DictionaryDataUtil.areArraysEqual( + [...hypothesis.inflections].sort(), + [...inflections].sort() + )); if (!duplicate) { existingEntry.inflectionHypotheses.push({source, inflections}); } else if (duplicate.source !== source) { From f159b39c89c4083c4ca9efd57e540cfc14147771 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Tue, 9 Jan 2024 09:38:14 +0100 Subject: [PATCH 17/28] use Map in areArraysEqualIgnoreOrder --- ext/js/dictionary/dictionary-data-util.js | 8 +++--- ext/js/language/translator.js | 35 +++++++++++++++++++---- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js index c27e377e86..50ae4b1194 100644 --- a/ext/js/dictionary/dictionary-data-util.js +++ b/ext/js/dictionary/dictionary-data-util.js @@ -331,8 +331,8 @@ export class DictionaryDataUtil { const pitchAccent2 = /** @type {import('dictionary').PitchAccent} */ (pronunciation2); return ( pronunciation1.position === pitchAccent2.position && - this.areArraysEqual(pronunciation1.nasalPositions, pitchAccent2.nasalPositions) && - this.areArraysEqual(pronunciation1.devoicePositions, pitchAccent2.devoicePositions) + this._areArraysEqual(pronunciation1.nasalPositions, pitchAccent2.nasalPositions) && + this._areArraysEqual(pronunciation1.devoicePositions, pitchAccent2.devoicePositions) ); } case 'phonetic-transcription': @@ -351,7 +351,7 @@ export class DictionaryDataUtil { * @param {T[]} array2 * @returns {boolean} */ - static areArraysEqual(array1, array2) { + static _areArraysEqual(array1, array2) { const ii = array1.length; if (ii !== array2.length) { return false; } for (let i = 0; i < ii; ++i) { @@ -372,7 +372,7 @@ export class DictionaryDataUtil { for (let i = 0; i < ii; ++i) { const tag1 = tagList1[i]; const tag2 = tagList2[i]; - if (tag1.name !== tag2.name || !this.areArraysEqual(tag1.dictionaries, tag2.dictionaries)) { + if (tag1.name !== tag2.name || !this._areArraysEqual(tag1.dictionaries, tag2.dictionaries)) { return false; } } diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index afc40d19b2..23a7bfc2a4 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -16,7 +16,6 @@ * along with this program. If not, see . */ -import {DictionaryDataUtil} from '../dictionary/dictionary-data-util.js'; import {RegexUtil} from '../general/regex-util.js'; import {TextSourceMap} from '../general/text-source-map.js'; import {Deinflector} from './deinflector.js'; @@ -249,7 +248,6 @@ export class Translator { } /** - * * @param {import('dictionary').TermDictionaryEntry} existingEntry * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses */ @@ -257,10 +255,7 @@ export class Translator { const existingHypotheses = existingEntry.inflectionHypotheses; for (const {source, inflections} of inflectionHypotheses) { - const duplicate = existingHypotheses.find((hypothesis) => DictionaryDataUtil.areArraysEqual( - [...hypothesis.inflections].sort(), - [...inflections].sort() - )); + const duplicate = existingHypotheses.find((hypothesis) => this._areArraysEqualIgnoreOrder(hypothesis.inflections, inflections)); if (!duplicate) { existingEntry.inflectionHypotheses.push({source, inflections}); } else if (duplicate.source !== source) { @@ -269,6 +264,34 @@ export class Translator { } } + /** + * @param {string[]} array1 + * @param {string[]} array2 + * @returns {boolean} + */ + _areArraysEqualIgnoreOrder(array1, array2) { + if (array1.length !== array2.length) { + return false; + } + + const frequencyCounter = new Map(); + + for (const element of array1) { + frequencyCounter.set(element, (frequencyCounter.get(element) || 0) + 1); + } + + for (const element of array2) { + const frequency = frequencyCounter.get(element); + if (!frequency) { + return false; + } + frequencyCounter.set(element, frequency - 1); + } + + return true; + } + + /** * @param {string} text * @param {Map} enabledDictionaryMap From 77cc705efcda1cad43582f98c7b40783533ac49a Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Thu, 11 Jan 2024 10:01:19 +0100 Subject: [PATCH 18/28] move inflection source icons to css --- ext/css/display.css | 19 +++++++++++++++++++ ext/js/display/display-generator.js | 8 ++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/ext/css/display.css b/ext/css/display.css index 6b688886ec..41fc6370fc 100644 --- a/ext/css/display.css +++ b/ext/css/display.css @@ -823,6 +823,25 @@ button.action-button:active { content: var(--inflection-separator); padding: 0 0.25em; } +.inflection-source-icon { + display: inline-block; + white-space: nowrap; + text-align: center; + width: 1.4em; + margin-right: 0.2em; +} +.inflection-source-icon[data-inflection-source="dictionary"]::after { + content: '📖'; +} +.inflection-source-icon[data-inflection-source="algorithm"]::after { + content: '🧩'; +} +.inflection-source-icon[data-inflection-source="both"] { + width: 2.8em; +} +.inflection-source-icon[data-inflection-source="both"]::after { + content: '🧩📖'; +} /* Headwords */ diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index fef2a230c8..69f242182c 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -379,18 +379,18 @@ export class DisplayGenerator { */ _getInflectionSourceIcon(source) { const icon = document.createElement('span'); - icon.style.marginRight = '0.5em'; + icon.classList.add('inflection-source-icon'); switch (source) { case 'dictionary': - icon.textContent = '📖'; + icon.dataset.inflectionSource = 'dictionary'; icon.title = 'Dictionary Deinflection'; return icon; case 'algorithm': - icon.textContent = '🧩'; + icon.dataset.inflectionSource = 'algorithm'; icon.title = 'Algorithm Deinflection'; return icon; case 'both': - icon.textContent = '📖🧩'; + icon.dataset.inflectionSource = 'both'; icon.title = 'Dictionary and Algorithm Deinflection'; return icon; } From a0a76091bbe9ae466bcddbf8066d3d32ff95eaf0 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Thu, 11 Jan 2024 10:03:34 +0100 Subject: [PATCH 19/28] lint --- ext/css/display.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/css/display.css b/ext/css/display.css index 41fc6370fc..3f36276365 100644 --- a/ext/css/display.css +++ b/ext/css/display.css @@ -830,16 +830,16 @@ button.action-button:active { width: 1.4em; margin-right: 0.2em; } -.inflection-source-icon[data-inflection-source="dictionary"]::after { +.inflection-source-icon[data-inflection-source='dictionary']::after { content: '📖'; } -.inflection-source-icon[data-inflection-source="algorithm"]::after { +.inflection-source-icon[data-inflection-source='algorithm']::after { content: '🧩'; } -.inflection-source-icon[data-inflection-source="both"] { +.inflection-source-icon[data-inflection-source='both'] { width: 2.8em; } -.inflection-source-icon[data-inflection-source="both"]::after { +.inflection-source-icon[data-inflection-source='both']::after { content: '🧩📖'; } From d110c4fee9943d78231fd567d5425f9e05ac40e4 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 13 Jan 2024 13:01:27 +0100 Subject: [PATCH 20/28] improve naming --- ext/css/display.css | 8 +- .../default-anki-field-templates.handlebars | 6 +- ext/display-templates.html | 4 +- ext/js/data/sandbox/anki-note-data-creator.js | 4 +- ext/js/display/display-generator.js | 14 +- ext/js/language/translator.js | 56 ++--- .../translator-test-results-note-data1.json | 172 ++++++++-------- test/data/translator-test-results.json | 192 +++++++++--------- types/ext/anki-templates.d.ts | 2 +- types/ext/dictionary.d.ts | 6 +- types/ext/translation-internal.d.ts | 2 +- 11 files changed, 233 insertions(+), 233 deletions(-) diff --git a/ext/css/display.css b/ext/css/display.css index 3f36276365..8c9e246620 100644 --- a/ext/css/display.css +++ b/ext/css/display.css @@ -809,17 +809,17 @@ button.action-button:active { /* Inflections */ -.inflection-hypotheses { +.inflection-possibilities { padding-inline-start: 0; list-style-type: none; } -.inflection-hypothesis { +.inflection-possibility { color: var(--reason-text-color); } -.inflection-hypothesis:empty { +.inflection-possibility:empty { display: none; } -.inflection-hypothesis>.inflection+.inflection-separator+.inflection::before { +.inflection-possibility>.inflection+.inflection-separator+.inflection::before { content: var(--inflection-separator); padding: 0 0.25em; } diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 83876c4f0d..3543b3af56 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -261,13 +261,13 @@ {{/inline}} {{#*inline "conjugation"}} - {{~#if (op ">" definition.inflectionHypotheses.length 0)~}} + {{~#if (op ">" definition.inflectionPossibilities.length 0)~}} {{~set "multiple" false~}} - {{~#if (op ">" definition.inflectionHypotheses.length 1)~}} + {{~#if (op ">" definition.inflectionPossibilities.length 1)~}} {{~set "multiple" true~}} {{~/if~}} {{~#if (get "multiple")~}}
      {{/if~}} - {{~#each definition.inflectionHypotheses~}} + {{~#each definition.inflectionPossibilities~}} {{~#if (op ">" inflections.length 0)~}} {{~#if (get "multiple")~}}
    • {{/if~}} {{~#each inflections~}} diff --git a/ext/display-templates.html b/ext/display-templates.html index 32d9e59a69..08912d8a5f 100644 --- a/ext/display-templates.html +++ b/ext/display-templates.html @@ -32,7 +32,7 @@
      -
        +
        @@ -77,7 +77,7 @@ - + diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index da1f80a0d5..f3203a1fed 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -376,7 +376,7 @@ export class AnkiNoteDataCreator { case 'merge': type = 'termMerged'; break; } - const {inflectionHypotheses, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry; + const {inflectionPossibilities, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry; let {url} = context; if (typeof url !== 'string') { url = ''; } @@ -401,7 +401,7 @@ export class AnkiNoteDataCreator { source: (primarySource !== null ? primarySource.transformedText : null), rawSource: (primarySource !== null ? primarySource.originalText : null), sourceTerm: (type !== 'termMerged' ? (primarySource !== null ? primarySource.deinflectedText : null) : void 0), - inflectionHypotheses, + inflectionPossibilities, score, isPrimary: (type === 'term' ? dictionaryEntry.isPrimary : void 0), get sequence() { return self.getCachedValue(sequence); }, diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 69f242182c..d2da52d21b 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -67,13 +67,13 @@ export class DisplayGenerator { const node = this._instantiate('term-entry'); const headwordsContainer = this._querySelector(node, '.headword-list'); - const inflectionHypothesesContainer = this._querySelector(node, '.inflection-hypotheses'); + const inflectionPossibilitiesContainer = this._querySelector(node, '.inflection-possibilities'); const groupedPronunciationsContainer = this._querySelector(node, '.pronunciation-group-list'); const frequencyGroupListContainer = this._querySelector(node, '.frequency-group-list'); const definitionsContainer = this._querySelector(node, '.definition-list'); const headwordTagsContainer = this._querySelector(node, '.headword-list-tag-list'); - const {headwords, type, inflectionHypotheses, definitions, frequencies, pronunciations} = dictionaryEntry; + const {headwords, type, inflectionPossibilities, definitions, frequencies, pronunciations} = dictionaryEntry; const groupedPronunciations = DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry); const pronunciationCount = groupedPronunciations.reduce((i, v) => i + v.pronunciations.length, 0); const groupedFrequencies = DictionaryDataUtil.groupTermFrequencies(dictionaryEntry); @@ -112,7 +112,7 @@ export class DisplayGenerator { } headwordsContainer.dataset.count = `${headwords.length}`; - this._appendMultiple(inflectionHypothesesContainer, this._createInflectionHypothesis.bind(this), inflectionHypotheses); + this._appendMultiple(inflectionPossibilitiesContainer, this._createInflectionPossibility.bind(this), inflectionPossibilities); this._appendMultiple(frequencyGroupListContainer, this._createFrequencyGroup.bind(this), groupedFrequencies, false); this._appendMultiple(groupedPronunciationsContainer, this._createGroupedPronunciation.bind(this), groupedPronunciations); this._appendMultiple(headwordTagsContainer, this._createTermTag.bind(this), termTags, headwords.length); @@ -357,13 +357,13 @@ export class DisplayGenerator { } /** - * @param {import('dictionary').InflectionHypothesis} inflectionHypothesis + * @param {import('dictionary').InflectionPossibility} inflectionPossibility * @returns {?HTMLElement} */ - _createInflectionHypothesis(inflectionHypothesis) { - const {source, inflections} = inflectionHypothesis; + _createInflectionPossibility(inflectionPossibility) { + const {source, inflections} = inflectionPossibility; if (!Array.isArray(inflections) || inflections.length === 0) { return null; } - const fragment = this._instantiate('inflection-hypothesis'); + const fragment = this._instantiate('inflection-possibility'); const sourceIcon = this._getInflectionSourceIcon(source); diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 23a7bfc2a4..a901913b8e 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -221,7 +221,7 @@ export class Translator { /** @type {import('dictionary').TermDictionaryEntry[]} */ const dictionaryEntries = []; const ids = new Set(); - for (const {databaseEntries, originalText, transformedText, deinflectedText, inflectionHypotheses} of deinflections) { + for (const {databaseEntries, originalText, transformedText, deinflectedText, inflectionPossibilities} of deinflections) { if (databaseEntries.length === 0) { continue; } originalTextLength = Math.max(originalTextLength, originalText.length); for (const databaseEntry of databaseEntries) { @@ -232,13 +232,13 @@ export class Translator { }); if (existingEntry && transformedText.length >= existingEntry.headwords[0].sources[0].transformedText.length) { - this._mergeInflectionHypotheses(existingEntry, inflectionHypotheses); + this._mergeInflectionPossibilities(existingEntry, inflectionPossibilities); } continue; } - const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionHypotheses, true, enabledDictionaryMap, tagAggregator); + const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionPossibilities, true, enabledDictionaryMap, tagAggregator); dictionaryEntries.push(dictionaryEntry); ids.add(id); } @@ -249,15 +249,15 @@ export class Translator { /** * @param {import('dictionary').TermDictionaryEntry} existingEntry - * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses + * @param {import('dictionary').InflectionPossibility[]} inflectionPossibilities */ - _mergeInflectionHypotheses(existingEntry, inflectionHypotheses) { - const existingHypotheses = existingEntry.inflectionHypotheses; + _mergeInflectionPossibilities(existingEntry, inflectionPossibilities) { + const existingPossibilities = existingEntry.inflectionPossibilities; - for (const {source, inflections} of inflectionHypotheses) { - const duplicate = existingHypotheses.find((hypothesis) => this._areArraysEqualIgnoreOrder(hypothesis.inflections, inflections)); + for (const {source, inflections} of inflectionPossibilities) { + const duplicate = existingPossibilities.find((possibility) => this._areArraysEqualIgnoreOrder(possibility.inflections, inflections)); if (!duplicate) { - existingEntry.inflectionHypotheses.push({source, inflections}); + existingEntry.inflectionPossibilities.push({source, inflections}); } else if (duplicate.source !== source) { duplicate.source = 'both'; } @@ -334,7 +334,7 @@ export class Translator { /** @type {import('translation-internal').DatabaseDeinflection[]} */ const dictionaryDeinflections = []; deinflections.forEach((deinflection) => { - const {originalText, transformedText, inflectionHypotheses: algHypotheses, databaseEntries} = deinflection; + const {originalText, transformedText, inflectionPossibilities: algPossibilities, databaseEntries} = deinflection; databaseEntries.forEach((entry) => { const {dictionary, definitions} = entry; const entryDictionary = enabledDictionaryMap.get(dictionary); @@ -345,14 +345,14 @@ export class Translator { const [formOf, inflections] = definition; if (!formOf) { continue; } - const inflectionHypotheses = algHypotheses.map(({inflections: algInflections}) => { + const inflectionPossibilities = algPossibilities.map(({inflections: algInflections}) => { return { source: /** @type {import('dictionary').InflectionSource} */ (algInflections.length === 0 ? 'dictionary' : 'both'), inflections: [...algInflections, ...inflections] }; }); - const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, inflectionHypotheses); + const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, inflectionPossibilities); dictionaryDeinflections.push(dictionaryDeinflection); } } @@ -472,12 +472,12 @@ export class Translator { used.add(source); const rawSource = sourceMap.source.substring(0, sourceMap.getSourceLength(i)); for (const {term, rules, reasons} of /** @type {Deinflector} */ (this._deinflector).deinflect(source)) { - /** @type {import('dictionary').InflectionHypothesis} */ - const inflectionHypothesis = { + /** @type {import('dictionary').InflectionPossibility} */ + const inflectionPossibility = { source: 'algorithm', inflections: reasons }; - deinflections.push(this._createDeinflection(rawSource, source, term, rules, [inflectionHypothesis])); + deinflections.push(this._createDeinflection(rawSource, source, term, rules, [inflectionPossibility])); } } } @@ -570,11 +570,11 @@ export class Translator { * @param {string} transformedText * @param {string} deinflectedText * @param {import('translation-internal').DeinflectionRuleFlags} rules - * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses + * @param {import('dictionary').InflectionPossibility[]} inflectionPossibilities * @returns {import('translation-internal').DatabaseDeinflection} */ - _createDeinflection(originalText, transformedText, deinflectedText, rules, inflectionHypotheses) { - return {originalText, transformedText, deinflectedText, rules, inflectionHypotheses, databaseEntries: []}; + _createDeinflection(originalText, transformedText, deinflectedText, rules, inflectionPossibilities) { + return {originalText, transformedText, deinflectedText, rules, inflectionPossibilities, databaseEntries: []}; } // Term dictionary entry grouping @@ -732,8 +732,8 @@ export class Translator { _groupDictionaryEntriesByHeadword(dictionaryEntries, tagAggregator) { const groups = new Map(); for (const dictionaryEntry of dictionaryEntries) { - const {inflectionHypotheses, headwords: [{term, reading}]} = dictionaryEntry; - const key = this._createMapKey([term, reading, ...inflectionHypotheses]); + const {inflectionPossibilities, headwords: [{term, reading}]} = dictionaryEntry; + const key = this._createMapKey([term, reading, ...inflectionPossibilities]); let groupDictionaryEntries = groups.get(key); if (typeof groupDictionaryEntries === 'undefined') { groupDictionaryEntries = []; @@ -1556,7 +1556,7 @@ export class Translator { /** * @param {boolean} isPrimary - * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses + * @param {import('dictionary').InflectionPossibility[]} inflectionPossibilities * @param {number} score * @param {number} dictionaryIndex * @param {number} dictionaryPriority @@ -1566,11 +1566,11 @@ export class Translator { * @param {import('dictionary').TermDefinition[]} definitions * @returns {import('dictionary').TermDictionaryEntry} */ - _createTermDictionaryEntry(isPrimary, inflectionHypotheses, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { + _createTermDictionaryEntry(isPrimary, inflectionPossibilities, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { return { type: 'term', isPrimary, - inflectionHypotheses, + inflectionPossibilities, score, frequencyOrder: 0, dictionaryIndex, @@ -1589,13 +1589,13 @@ export class Translator { * @param {string} originalText * @param {string} transformedText * @param {string} deinflectedText - * @param {import('dictionary').InflectionHypothesis[]} inflectionHypotheses + * @param {import('dictionary').InflectionPossibility[]} inflectionPossibilities * @param {boolean} isPrimary * @param {Map} enabledDictionaryMap * @param {TranslatorTagAggregator} tagAggregator * @returns {import('dictionary').TermDictionaryEntry} */ - _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionHypotheses, isPrimary, enabledDictionaryMap, tagAggregator) { + _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionPossibilities, isPrimary, enabledDictionaryMap, tagAggregator) { const {matchType, matchSource, term, reading: rawReading, definitionTags, termTags, definitions, score, dictionary, id, sequence: rawSequence, rules} = databaseEntry; const reading = (rawReading.length > 0 ? rawReading : term); const {index: dictionaryIndex, priority: dictionaryPriority} = this._getDictionaryOrder(dictionary, enabledDictionaryMap); @@ -1614,7 +1614,7 @@ export class Translator { return this._createTermDictionaryEntry( isPrimary, - inflectionHypotheses, + inflectionPossibilities, score, dictionaryIndex, dictionaryPriority, @@ -1665,7 +1665,7 @@ export class Translator { if (dictionaryEntry.isPrimary) { isPrimary = true; maxTransformedTextLength = Math.max(maxTransformedTextLength, dictionaryEntry.maxTransformedTextLength); - const dictionaryEntryInflections = dictionaryEntry.inflectionHypotheses; + const dictionaryEntryInflections = dictionaryEntry.inflectionPossibilities; if (inflections === null || dictionaryEntryInflections.length < inflections.length) { inflections = dictionaryEntryInflections; } @@ -1877,7 +1877,7 @@ export class Translator { if (i !== 0) { return i; } // Sort by the number of inflection reasons - i = v1.inflectionHypotheses.length - v2.inflectionHypotheses.length; + i = v1.inflectionPossibilities.length - v2.inflectionPossibilities.length; if (i !== 0) { return i; } // Sort by how many terms exactly match the source (e.g. for exact kana prioritization) diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index 224844030d..530f04bf00 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -341,7 +341,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -652,7 +652,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -977,7 +977,7 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -1288,7 +1288,7 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -1599,7 +1599,7 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -1910,7 +1910,7 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -2221,7 +2221,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -2532,7 +2532,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -2857,7 +2857,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -3276,7 +3276,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -3695,7 +3695,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -4114,7 +4114,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -4533,7 +4533,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -4846,7 +4846,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -5159,7 +5159,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -5472,7 +5472,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -5785,7 +5785,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6096,7 +6096,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6421,7 +6421,7 @@ "source": "画像", "rawSource": "画像", "sourceTerm": "画像", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6580,7 +6580,7 @@ "source": "だ", "rawSource": "だ", "sourceTerm": "だ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6896,7 +6896,7 @@ "source": "ダース", "rawSource": "ダース", "sourceTerm": "ダース", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -7221,7 +7221,7 @@ "source": "うつ", "rawSource": "うつ", "sourceTerm": "うつ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -7532,7 +7532,7 @@ "source": "うつ", "rawSource": "うつ", "sourceTerm": "うつ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -7848,7 +7848,7 @@ "source": "ぶつ", "rawSource": "ぶつ", "sourceTerm": "ぶつ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -8159,7 +8159,7 @@ "source": "ぶつ", "rawSource": "ぶつ", "sourceTerm": "ぶつ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -8475,7 +8475,7 @@ "source": "うちこむ", "rawSource": "うちこむ", "sourceTerm": "うちこむ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -8894,7 +8894,7 @@ "source": "うちこむ", "rawSource": "うちこむ", "sourceTerm": "うちこむ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -9313,7 +9313,7 @@ "source": "うち", "rawSource": "うち", "sourceTerm": "うつ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -9626,7 +9626,7 @@ "source": "うち", "rawSource": "うち", "sourceTerm": "うつ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -9944,7 +9944,7 @@ "source": "ぶちこむ", "rawSource": "ぶちこむ", "sourceTerm": "ぶちこむ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -10363,7 +10363,7 @@ "source": "ぶちこむ", "rawSource": "ぶちこむ", "sourceTerm": "ぶちこむ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -10782,7 +10782,7 @@ "source": "ぶち", "rawSource": "ぶち", "sourceTerm": "ぶつ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -11095,7 +11095,7 @@ "source": "ぶち", "rawSource": "ぶち", "sourceTerm": "ぶつ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -11413,7 +11413,7 @@ "source": "がぞう", "rawSource": "がぞう", "sourceTerm": "がぞう", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -11583,7 +11583,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -12025,7 +12025,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -12467,7 +12467,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -12811,7 +12811,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -13155,7 +13155,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -13464,7 +13464,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -13786,7 +13786,7 @@ "type": "termMerged", "source": "打ち込む", "rawSource": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -14556,7 +14556,7 @@ "type": "termMerged", "source": "打ち", "rawSource": "打ち", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -15133,7 +15133,7 @@ "type": "termMerged", "source": "打", "rawSource": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -15435,7 +15435,7 @@ "type": "termMerged", "source": "打", "rawSource": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -15753,7 +15753,7 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -16176,7 +16176,7 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -16599,7 +16599,7 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -17022,7 +17022,7 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -17445,7 +17445,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -17758,7 +17758,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -18071,7 +18071,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -18384,7 +18384,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -18697,7 +18697,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -19008,7 +19008,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -19333,7 +19333,7 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -19752,7 +19752,7 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -20171,7 +20171,7 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -20590,7 +20590,7 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -21009,7 +21009,7 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -21322,7 +21322,7 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -21635,7 +21635,7 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -21948,7 +21948,7 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -22261,7 +22261,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -22572,7 +22572,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -22897,7 +22897,7 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -23316,7 +23316,7 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -23735,7 +23735,7 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -24154,7 +24154,7 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -24573,7 +24573,7 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -24886,7 +24886,7 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -25199,7 +25199,7 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -25512,7 +25512,7 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -25825,7 +25825,7 @@ "source": "打", "rawSource": "(打)", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -26136,7 +26136,7 @@ "source": "打", "rawSource": "(打)", "sourceTerm": "打", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -26461,7 +26461,7 @@ "source": "よみ", "rawSource": "test", "sourceTerm": "よむ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -26620,7 +26620,7 @@ "source": "つよみ", "rawSource": "つtest", "sourceTerm": "つよみ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -26777,7 +26777,7 @@ "source": "よみました", "rawSource": "testました", "sourceTerm": "よむ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -26934,7 +26934,7 @@ "type": "termMerged", "source": "うちこむ", "rawSource": "うちこむ", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -27704,7 +27704,7 @@ "type": "termMerged", "source": "うち", "rawSource": "うち", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -28288,7 +28288,7 @@ "source": "お手前", "rawSource": "お手前", "sourceTerm": "お手前", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -28621,7 +28621,7 @@ "source": "番号", "rawSource": "番号", "sourceTerm": "番号", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -28806,7 +28806,7 @@ "source": "中腰", "rawSource": "中腰", "sourceTerm": "中腰", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -28991,7 +28991,7 @@ "source": "所業", "rawSource": "所業", "sourceTerm": "所業", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -29176,7 +29176,7 @@ "source": "土木工事", "rawSource": "土木工事", "sourceTerm": "土木工事", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -29361,7 +29361,7 @@ "source": "好き", "rawSource": "好き", "sourceTerm": "好き", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -29574,7 +29574,7 @@ "source": "構造", "rawSource": "構造", "sourceTerm": "構造", - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index 8c33c61b55..a819f5b720 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -291,7 +291,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -459,7 +459,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -646,7 +646,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -816,7 +816,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -986,7 +986,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -1156,7 +1156,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -1326,7 +1326,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -1494,7 +1494,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -1681,7 +1681,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -1875,7 +1875,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -2069,7 +2069,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -2263,7 +2263,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -2457,7 +2457,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -2629,7 +2629,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -2801,7 +2801,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -2973,7 +2973,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -3145,7 +3145,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -3313,7 +3313,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -3500,7 +3500,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -3618,7 +3618,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -3792,7 +3792,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -3979,7 +3979,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -4149,7 +4149,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -4325,7 +4325,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -4495,7 +4495,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -4671,7 +4671,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -4865,7 +4865,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -5059,7 +5059,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -5231,7 +5231,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -5409,7 +5409,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -5603,7 +5603,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -5797,7 +5797,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -5969,7 +5969,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -6147,7 +6147,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6275,7 +6275,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6337,7 +6337,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6399,7 +6399,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6461,7 +6461,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6523,7 +6523,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -6587,7 +6587,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -6651,7 +6651,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -6715,7 +6715,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -6779,7 +6779,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6841,7 +6841,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -6909,7 +6909,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -7151,7 +7151,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -7393,7 +7393,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -7613,7 +7613,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -7833,7 +7833,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -8001,7 +8001,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -8188,7 +8188,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -8648,7 +8648,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -9063,7 +9063,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -9231,7 +9231,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -9418,7 +9418,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -9616,7 +9616,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -9814,7 +9814,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -10012,7 +10012,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -10210,7 +10210,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -10382,7 +10382,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -10554,7 +10554,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -10726,7 +10726,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -10898,7 +10898,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -11066,7 +11066,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -11253,7 +11253,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -11447,7 +11447,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -11641,7 +11641,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -11835,7 +11835,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -12029,7 +12029,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -12201,7 +12201,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -12373,7 +12373,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -12545,7 +12545,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -12717,7 +12717,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -12885,7 +12885,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -13072,7 +13072,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -13266,7 +13266,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -13460,7 +13460,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -13654,7 +13654,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -13848,7 +13848,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -14020,7 +14020,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -14192,7 +14192,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -14364,7 +14364,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -14536,7 +14536,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -14704,7 +14704,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -14891,7 +14891,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -15001,7 +15001,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -15109,7 +15109,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -15219,7 +15219,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -15679,7 +15679,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [ @@ -16100,7 +16100,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -16254,7 +16254,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -16354,7 +16354,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -16454,7 +16454,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -16554,7 +16554,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -16654,7 +16654,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] @@ -16771,7 +16771,7 @@ { "type": "term", "isPrimary": true, - "inflectionHypotheses": [ + "inflectionPossibilities": [ { "source": "algorithm", "inflections": [] diff --git a/types/ext/anki-templates.d.ts b/types/ext/anki-templates.d.ts index 9b868436d5..931bec96ef 100644 --- a/types/ext/anki-templates.d.ts +++ b/types/ext/anki-templates.d.ts @@ -172,7 +172,7 @@ export type TermDictionaryEntry = { source: string | null; rawSource: string | null; sourceTerm?: string | null; - inflectionHypotheses: Dictionary.InflectionHypothesis[]; + inflectionPossibilities: Dictionary.InflectionPossibility[]; score: number; isPrimary?: boolean; readonly sequence: number; diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index 54172f2a8d..e1738c3a71 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -208,9 +208,9 @@ export type TermDictionaryEntry = { */ isPrimary: boolean; /** - * A list of inflections that was applied to get the term. + * Possible inflection combinations by which the original search text might have been derived from this term. */ - inflectionHypotheses: InflectionHypothesis[]; + inflectionPossibilities: InflectionPossibility[]; /** * A score for the dictionary entry. */ @@ -253,7 +253,7 @@ export type TermDictionaryEntry = { frequencies: TermFrequency[]; }; -export type InflectionHypothesis = { +export type InflectionPossibility = { source: InflectionSource; inflections: Inflections; }; diff --git a/types/ext/translation-internal.d.ts b/types/ext/translation-internal.d.ts index 572e6aeb58..5c3ccec69f 100644 --- a/types/ext/translation-internal.d.ts +++ b/types/ext/translation-internal.d.ts @@ -61,6 +61,6 @@ export type DatabaseDeinflection = { transformedText: string; deinflectedText: string; rules: DeinflectionRuleFlags; - inflectionHypotheses: Dictionary.InflectionHypothesis[]; + inflectionPossibilities: Dictionary.InflectionPossibility[]; databaseEntries: DictionaryDatabase.TermEntry[]; }; From 249c4b91e95c9a6829c22a6b760eab330bc9a441 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 13 Jan 2024 13:41:41 +0100 Subject: [PATCH 21/28] fix tests --- ext/js/data/options-util.js | 5 +++-- ext/js/language/translator.js | 13 ++++++------- test/options-util.test.js | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index caff2e5f07..07f8867aad 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -556,7 +556,8 @@ export class OptionsUtil { this._updateVersion20, this._updateVersion21, this._updateVersion22, - this._updateVersion23 + this._updateVersion23, + this._updateVersion24 ]; if (typeof targetVersion === 'number' && targetVersion < result.length) { result.splice(targetVersion); @@ -1159,7 +1160,7 @@ export class OptionsUtil { * - Added dictionaries[].useDeinflections. * @type {import('options-util').UpdateFunction} */ - _updateVersion23(options) { + _updateVersion24(options) { for (const {options: profileOptions} of options.profiles) { for (const dictionary of profileOptions.dictionaries) { dictionary.useDeinflections = true; diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 68b889af95..f1447a3889 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -359,7 +359,7 @@ export class Translator { }); }); - await this._addEntriesToDeinflections(dictionaryDeinflections, enabledDictionaryMap, matchType, false); + await this._addEntriesToDeinflections(dictionaryDeinflections, enabledDictionaryMap, matchType); return dictionaryDeinflections; } @@ -368,15 +368,14 @@ export class Translator { * @param {import('translation-internal').DatabaseDeinflection[]} deinflections * @param {Map} enabledDictionaryMap * @param {import('dictionary').TermSourceMatchType} matchType - * @param {boolean} partsOfSpeechFilter */ - async _addEntriesToDeinflections(deinflections, enabledDictionaryMap, matchType, partsOfSpeechFilter = true) { + async _addEntriesToDeinflections(deinflections, enabledDictionaryMap, matchType) { const uniqueDeinflectionsMap = this._groupDeinflectionsByTerm(deinflections); const uniqueDeinflectionArrays = [...uniqueDeinflectionsMap.values()]; const uniqueDeinflectionTerms = [...uniqueDeinflectionsMap.keys()]; const databaseEntries = await this._database.findTermsBulk(uniqueDeinflectionTerms, enabledDictionaryMap, matchType); - this._matchEntriesToDeinflections(databaseEntries, uniqueDeinflectionArrays, partsOfSpeechFilter); + this._matchEntriesToDeinflections(databaseEntries, uniqueDeinflectionArrays, enabledDictionaryMap); } /** @@ -400,12 +399,12 @@ export class Translator { /** * @param {import('dictionary-database').TermEntry[]} databaseEntries * @param {import('translation-internal').DatabaseDeinflection[][]} uniqueDeinflectionArrays - * @param {boolean} partsOfSpeechFilter + * @param {Map} enabledDictionaryMap */ - _matchEntriesToDeinflections(databaseEntries, uniqueDeinflectionArrays, partsOfSpeechFilter) { + _matchEntriesToDeinflections(databaseEntries, uniqueDeinflectionArrays, enabledDictionaryMap) { for (const databaseEntry of databaseEntries) { const entryDictionary = /** @type {import('translation').FindTermDictionary} */ (enabledDictionaryMap.get(databaseEntry.dictionary)); - const partsOfSpeechFilter = entryDictionary.partsOfSpeechFilter; + const {partsOfSpeechFilter} = entryDictionary; const definitionRules = Deinflector.rulesToRuleFlags(databaseEntry.rules); for (const deinflection of uniqueDeinflectionArrays[databaseEntry.index]) { diff --git a/test/options-util.test.js b/test/options-util.test.js index 76c5a27a18..5b3a868e71 100644 --- a/test/options-util.test.js +++ b/test/options-util.test.js @@ -604,7 +604,7 @@ function createOptionsUpdatedTestData1() { } ], profileCurrent: 0, - version: 23, + version: 24, global: { database: { prefixWildcardsSupported: false From 49c84fb12cbb1c92d38c614d796e00575cfe1856 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 13 Jan 2024 13:42:05 +0100 Subject: [PATCH 22/28] add test --- test/data/anki-note-builder-test-results.json | 36 ++++++ .../valid-dictionary1/term_bank_1.json | 4 +- test/data/translator-test-inputs.json | 7 ++ .../translator-test-results-note-data1.json | 113 ++++++++++++++++++ test/data/translator-test-results.json | 81 +++++++++++++ 5 files changed, 240 insertions(+), 1 deletion(-) diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index 86bffc6a0e..7129d74803 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -2867,5 +2867,41 @@ "url": "url:" } ] + }, + { + "name": "Test dictionary deinflection", + "results": [ + { + "audio": "", + "clipboard-image": "", + "clipboard-text": "", + "cloze-body": "のたもうた", + "cloze-prefix": "cloze-prefix", + "cloze-suffix": "cloze-suffix", + "conjugation": "past", + "dictionary": "Test Dictionary 2", + "document-title": "title", + "expression": "のたまう", + "frequencies": "", + "furigana": "のたまう", + "furigana-plain": "のたまう", + "glossary": "
        (v5, Test Dictionary 2) notamau definition
        ", + "glossary-brief": "
        notamau definition
        ", + "glossary-no-dictionary": "
        (v5) notamau definition
        ", + "part-of-speech": "Godan verb", + "pitch-accents": "No pitch accent data", + "pitch-accent-graphs": "No pitch accent data", + "pitch-accent-positions": "No pitch accent data", + "phonetic-transcriptions": "", + "reading": "のたまう", + "screenshot": "", + "search-query": "fullQuery", + "selection-text": "", + "sentence": "cloze-prefixのたもうたcloze-suffix", + "sentence-furigana": "cloze-prefixのたもうたcloze-suffix", + "tags": "v5", + "url": "url:" + } + ] } ] \ No newline at end of file diff --git a/test/data/dictionaries/valid-dictionary1/term_bank_1.json b/test/data/dictionaries/valid-dictionary1/term_bank_1.json index ce4290bdff..cc3fd22593 100644 --- a/test/data/dictionaries/valid-dictionary1/term_bank_1.json +++ b/test/data/dictionaries/valid-dictionary1/term_bank_1.json @@ -337,5 +337,7 @@ {"type": "structured-content", "content": "kouzou definition 3 (構造)"} ], 101, "P E1" - ] + ], + ["のたもうた", "のたもうた", "", "", 1, [["のたまう", ["past"]]], 15, ""], + ["のたまう", "のたまう", "v5", "v5", 1, ["notamau definition"], 16, ""] ] \ No newline at end of file diff --git a/test/data/translator-test-inputs.json b/test/data/translator-test-inputs.json index 9046b3670a..ce449c1e03 100644 --- a/test/data/translator-test-inputs.json +++ b/test/data/translator-test-inputs.json @@ -345,6 +345,13 @@ "mode": "split", "text": "構造", "options": "default" + }, + { + "name": "Test dictionary deinflection", + "func": "findTerms", + "mode": "split", + "text": "のたもうた", + "options": "default" } ] } \ No newline at end of file diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index 530f04bf00..31492213de 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -29719,5 +29719,118 @@ "media": {} } ] + }, + { + "name": "Test dictionary deinflection", + "noteDataList": [ + { + "marker": "{marker}", + "definition": { + "type": "term", + "id": 24, + "source": "のたもうた", + "rawSource": "のたもうた", + "sourceTerm": "のたまう", + "inflectionPossibilities": [ + { + "source": "both", + "inflections": [ + "past" + ] + } + ], + "score": 1, + "isPrimary": true, + "sequence": 16, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "dictionaryNames": [ + "Test Dictionary 2" + ], + "expression": "のたまう", + "reading": "のたまう", + "expressions": [ + { + "sourceTerm": "のたまう", + "expression": "のたまう", + "reading": "のたまう", + "termTags": [], + "frequencies": [], + "pitches": [], + "furiganaSegments": [ + { + "text": "のたまう", + "furigana": "" + } + ], + "termFrequency": "normal", + "wordClasses": [ + "v5" + ] + } + ], + "glossary": [ + "notamau definition" + ], + "definitionTags": [ + { + "name": "v5", + "category": "default", + "notes": "", + "order": 0, + "score": 0, + "dictionary": "Test Dictionary 2", + "redundant": false + } + ], + "termTags": [], + "frequencies": [], + "pitches": [], + "phoneticTranscriptions": [], + "sourceTermExactMatchCount": 1, + "url": "url:", + "cloze": { + "sentence": "", + "prefix": "", + "body": "", + "suffix": "" + }, + "furiganaSegments": [ + { + "text": "のたまう", + "furigana": "" + } + ] + }, + "glossaryLayoutMode": "default", + "compactTags": false, + "group": false, + "merge": false, + "modeTermKanji": false, + "modeTermKana": false, + "modeKanji": false, + "compactGlossaries": false, + "uniqueExpressions": [ + "のたまう" + ], + "uniqueReadings": [ + "のたまう" + ], + "pitches": [], + "pitchCount": 0, + "phoneticTranscriptions": [], + "context": { + "query": "query", + "fullQuery": "fullQuery", + "document": { + "title": "title" + } + }, + "media": {} + } + ] } ] \ No newline at end of file diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index a819f5b720..cb1218198e 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -16879,5 +16879,86 @@ "frequencies": [] } ] + }, + { + "name": "Test dictionary deinflection", + "originalTextLength": 5, + "dictionaryEntries": [ + { + "type": "term", + "isPrimary": true, + "inflectionPossibilities": [ + { + "source": "both", + "inflections": [ + "past" + ] + } + ], + "score": 1, + "frequencyOrder": 0, + "dictionaryIndex": 0, + "dictionaryPriority": 0, + "sourceTermExactMatchCount": 1, + "maxTransformedTextLength": 5, + "headwords": [ + { + "index": 0, + "term": "のたまう", + "reading": "のたまう", + "sources": [ + { + "originalText": "のたもうた", + "transformedText": "のたもうた", + "deinflectedText": "のたまう", + "matchType": "exact", + "matchSource": "term", + "isPrimary": true + } + ], + "tags": [], + "wordClasses": [ + "v5" + ] + } + ], + "definitions": [ + { + "index": 0, + "headwordIndices": [ + 0 + ], + "dictionary": "Test Dictionary 2", + "dictionaryIndex": 0, + "dictionaryPriority": 0, + "id": 24, + "score": 1, + "frequencyOrder": 0, + "sequences": [ + 16 + ], + "isPrimary": true, + "tags": [ + { + "name": "v5", + "category": "default", + "order": 0, + "score": 0, + "content": [], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ], + "entries": [ + "notamau definition" + ] + } + ], + "pronunciations": [], + "frequencies": [] + } + ] } ] \ No newline at end of file From 778c4bfb4f5e26ff9fcc8b23df37f9bc7b2d2707 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 13 Jan 2024 14:42:46 +0100 Subject: [PATCH 23/28] typescript --- ext/js/display/display-generator.js | 2 +- ext/js/language/translator.js | 21 ++++++++++++++++--- .../sandbox/anki-template-renderer.js | 2 +- test/data/database-test-cases.json | 6 +++--- .../valid-dictionary1/term_bank_1.json | 4 ++-- .../translator-test-results-note-data1.json | 4 ++-- test/data/translator-test-results.json | 4 ++-- types/ext/dictionary-data.d.ts | 9 ++++++++ types/ext/dictionary.d.ts | 2 +- 9 files changed, 39 insertions(+), 15 deletions(-) diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index d2da52d21b..d467d6bedf 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -436,7 +436,7 @@ export class DisplayGenerator { } /** - * @param {import('dictionary-data').TermGlossary} entry + * @param {import('dictionary-data').TermGlossaryContent} entry * @param {string} dictionary * @returns {?HTMLElement} */ diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index f1447a3889..7faa274ca8 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -1507,7 +1507,7 @@ export class Translator { * @param {number[]} sequences * @param {boolean} isPrimary * @param {import('dictionary').Tag[]} tags - * @param {import('dictionary-data').TermGlossary[]} entries + * @param {import('dictionary-data').TermGlossaryContent[]} entries * @returns {import('dictionary').TermDefinition} */ _createTermDefinition(index, headwordIndices, dictionary, dictionaryIndex, dictionaryPriority, id, score, sequences, isPrimary, tags, entries) { @@ -1598,7 +1598,22 @@ export class Translator { * @returns {import('dictionary').TermDictionaryEntry} */ _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionPossibilities, isPrimary, enabledDictionaryMap, tagAggregator) { - const {matchType, matchSource, term, reading: rawReading, definitionTags, termTags, definitions, score, dictionary, id, sequence: rawSequence, rules} = databaseEntry; + const { + matchType, + matchSource, + term, + reading: rawReading, + definitionTags, + termTags, + definitions, + score, + dictionary, + id, + sequence: rawSequence, + rules + } = databaseEntry; + // cast is safe because getDeinflections filters out deinflection definitions + const contentDefinitions = /** @type {import('dictionary-data').TermGlossaryContent[]} */ (definitions); const reading = (rawReading.length > 0 ? rawReading : term); const {index: dictionaryIndex, priority: dictionaryPriority} = this._getDictionaryOrder(dictionary, enabledDictionaryMap); const sourceTermExactMatchCount = (isPrimary && deinflectedText === term ? 1 : 0); @@ -1623,7 +1638,7 @@ export class Translator { sourceTermExactMatchCount, maxTransformedTextLength, [this._createTermHeadword(0, term, reading, [source], headwordTagGroups, rules)], - [this._createTermDefinition(0, [0], dictionary, dictionaryIndex, dictionaryPriority, id, score, [sequence], isPrimary, definitionTagGroups, definitions)] + [this._createTermDefinition(0, [0], dictionary, dictionaryIndex, dictionaryPriority, id, score, [sequence], isPrimary, definitionTagGroups, contentDefinitions)] ); } diff --git a/ext/js/templates/sandbox/anki-template-renderer.js b/ext/js/templates/sandbox/anki-template-renderer.js index 3311097f2e..e4822bee65 100644 --- a/ext/js/templates/sandbox/anki-template-renderer.js +++ b/ext/js/templates/sandbox/anki-template-renderer.js @@ -675,7 +675,7 @@ export class AnkiTemplateRenderer { * @type {import('template-renderer').HelperFunction} */ _formatGlossary(args, _context, options) { - const [dictionary, content] = /** @type {[dictionary: string, content: import('dictionary-data').TermGlossary]} */ (args); + const [dictionary, content] = /** @type {[dictionary: string, content: import('dictionary-data').TermGlossaryContent]} */ (args); const data = options.data.root; if (typeof content === 'string') { return this._stringToMultiLineHtml(this._escape(content)); } if (!(typeof content === 'object' && content !== null)) { return ''; } diff --git a/test/data/database-test-cases.json b/test/data/database-test-cases.json index 02fddd4931..611903dd85 100644 --- a/test/data/database-test-cases.json +++ b/test/data/database-test-cases.json @@ -27,7 +27,7 @@ "ipa": 1 }, "terms": { - "total": 23 + "total": 25 } } }, @@ -36,7 +36,7 @@ { "kanji": 2, "kanjiMeta": 6, - "terms": 23, + "terms": 25, "termMeta": 39, "tagMeta": 15, "media": 6 @@ -45,7 +45,7 @@ "total": { "kanji": 2, "kanjiMeta": 6, - "terms": 23, + "terms": 25, "termMeta": 39, "tagMeta": 15, "media": 6 diff --git a/test/data/dictionaries/valid-dictionary1/term_bank_1.json b/test/data/dictionaries/valid-dictionary1/term_bank_1.json index cc3fd22593..7f2af6ddc9 100644 --- a/test/data/dictionaries/valid-dictionary1/term_bank_1.json +++ b/test/data/dictionaries/valid-dictionary1/term_bank_1.json @@ -338,6 +338,6 @@ ], 101, "P E1" ], - ["のたもうた", "のたもうた", "", "", 1, [["のたまう", ["past"]]], 15, ""], - ["のたまう", "のたまう", "v5", "v5", 1, ["notamau definition"], 16, ""] + ["のたまう", "のたまう", "v5", "v5", 1, ["notamau definition"], 15, ""], + ["のたもうた", "のたもうた", "", "", 1, [["のたまう", ["past"]]], 16, ""] ] \ No newline at end of file diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index 31492213de..3bb96984d2 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -29727,7 +29727,7 @@ "marker": "{marker}", "definition": { "type": "term", - "id": 24, + "id": 23, "source": "のたもうた", "rawSource": "のたもうた", "sourceTerm": "のたまう", @@ -29741,7 +29741,7 @@ ], "score": 1, "isPrimary": true, - "sequence": 16, + "sequence": 15, "dictionary": "Test Dictionary 2", "dictionaryOrder": { "index": 0, diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index cb1218198e..bb373a2a66 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -16931,11 +16931,11 @@ "dictionary": "Test Dictionary 2", "dictionaryIndex": 0, "dictionaryPriority": 0, - "id": 24, + "id": 23, "score": 1, "frequencyOrder": 0, "sequences": [ - 16 + 15 ], "isPrimary": true, "tags": [ diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index 0e0edd5c46..ef05fb22bc 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -90,6 +90,11 @@ export type KanjiV3 = [ ]; export type TermGlossary = ( + TermGlossaryContent | + TermGlossaryDeinflection +); + +export type TermGlossaryContent = ( TermGlossaryString | TermGlossaryText | TermGlossaryImage | @@ -100,6 +105,10 @@ export type TermGlossaryString = string; export type TermGlossaryText = {type: 'text', text: string}; export type TermGlossaryImage = {type: 'image'} & TermImage; export type TermGlossaryStructuredContent = {type: 'structured-content', content: StructuredContent.Content}; +export type TermGlossaryDeinflection = [ + uninflected: string, + inflections: string[], +]; export type TermImage = StructuredContent.ImageElementBase & { // Compatibility properties diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index e1738c3a71..d99a097b5e 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -346,7 +346,7 @@ export type TermDefinition = { /** * The definition entries. */ - entries: DictionaryData.TermGlossary[]; + entries: DictionaryData.TermGlossaryContent[]; }; /** From 9d1ed7de1d577f9d64a9bf7af96c5143d9a761c7 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Sat, 13 Jan 2024 14:53:54 +0100 Subject: [PATCH 24/28] use for of --- ext/js/language/translator.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 7faa274ca8..21b2a9f04a 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -333,13 +333,13 @@ export class Translator { async _getDictionaryDeinflections(deinflections, enabledDictionaryMap, matchType) { /** @type {import('translation-internal').DatabaseDeinflection[]} */ const dictionaryDeinflections = []; - deinflections.forEach((deinflection) => { + for (const deinflection of deinflections) { const {originalText, transformedText, inflectionPossibilities: algPossibilities, databaseEntries} = deinflection; - databaseEntries.forEach((entry) => { + for (const entry of databaseEntries) { const {dictionary, definitions} = entry; const entryDictionary = enabledDictionaryMap.get(dictionary); const useDeinflections = entryDictionary?.useDeinflections ?? true; - if (!useDeinflections) { return; } + if (!useDeinflections) { continue; } for (const definition of definitions) { if (Array.isArray(definition)) { const [formOf, inflections] = definition; @@ -356,8 +356,8 @@ export class Translator { dictionaryDeinflections.push(dictionaryDeinflection); } } - }); - }); + } + } await this._addEntriesToDeinflections(dictionaryDeinflections, enabledDictionaryMap, matchType); From bc9c02486413fa54742e7a9ab22acf2796dc6c9b Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Tue, 16 Jan 2024 14:56:35 +0100 Subject: [PATCH 25/28] wip --- ext/css/display.css | 8 +- .../default-anki-field-templates.handlebars | 10 +- ext/display-templates.html | 4 +- ext/js/data/sandbox/anki-note-data-creator.js | 4 +- ext/js/display/display-generator.js | 22 +- ext/js/language/deinflector.js | 2 +- ext/js/language/translator.js | 62 +-- .../translator-test-results-note-data1.json | 348 ++++++++-------- test/data/translator-test-results.json | 388 +++++++++--------- types/ext/anki-templates.d.ts | 2 +- types/ext/dictionary-data.d.ts | 2 +- types/ext/dictionary.d.ts | 10 +- types/ext/translation-internal.d.ts | 4 +- 13 files changed, 432 insertions(+), 434 deletions(-) diff --git a/ext/css/display.css b/ext/css/display.css index 8c9e246620..e0b7ab6d05 100644 --- a/ext/css/display.css +++ b/ext/css/display.css @@ -809,17 +809,17 @@ button.action-button:active { /* Inflections */ -.inflection-possibilities { +.inflection-rule-chains { padding-inline-start: 0; list-style-type: none; } -.inflection-possibility { +.inflection-rule-chain { color: var(--reason-text-color); } -.inflection-possibility:empty { +.inflection-rule-chain:empty { display: none; } -.inflection-possibility>.inflection+.inflection-separator+.inflection::before { +.inflection-rule-chain>.inflection+.inflection-separator+.inflection::before { content: var(--inflection-separator); padding: 0 0.25em; } diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index 3543b3af56..b83d227d8e 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -261,16 +261,16 @@ {{/inline}} {{#*inline "conjugation"}} - {{~#if (op ">" definition.inflectionPossibilities.length 0)~}} + {{~#if (op ">" definition.possibleInflectionRuleChains.length 0)~}} {{~set "multiple" false~}} - {{~#if (op ">" definition.inflectionPossibilities.length 1)~}} + {{~#if (op ">" definition.possibleInflectionRuleChains.length 1)~}} {{~set "multiple" true~}} {{~/if~}} {{~#if (get "multiple")~}}
          {{/if~}} - {{~#each definition.inflectionPossibilities~}} - {{~#if (op ">" inflections.length 0)~}} + {{~#each definition.possibleInflectionRuleChains~}} + {{~#if (op ">" inflectionRules.length 0)~}} {{~#if (get "multiple")~}}
        • {{/if~}} - {{~#each inflections~}} + {{~#each inflectionRules~}} {{~#if (op ">" @index 0)}} « {{/if~}} {{.}} {{~/each~}} diff --git a/ext/display-templates.html b/ext/display-templates.html index 08912d8a5f..a50cea3b9d 100644 --- a/ext/display-templates.html +++ b/ext/display-templates.html @@ -32,7 +32,7 @@
          -
            +
            @@ -77,7 +77,7 @@ - + diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index f3203a1fed..c82e73c0ff 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -376,7 +376,7 @@ export class AnkiNoteDataCreator { case 'merge': type = 'termMerged'; break; } - const {inflectionPossibilities, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry; + const {possibleInflectionRuleChains, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry; let {url} = context; if (typeof url !== 'string') { url = ''; } @@ -401,7 +401,7 @@ export class AnkiNoteDataCreator { source: (primarySource !== null ? primarySource.transformedText : null), rawSource: (primarySource !== null ? primarySource.originalText : null), sourceTerm: (type !== 'termMerged' ? (primarySource !== null ? primarySource.deinflectedText : null) : void 0), - inflectionPossibilities, + possibleInflectionRuleChains, score, isPrimary: (type === 'term' ? dictionaryEntry.isPrimary : void 0), get sequence() { return self.getCachedValue(sequence); }, diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index d467d6bedf..9c3244a732 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -67,13 +67,13 @@ export class DisplayGenerator { const node = this._instantiate('term-entry'); const headwordsContainer = this._querySelector(node, '.headword-list'); - const inflectionPossibilitiesContainer = this._querySelector(node, '.inflection-possibilities'); + const inflectionRuleChainsContainer = this._querySelector(node, '.inflection-rule-chains'); const groupedPronunciationsContainer = this._querySelector(node, '.pronunciation-group-list'); const frequencyGroupListContainer = this._querySelector(node, '.frequency-group-list'); const definitionsContainer = this._querySelector(node, '.definition-list'); const headwordTagsContainer = this._querySelector(node, '.headword-list-tag-list'); - const {headwords, type, inflectionPossibilities, definitions, frequencies, pronunciations} = dictionaryEntry; + const {headwords, type, possibleInflectionRuleChains, definitions, frequencies, pronunciations} = dictionaryEntry; const groupedPronunciations = DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry); const pronunciationCount = groupedPronunciations.reduce((i, v) => i + v.pronunciations.length, 0); const groupedFrequencies = DictionaryDataUtil.groupTermFrequencies(dictionaryEntry); @@ -112,7 +112,7 @@ export class DisplayGenerator { } headwordsContainer.dataset.count = `${headwords.length}`; - this._appendMultiple(inflectionPossibilitiesContainer, this._createInflectionPossibility.bind(this), inflectionPossibilities); + this._appendMultiple(inflectionRuleChainsContainer, this._createInflectionRuleChain.bind(this), possibleInflectionRuleChains); this._appendMultiple(frequencyGroupListContainer, this._createFrequencyGroup.bind(this), groupedFrequencies, false); this._appendMultiple(groupedPronunciationsContainer, this._createGroupedPronunciation.bind(this), groupedPronunciations); this._appendMultiple(headwordTagsContainer, this._createTermTag.bind(this), termTags, headwords.length); @@ -357,19 +357,19 @@ export class DisplayGenerator { } /** - * @param {import('dictionary').InflectionPossibility} inflectionPossibility + * @param {import('dictionary').PossibleInflectionRuleChain} inflectionRuleChain * @returns {?HTMLElement} */ - _createInflectionPossibility(inflectionPossibility) { - const {source, inflections} = inflectionPossibility; - if (!Array.isArray(inflections) || inflections.length === 0) { return null; } - const fragment = this._instantiate('inflection-possibility'); + _createInflectionRuleChain(inflectionRuleChain) { + const {source, inflectionRules} = inflectionRuleChain; + if (!Array.isArray(inflectionRules) || inflectionRules.length === 0) { return null; } + const fragment = this._instantiate('inflection-rule-chain'); const sourceIcon = this._getInflectionSourceIcon(source); fragment.appendChild(sourceIcon); - this._appendMultiple(fragment, this._createTermInflection.bind(this), inflections); + this._appendMultiple(fragment, this._createTermInflection.bind(this), inflectionRules); return fragment; } @@ -380,17 +380,15 @@ export class DisplayGenerator { _getInflectionSourceIcon(source) { const icon = document.createElement('span'); icon.classList.add('inflection-source-icon'); + icon.dataset.inflectionSource = source; switch (source) { case 'dictionary': - icon.dataset.inflectionSource = 'dictionary'; icon.title = 'Dictionary Deinflection'; return icon; case 'algorithm': - icon.dataset.inflectionSource = 'algorithm'; icon.title = 'Algorithm Deinflection'; return icon; case 'both': - icon.dataset.inflectionSource = 'both'; icon.title = 'Dictionary and Algorithm Deinflection'; return icon; } diff --git a/ext/js/language/deinflector.js b/ext/js/language/deinflector.js index d2d92e53d6..e2b66cb40a 100644 --- a/ext/js/language/deinflector.js +++ b/ext/js/language/deinflector.js @@ -80,7 +80,7 @@ export class Deinflector { /** * @param {string} term * @param {import('translation-internal').DeinflectionRuleFlags} rules - * @param {string[]} reasons + * @param {import('dictionary').InflectionRuleChain} reasons * @returns {import('translation-internal').Deinflection} */ _createDeinflection(term, rules, reasons) { diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 21b2a9f04a..272a329b18 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -221,7 +221,7 @@ export class Translator { /** @type {import('dictionary').TermDictionaryEntry[]} */ const dictionaryEntries = []; const ids = new Set(); - for (const {databaseEntries, originalText, transformedText, deinflectedText, inflectionPossibilities} of deinflections) { + for (const {databaseEntries, originalText, transformedText, deinflectedText, possibleInflectionRuleChains} of deinflections) { if (databaseEntries.length === 0) { continue; } originalTextLength = Math.max(originalTextLength, originalText.length); for (const databaseEntry of databaseEntries) { @@ -232,13 +232,13 @@ export class Translator { }); if (existingEntry && transformedText.length >= existingEntry.headwords[0].sources[0].transformedText.length) { - this._mergeInflectionPossibilities(existingEntry, inflectionPossibilities); + this._mergeInflectionRuleChains(existingEntry, possibleInflectionRuleChains); } continue; } - const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionPossibilities, true, enabledDictionaryMap, tagAggregator); + const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, possibleInflectionRuleChains, true, enabledDictionaryMap, tagAggregator); dictionaryEntries.push(dictionaryEntry); ids.add(id); } @@ -249,15 +249,15 @@ export class Translator { /** * @param {import('dictionary').TermDictionaryEntry} existingEntry - * @param {import('dictionary').InflectionPossibility[]} inflectionPossibilities + * @param {import('dictionary').PossibleInflectionRuleChain[]} possibleInflectionRuleChains */ - _mergeInflectionPossibilities(existingEntry, inflectionPossibilities) { - const existingPossibilities = existingEntry.inflectionPossibilities; + _mergeInflectionRuleChains(existingEntry, possibleInflectionRuleChains) { + const existingChains = existingEntry.possibleInflectionRuleChains; - for (const {source, inflections} of inflectionPossibilities) { - const duplicate = existingPossibilities.find((possibility) => this._areArraysEqualIgnoreOrder(possibility.inflections, inflections)); + for (const {source, inflectionRules} of possibleInflectionRuleChains) { + const duplicate = existingChains.find((existingChain) => this._areArraysEqualIgnoreOrder(existingChain.inflectionRules, inflectionRules)); if (!duplicate) { - existingEntry.inflectionPossibilities.push({source, inflections}); + existingEntry.possibleInflectionRuleChains.push({source, inflectionRules}); } else if (duplicate.source !== source) { duplicate.source = 'both'; } @@ -334,7 +334,7 @@ export class Translator { /** @type {import('translation-internal').DatabaseDeinflection[]} */ const dictionaryDeinflections = []; for (const deinflection of deinflections) { - const {originalText, transformedText, inflectionPossibilities: algPossibilities, databaseEntries} = deinflection; + const {originalText, transformedText, possibleInflectionRuleChains: algorithmChains, databaseEntries} = deinflection; for (const entry of databaseEntries) { const {dictionary, definitions} = entry; const entryDictionary = enabledDictionaryMap.get(dictionary); @@ -342,17 +342,17 @@ export class Translator { if (!useDeinflections) { continue; } for (const definition of definitions) { if (Array.isArray(definition)) { - const [formOf, inflections] = definition; + const [formOf, inflectionRules] = definition; if (!formOf) { continue; } - const inflectionPossibilities = algPossibilities.map(({inflections: algInflections}) => { + const possibleInflectionRuleChains = algorithmChains.map(({inflectionRules: algInflections}) => { return { source: /** @type {import('dictionary').InflectionSource} */ (algInflections.length === 0 ? 'dictionary' : 'both'), - inflections: [...algInflections, ...inflections] + inflectionRules: [...algInflections, ...inflectionRules] }; }); - const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, inflectionPossibilities); + const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, possibleInflectionRuleChains); dictionaryDeinflections.push(dictionaryDeinflection); } } @@ -474,12 +474,12 @@ export class Translator { used.add(source); const rawSource = sourceMap.source.substring(0, sourceMap.getSourceLength(i)); for (const {term, rules, reasons} of /** @type {Deinflector} */ (this._deinflector).deinflect(source)) { - /** @type {import('dictionary').InflectionPossibility} */ - const inflectionPossibility = { + /** @type {import('dictionary').PossibleInflectionRuleChain} */ + const possibleInflectionRuleChain = { source: 'algorithm', - inflections: reasons + inflectionRules: reasons }; - deinflections.push(this._createDeinflection(rawSource, source, term, rules, [inflectionPossibility])); + deinflections.push(this._createDeinflection(rawSource, source, term, rules, [possibleInflectionRuleChain])); } } } @@ -572,11 +572,11 @@ export class Translator { * @param {string} transformedText * @param {string} deinflectedText * @param {import('translation-internal').DeinflectionRuleFlags} rules - * @param {import('dictionary').InflectionPossibility[]} inflectionPossibilities + * @param {import('dictionary').PossibleInflectionRuleChain[]} possibleInflectionRuleChains * @returns {import('translation-internal').DatabaseDeinflection} */ - _createDeinflection(originalText, transformedText, deinflectedText, rules, inflectionPossibilities) { - return {originalText, transformedText, deinflectedText, rules, inflectionPossibilities, databaseEntries: []}; + _createDeinflection(originalText, transformedText, deinflectedText, rules, possibleInflectionRuleChains) { + return {originalText, transformedText, deinflectedText, rules, possibleInflectionRuleChains, databaseEntries: []}; } // Term dictionary entry grouping @@ -734,8 +734,8 @@ export class Translator { _groupDictionaryEntriesByHeadword(dictionaryEntries, tagAggregator) { const groups = new Map(); for (const dictionaryEntry of dictionaryEntries) { - const {inflectionPossibilities, headwords: [{term, reading}]} = dictionaryEntry; - const key = this._createMapKey([term, reading, ...inflectionPossibilities]); + const {possibleInflectionRuleChains, headwords: [{term, reading}]} = dictionaryEntry; + const key = this._createMapKey([term, reading, ...possibleInflectionRuleChains]); let groupDictionaryEntries = groups.get(key); if (typeof groupDictionaryEntries === 'undefined') { groupDictionaryEntries = []; @@ -1558,7 +1558,7 @@ export class Translator { /** * @param {boolean} isPrimary - * @param {import('dictionary').InflectionPossibility[]} inflectionPossibilities + * @param {import('dictionary').PossibleInflectionRuleChain[]} possibleInflectionRuleChains * @param {number} score * @param {number} dictionaryIndex * @param {number} dictionaryPriority @@ -1568,11 +1568,11 @@ export class Translator { * @param {import('dictionary').TermDefinition[]} definitions * @returns {import('dictionary').TermDictionaryEntry} */ - _createTermDictionaryEntry(isPrimary, inflectionPossibilities, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { + _createTermDictionaryEntry(isPrimary, possibleInflectionRuleChains, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { return { type: 'term', isPrimary, - inflectionPossibilities, + possibleInflectionRuleChains, score, frequencyOrder: 0, dictionaryIndex, @@ -1591,13 +1591,13 @@ export class Translator { * @param {string} originalText * @param {string} transformedText * @param {string} deinflectedText - * @param {import('dictionary').InflectionPossibility[]} inflectionPossibilities + * @param {import('dictionary').PossibleInflectionRuleChain[]} possibleInflectionRuleChains * @param {boolean} isPrimary * @param {Map} enabledDictionaryMap * @param {TranslatorTagAggregator} tagAggregator * @returns {import('dictionary').TermDictionaryEntry} */ - _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionPossibilities, isPrimary, enabledDictionaryMap, tagAggregator) { + _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, possibleInflectionRuleChains, isPrimary, enabledDictionaryMap, tagAggregator) { const { matchType, matchSource, @@ -1631,7 +1631,7 @@ export class Translator { return this._createTermDictionaryEntry( isPrimary, - inflectionPossibilities, + possibleInflectionRuleChains, score, dictionaryIndex, dictionaryPriority, @@ -1682,7 +1682,7 @@ export class Translator { if (dictionaryEntry.isPrimary) { isPrimary = true; maxTransformedTextLength = Math.max(maxTransformedTextLength, dictionaryEntry.maxTransformedTextLength); - const dictionaryEntryInflections = dictionaryEntry.inflectionPossibilities; + const dictionaryEntryInflections = dictionaryEntry.possibleInflectionRuleChains; if (inflections === null || dictionaryEntryInflections.length < inflections.length) { inflections = dictionaryEntryInflections; } @@ -1894,7 +1894,7 @@ export class Translator { if (i !== 0) { return i; } // Sort by the number of inflection reasons - i = v1.inflectionPossibilities.length - v2.inflectionPossibilities.length; + i = v1.possibleInflectionRuleChains.length - v2.possibleInflectionRuleChains.length; if (i !== 0) { return i; } // Sort by how many terms exactly match the source (e.g. for exact kana prioritization) diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index 3bb96984d2..62140edc9c 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -341,10 +341,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -652,10 +652,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -977,10 +977,10 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -1288,10 +1288,10 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -1599,10 +1599,10 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -1910,10 +1910,10 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -2221,10 +2221,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -2532,10 +2532,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -2857,10 +2857,10 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -3276,10 +3276,10 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -3695,10 +3695,10 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -4114,10 +4114,10 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -4533,10 +4533,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -4846,10 +4846,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -5159,10 +5159,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -5472,10 +5472,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -5785,10 +5785,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6096,10 +6096,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6421,10 +6421,10 @@ "source": "画像", "rawSource": "画像", "sourceTerm": "画像", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6580,10 +6580,10 @@ "source": "だ", "rawSource": "だ", "sourceTerm": "だ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6896,10 +6896,10 @@ "source": "ダース", "rawSource": "ダース", "sourceTerm": "ダース", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -7221,10 +7221,10 @@ "source": "うつ", "rawSource": "うつ", "sourceTerm": "うつ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -7532,10 +7532,10 @@ "source": "うつ", "rawSource": "うつ", "sourceTerm": "うつ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -7848,10 +7848,10 @@ "source": "ぶつ", "rawSource": "ぶつ", "sourceTerm": "ぶつ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -8159,10 +8159,10 @@ "source": "ぶつ", "rawSource": "ぶつ", "sourceTerm": "ぶつ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -8475,10 +8475,10 @@ "source": "うちこむ", "rawSource": "うちこむ", "sourceTerm": "うちこむ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -8894,10 +8894,10 @@ "source": "うちこむ", "rawSource": "うちこむ", "sourceTerm": "うちこむ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -9313,10 +9313,10 @@ "source": "うち", "rawSource": "うち", "sourceTerm": "うつ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -9626,10 +9626,10 @@ "source": "うち", "rawSource": "うち", "sourceTerm": "うつ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -9944,10 +9944,10 @@ "source": "ぶちこむ", "rawSource": "ぶちこむ", "sourceTerm": "ぶちこむ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -10363,10 +10363,10 @@ "source": "ぶちこむ", "rawSource": "ぶちこむ", "sourceTerm": "ぶちこむ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -10782,10 +10782,10 @@ "source": "ぶち", "rawSource": "ぶち", "sourceTerm": "ぶつ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -11095,10 +11095,10 @@ "source": "ぶち", "rawSource": "ぶち", "sourceTerm": "ぶつ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -11413,10 +11413,10 @@ "source": "がぞう", "rawSource": "がぞう", "sourceTerm": "がぞう", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -11583,10 +11583,10 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -12025,10 +12025,10 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -12467,10 +12467,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -12811,10 +12811,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -13155,10 +13155,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -13464,10 +13464,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -13786,10 +13786,10 @@ "type": "termMerged", "source": "打ち込む", "rawSource": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -14556,10 +14556,10 @@ "type": "termMerged", "source": "打ち", "rawSource": "打ち", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -15133,10 +15133,10 @@ "type": "termMerged", "source": "打", "rawSource": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -15435,10 +15435,10 @@ "type": "termMerged", "source": "打", "rawSource": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -15753,10 +15753,10 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "-te", "progressive or perfect", "polite past negative" @@ -16176,10 +16176,10 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "-te", "progressive or perfect", "polite past negative" @@ -16599,10 +16599,10 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "-te", "progressive or perfect", "polite past negative" @@ -17022,10 +17022,10 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "-te", "progressive or perfect", "polite past negative" @@ -17445,10 +17445,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -17758,10 +17758,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -18071,10 +18071,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -18384,10 +18384,10 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -18697,10 +18697,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -19008,10 +19008,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -19333,10 +19333,10 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -19752,10 +19752,10 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -20171,10 +20171,10 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -20590,10 +20590,10 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -21009,10 +21009,10 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -21322,10 +21322,10 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -21635,10 +21635,10 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -21948,10 +21948,10 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -22261,10 +22261,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -22572,10 +22572,10 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -22897,10 +22897,10 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -23316,10 +23316,10 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -23735,10 +23735,10 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -24154,10 +24154,10 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -24573,10 +24573,10 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -24886,10 +24886,10 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -25199,10 +25199,10 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -25512,10 +25512,10 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -25825,10 +25825,10 @@ "source": "打", "rawSource": "(打)", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -26136,10 +26136,10 @@ "source": "打", "rawSource": "(打)", "sourceTerm": "打", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -26461,10 +26461,10 @@ "source": "よみ", "rawSource": "test", "sourceTerm": "よむ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -26620,10 +26620,10 @@ "source": "つよみ", "rawSource": "つtest", "sourceTerm": "つよみ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 90, @@ -26777,10 +26777,10 @@ "source": "よみました", "rawSource": "testました", "sourceTerm": "よむ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "polite past" ] } @@ -26934,10 +26934,10 @@ "type": "termMerged", "source": "うちこむ", "rawSource": "うちこむ", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -27704,10 +27704,10 @@ "type": "termMerged", "source": "うち", "rawSource": "うち", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -28288,10 +28288,10 @@ "source": "お手前", "rawSource": "お手前", "sourceTerm": "お手前", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -28621,10 +28621,10 @@ "source": "番号", "rawSource": "番号", "sourceTerm": "番号", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -28806,10 +28806,10 @@ "source": "中腰", "rawSource": "中腰", "sourceTerm": "中腰", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -28991,10 +28991,10 @@ "source": "所業", "rawSource": "所業", "sourceTerm": "所業", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -29176,10 +29176,10 @@ "source": "土木工事", "rawSource": "土木工事", "sourceTerm": "土木工事", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -29361,10 +29361,10 @@ "source": "好き", "rawSource": "好き", "sourceTerm": "好き", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -29574,10 +29574,10 @@ "source": "構造", "rawSource": "構造", "sourceTerm": "構造", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 35, @@ -29731,10 +29731,10 @@ "source": "のたもうた", "rawSource": "のたもうた", "sourceTerm": "のたまう", - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "both", - "inflections": [ + "inflectionRules": [ "past" ] } diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index bb373a2a66..d19170439b 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -291,10 +291,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -459,10 +459,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -646,10 +646,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -816,10 +816,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -986,10 +986,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -1156,10 +1156,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -1326,10 +1326,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -1494,10 +1494,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -1681,10 +1681,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -1875,10 +1875,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -2069,10 +2069,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -2263,10 +2263,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -2457,10 +2457,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -2629,10 +2629,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -2801,10 +2801,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -2973,10 +2973,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -3145,10 +3145,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -3313,10 +3313,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -3500,10 +3500,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -3618,10 +3618,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -3792,10 +3792,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -3979,10 +3979,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -4149,10 +4149,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -4325,10 +4325,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -4495,10 +4495,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -4671,10 +4671,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -4865,10 +4865,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -5059,10 +5059,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -5231,10 +5231,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -5409,10 +5409,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -5603,10 +5603,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -5797,10 +5797,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -5969,10 +5969,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -6147,10 +6147,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6275,10 +6275,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -6337,10 +6337,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -6399,10 +6399,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6461,10 +6461,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6523,10 +6523,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -6587,10 +6587,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -6651,10 +6651,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -6715,10 +6715,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -6779,10 +6779,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6841,10 +6841,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -6909,10 +6909,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -7151,10 +7151,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -7393,10 +7393,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -7613,10 +7613,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -7833,10 +7833,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -8001,10 +8001,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -8188,10 +8188,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -8648,10 +8648,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -9063,10 +9063,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -9231,10 +9231,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -9418,10 +9418,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "-te", "progressive or perfect", "polite past negative" @@ -9616,10 +9616,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "-te", "progressive or perfect", "polite past negative" @@ -9814,10 +9814,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "-te", "progressive or perfect", "polite past negative" @@ -10012,10 +10012,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "-te", "progressive or perfect", "polite past negative" @@ -10210,10 +10210,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -10382,10 +10382,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -10554,10 +10554,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -10726,10 +10726,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -10898,10 +10898,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -11066,10 +11066,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -11253,10 +11253,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -11447,10 +11447,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -11641,10 +11641,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -11835,10 +11835,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -12029,10 +12029,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -12201,10 +12201,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -12373,10 +12373,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -12545,10 +12545,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -12717,10 +12717,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -12885,10 +12885,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -13072,10 +13072,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -13266,10 +13266,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -13460,10 +13460,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -13654,10 +13654,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -13848,10 +13848,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -14020,10 +14020,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -14192,10 +14192,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -14364,10 +14364,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -14536,10 +14536,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -14704,10 +14704,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -14891,10 +14891,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -15001,10 +15001,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 90, @@ -15109,10 +15109,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "polite past" ] } @@ -15219,10 +15219,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 10, @@ -15679,10 +15679,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [ + "inflectionRules": [ "masu stem" ] } @@ -16100,10 +16100,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -16254,10 +16254,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -16354,10 +16354,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -16454,10 +16454,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -16554,10 +16554,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -16654,10 +16654,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 1, @@ -16771,10 +16771,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "algorithm", - "inflections": [] + "inflectionRules": [] } ], "score": 35, @@ -16887,10 +16887,10 @@ { "type": "term", "isPrimary": true, - "inflectionPossibilities": [ + "possibleInflectionRuleChains": [ { "source": "both", - "inflections": [ + "inflectionRules": [ "past" ] } diff --git a/types/ext/anki-templates.d.ts b/types/ext/anki-templates.d.ts index 931bec96ef..4b0cb02a9b 100644 --- a/types/ext/anki-templates.d.ts +++ b/types/ext/anki-templates.d.ts @@ -172,7 +172,7 @@ export type TermDictionaryEntry = { source: string | null; rawSource: string | null; sourceTerm?: string | null; - inflectionPossibilities: Dictionary.InflectionPossibility[]; + possibleInflectionRuleChains: Dictionary.PossibleInflectionRuleChain[]; score: number; isPrimary?: boolean; readonly sequence: number; diff --git a/types/ext/dictionary-data.d.ts b/types/ext/dictionary-data.d.ts index ef05fb22bc..82e0f00dbe 100644 --- a/types/ext/dictionary-data.d.ts +++ b/types/ext/dictionary-data.d.ts @@ -107,7 +107,7 @@ export type TermGlossaryImage = {type: 'image'} & TermImage; export type TermGlossaryStructuredContent = {type: 'structured-content', content: StructuredContent.Content}; export type TermGlossaryDeinflection = [ uninflected: string, - inflections: string[], + inflectionRuleChain: string[], ]; export type TermImage = StructuredContent.ImageElementBase & { diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index d99a097b5e..a224a407f3 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -208,9 +208,9 @@ export type TermDictionaryEntry = { */ isPrimary: boolean; /** - * Possible inflection combinations by which the original search text might have been derived from this term. + * Ways that a looked-up word might be an inflected form of this term. */ - inflectionPossibilities: InflectionPossibility[]; + possibleInflectionRuleChains: PossibleInflectionRuleChain[]; /** * A score for the dictionary entry. */ @@ -253,12 +253,12 @@ export type TermDictionaryEntry = { frequencies: TermFrequency[]; }; -export type InflectionPossibility = { +export type PossibleInflectionRuleChain = { source: InflectionSource; - inflections: Inflections; + inflectionRules: InflectionRuleChain; }; -export type Inflections = string[]; +export type InflectionRuleChain = string[]; export type InflectionSource = 'algorithm' | 'dictionary' | 'both'; diff --git a/types/ext/translation-internal.d.ts b/types/ext/translation-internal.d.ts index 5c3ccec69f..0f88fc3219 100644 --- a/types/ext/translation-internal.d.ts +++ b/types/ext/translation-internal.d.ts @@ -53,7 +53,7 @@ export enum DeinflectionRuleFlags { export type Deinflection = { term: string; rules: DeinflectionRuleFlags; - reasons: string[]; + reasons: Dictionary.InflectionRuleChain; }; export type DatabaseDeinflection = { @@ -61,6 +61,6 @@ export type DatabaseDeinflection = { transformedText: string; deinflectedText: string; rules: DeinflectionRuleFlags; - inflectionPossibilities: Dictionary.InflectionPossibility[]; + possibleInflectionRuleChains: Dictionary.PossibleInflectionRuleChain[]; databaseEntries: DictionaryDatabase.TermEntry[]; }; From ff67a5bc87f09f7a8aef127a654780a21cd3f307 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 17 Jan 2024 10:21:57 +0100 Subject: [PATCH 26/28] comments --- .../default-anki-field-templates.handlebars | 6 +- ext/js/data/sandbox/anki-note-data-creator.js | 4 +- ext/js/display/display-generator.js | 6 +- ext/js/language/translator.js | 55 ++--- .../translator-test-results-note-data1.json | 174 ++++++++-------- test/data/translator-test-results.json | 194 +++++++++--------- types/ext/anki-templates.d.ts | 2 +- types/ext/dictionary.d.ts | 4 +- types/ext/translation-internal.d.ts | 2 +- 9 files changed, 224 insertions(+), 223 deletions(-) diff --git a/ext/data/templates/default-anki-field-templates.handlebars b/ext/data/templates/default-anki-field-templates.handlebars index b83d227d8e..818677cedf 100644 --- a/ext/data/templates/default-anki-field-templates.handlebars +++ b/ext/data/templates/default-anki-field-templates.handlebars @@ -261,13 +261,13 @@ {{/inline}} {{#*inline "conjugation"}} - {{~#if (op ">" definition.possibleInflectionRuleChains.length 0)~}} + {{~#if (op ">" definition.inflectionRuleChainCandidates.length 0)~}} {{~set "multiple" false~}} - {{~#if (op ">" definition.possibleInflectionRuleChains.length 1)~}} + {{~#if (op ">" definition.inflectionRuleChainCandidates.length 1)~}} {{~set "multiple" true~}} {{~/if~}} {{~#if (get "multiple")~}}
              {{/if~}} - {{~#each definition.possibleInflectionRuleChains~}} + {{~#each definition.inflectionRuleChainCandidates~}} {{~#if (op ">" inflectionRules.length 0)~}} {{~#if (get "multiple")~}}
            • {{/if~}} {{~#each inflectionRules~}} diff --git a/ext/js/data/sandbox/anki-note-data-creator.js b/ext/js/data/sandbox/anki-note-data-creator.js index c82e73c0ff..77d6e357bf 100644 --- a/ext/js/data/sandbox/anki-note-data-creator.js +++ b/ext/js/data/sandbox/anki-note-data-creator.js @@ -376,7 +376,7 @@ export class AnkiNoteDataCreator { case 'merge': type = 'termMerged'; break; } - const {possibleInflectionRuleChains, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry; + const {inflectionRuleChainCandidates, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, definitions} = dictionaryEntry; let {url} = context; if (typeof url !== 'string') { url = ''; } @@ -401,7 +401,7 @@ export class AnkiNoteDataCreator { source: (primarySource !== null ? primarySource.transformedText : null), rawSource: (primarySource !== null ? primarySource.originalText : null), sourceTerm: (type !== 'termMerged' ? (primarySource !== null ? primarySource.deinflectedText : null) : void 0), - possibleInflectionRuleChains, + inflectionRuleChainCandidates, score, isPrimary: (type === 'term' ? dictionaryEntry.isPrimary : void 0), get sequence() { return self.getCachedValue(sequence); }, diff --git a/ext/js/display/display-generator.js b/ext/js/display/display-generator.js index 9c3244a732..521cbb4121 100644 --- a/ext/js/display/display-generator.js +++ b/ext/js/display/display-generator.js @@ -73,7 +73,7 @@ export class DisplayGenerator { const definitionsContainer = this._querySelector(node, '.definition-list'); const headwordTagsContainer = this._querySelector(node, '.headword-list-tag-list'); - const {headwords, type, possibleInflectionRuleChains, definitions, frequencies, pronunciations} = dictionaryEntry; + const {headwords, type, inflectionRuleChainCandidates, definitions, frequencies, pronunciations} = dictionaryEntry; const groupedPronunciations = DictionaryDataUtil.getGroupedPronunciations(dictionaryEntry); const pronunciationCount = groupedPronunciations.reduce((i, v) => i + v.pronunciations.length, 0); const groupedFrequencies = DictionaryDataUtil.groupTermFrequencies(dictionaryEntry); @@ -112,7 +112,7 @@ export class DisplayGenerator { } headwordsContainer.dataset.count = `${headwords.length}`; - this._appendMultiple(inflectionRuleChainsContainer, this._createInflectionRuleChain.bind(this), possibleInflectionRuleChains); + this._appendMultiple(inflectionRuleChainsContainer, this._createInflectionRuleChain.bind(this), inflectionRuleChainCandidates); this._appendMultiple(frequencyGroupListContainer, this._createFrequencyGroup.bind(this), groupedFrequencies, false); this._appendMultiple(groupedPronunciationsContainer, this._createGroupedPronunciation.bind(this), groupedPronunciations); this._appendMultiple(headwordTagsContainer, this._createTermTag.bind(this), termTags, headwords.length); @@ -357,7 +357,7 @@ export class DisplayGenerator { } /** - * @param {import('dictionary').PossibleInflectionRuleChain} inflectionRuleChain + * @param {import('dictionary').InflectionRuleChainCandidate} inflectionRuleChain * @returns {?HTMLElement} */ _createInflectionRuleChain(inflectionRuleChain) { diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 272a329b18..89a3e5ec67 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -19,6 +19,7 @@ import {RegexUtil} from '../general/regex-util.js'; import {TextSourceMap} from '../general/text-source-map.js'; import {Deinflector} from './deinflector.js'; + /** * Class which finds term and kanji dictionary entries for text. */ @@ -221,7 +222,7 @@ export class Translator { /** @type {import('dictionary').TermDictionaryEntry[]} */ const dictionaryEntries = []; const ids = new Set(); - for (const {databaseEntries, originalText, transformedText, deinflectedText, possibleInflectionRuleChains} of deinflections) { + for (const {databaseEntries, originalText, transformedText, deinflectedText, inflectionRuleChainCandidates} of deinflections) { if (databaseEntries.length === 0) { continue; } originalTextLength = Math.max(originalTextLength, originalText.length); for (const databaseEntry of databaseEntries) { @@ -232,13 +233,13 @@ export class Translator { }); if (existingEntry && transformedText.length >= existingEntry.headwords[0].sources[0].transformedText.length) { - this._mergeInflectionRuleChains(existingEntry, possibleInflectionRuleChains); + this._mergeInflectionRuleChains(existingEntry, inflectionRuleChainCandidates); } continue; } - const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, possibleInflectionRuleChains, true, enabledDictionaryMap, tagAggregator); + const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionRuleChainCandidates, true, enabledDictionaryMap, tagAggregator); dictionaryEntries.push(dictionaryEntry); ids.add(id); } @@ -249,15 +250,15 @@ export class Translator { /** * @param {import('dictionary').TermDictionaryEntry} existingEntry - * @param {import('dictionary').PossibleInflectionRuleChain[]} possibleInflectionRuleChains + * @param {import('dictionary').InflectionRuleChainCandidate[]} inflectionRuleChainCandidates */ - _mergeInflectionRuleChains(existingEntry, possibleInflectionRuleChains) { - const existingChains = existingEntry.possibleInflectionRuleChains; + _mergeInflectionRuleChains(existingEntry, inflectionRuleChainCandidates) { + const existingChains = existingEntry.inflectionRuleChainCandidates; - for (const {source, inflectionRules} of possibleInflectionRuleChains) { + for (const {source, inflectionRules} of inflectionRuleChainCandidates) { const duplicate = existingChains.find((existingChain) => this._areArraysEqualIgnoreOrder(existingChain.inflectionRules, inflectionRules)); if (!duplicate) { - existingEntry.possibleInflectionRuleChains.push({source, inflectionRules}); + existingEntry.inflectionRuleChainCandidates.push({source, inflectionRules}); } else if (duplicate.source !== source) { duplicate.source = 'both'; } @@ -334,7 +335,7 @@ export class Translator { /** @type {import('translation-internal').DatabaseDeinflection[]} */ const dictionaryDeinflections = []; for (const deinflection of deinflections) { - const {originalText, transformedText, possibleInflectionRuleChains: algorithmChains, databaseEntries} = deinflection; + const {originalText, transformedText, inflectionRuleChainCandidates: algorithmChains, databaseEntries} = deinflection; for (const entry of databaseEntries) { const {dictionary, definitions} = entry; const entryDictionary = enabledDictionaryMap.get(dictionary); @@ -345,14 +346,14 @@ export class Translator { const [formOf, inflectionRules] = definition; if (!formOf) { continue; } - const possibleInflectionRuleChains = algorithmChains.map(({inflectionRules: algInflections}) => { + const inflectionRuleChainCandidates = algorithmChains.map(({inflectionRules: algInflections}) => { return { source: /** @type {import('dictionary').InflectionSource} */ (algInflections.length === 0 ? 'dictionary' : 'both'), inflectionRules: [...algInflections, ...inflectionRules] }; }); - const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, possibleInflectionRuleChains); + const dictionaryDeinflection = this._createDeinflection(originalText, transformedText, formOf, 0, inflectionRuleChainCandidates); dictionaryDeinflections.push(dictionaryDeinflection); } } @@ -474,12 +475,12 @@ export class Translator { used.add(source); const rawSource = sourceMap.source.substring(0, sourceMap.getSourceLength(i)); for (const {term, rules, reasons} of /** @type {Deinflector} */ (this._deinflector).deinflect(source)) { - /** @type {import('dictionary').PossibleInflectionRuleChain} */ - const possibleInflectionRuleChain = { + /** @type {import('dictionary').InflectionRuleChainCandidate} */ + const inflectionRuleChainCandidate = { source: 'algorithm', inflectionRules: reasons }; - deinflections.push(this._createDeinflection(rawSource, source, term, rules, [possibleInflectionRuleChain])); + deinflections.push(this._createDeinflection(rawSource, source, term, rules, [inflectionRuleChainCandidate])); } } } @@ -572,11 +573,11 @@ export class Translator { * @param {string} transformedText * @param {string} deinflectedText * @param {import('translation-internal').DeinflectionRuleFlags} rules - * @param {import('dictionary').PossibleInflectionRuleChain[]} possibleInflectionRuleChains + * @param {import('dictionary').InflectionRuleChainCandidate[]} inflectionRuleChainCandidates * @returns {import('translation-internal').DatabaseDeinflection} */ - _createDeinflection(originalText, transformedText, deinflectedText, rules, possibleInflectionRuleChains) { - return {originalText, transformedText, deinflectedText, rules, possibleInflectionRuleChains, databaseEntries: []}; + _createDeinflection(originalText, transformedText, deinflectedText, rules, inflectionRuleChainCandidates) { + return {originalText, transformedText, deinflectedText, rules, inflectionRuleChainCandidates, databaseEntries: []}; } // Term dictionary entry grouping @@ -734,8 +735,8 @@ export class Translator { _groupDictionaryEntriesByHeadword(dictionaryEntries, tagAggregator) { const groups = new Map(); for (const dictionaryEntry of dictionaryEntries) { - const {possibleInflectionRuleChains, headwords: [{term, reading}]} = dictionaryEntry; - const key = this._createMapKey([term, reading, ...possibleInflectionRuleChains]); + const {inflectionRuleChainCandidates, headwords: [{term, reading}]} = dictionaryEntry; + const key = this._createMapKey([term, reading, ...inflectionRuleChainCandidates]); let groupDictionaryEntries = groups.get(key); if (typeof groupDictionaryEntries === 'undefined') { groupDictionaryEntries = []; @@ -1558,7 +1559,7 @@ export class Translator { /** * @param {boolean} isPrimary - * @param {import('dictionary').PossibleInflectionRuleChain[]} possibleInflectionRuleChains + * @param {import('dictionary').InflectionRuleChainCandidate[]} inflectionRuleChainCandidates * @param {number} score * @param {number} dictionaryIndex * @param {number} dictionaryPriority @@ -1568,11 +1569,11 @@ export class Translator { * @param {import('dictionary').TermDefinition[]} definitions * @returns {import('dictionary').TermDictionaryEntry} */ - _createTermDictionaryEntry(isPrimary, possibleInflectionRuleChains, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { + _createTermDictionaryEntry(isPrimary, inflectionRuleChainCandidates, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { return { type: 'term', isPrimary, - possibleInflectionRuleChains, + inflectionRuleChainCandidates, score, frequencyOrder: 0, dictionaryIndex, @@ -1591,13 +1592,13 @@ export class Translator { * @param {string} originalText * @param {string} transformedText * @param {string} deinflectedText - * @param {import('dictionary').PossibleInflectionRuleChain[]} possibleInflectionRuleChains + * @param {import('dictionary').InflectionRuleChainCandidate[]} inflectionRuleChainCandidates * @param {boolean} isPrimary * @param {Map} enabledDictionaryMap * @param {TranslatorTagAggregator} tagAggregator * @returns {import('dictionary').TermDictionaryEntry} */ - _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, possibleInflectionRuleChains, isPrimary, enabledDictionaryMap, tagAggregator) { + _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, inflectionRuleChainCandidates, isPrimary, enabledDictionaryMap, tagAggregator) { const { matchType, matchSource, @@ -1631,7 +1632,7 @@ export class Translator { return this._createTermDictionaryEntry( isPrimary, - possibleInflectionRuleChains, + inflectionRuleChainCandidates, score, dictionaryIndex, dictionaryPriority, @@ -1682,7 +1683,7 @@ export class Translator { if (dictionaryEntry.isPrimary) { isPrimary = true; maxTransformedTextLength = Math.max(maxTransformedTextLength, dictionaryEntry.maxTransformedTextLength); - const dictionaryEntryInflections = dictionaryEntry.possibleInflectionRuleChains; + const dictionaryEntryInflections = dictionaryEntry.inflectionRuleChainCandidates; if (inflections === null || dictionaryEntryInflections.length < inflections.length) { inflections = dictionaryEntryInflections; } @@ -1894,7 +1895,7 @@ export class Translator { if (i !== 0) { return i; } // Sort by the number of inflection reasons - i = v1.possibleInflectionRuleChains.length - v2.possibleInflectionRuleChains.length; + i = v1.inflectionRuleChainCandidates.length - v2.inflectionRuleChainCandidates.length; if (i !== 0) { return i; } // Sort by how many terms exactly match the source (e.g. for exact kana prioritization) diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index 62140edc9c..c34842da82 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -341,7 +341,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -652,7 +652,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -977,7 +977,7 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -1288,7 +1288,7 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -1599,7 +1599,7 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -1910,7 +1910,7 @@ "source": "打つ", "rawSource": "打つ", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -2221,7 +2221,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -2532,7 +2532,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -2857,7 +2857,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -3276,7 +3276,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -3695,7 +3695,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -4114,7 +4114,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -4533,7 +4533,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -4846,7 +4846,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -5159,7 +5159,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -5472,7 +5472,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -5785,7 +5785,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6096,7 +6096,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6421,7 +6421,7 @@ "source": "画像", "rawSource": "画像", "sourceTerm": "画像", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6580,7 +6580,7 @@ "source": "だ", "rawSource": "だ", "sourceTerm": "だ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6896,7 +6896,7 @@ "source": "ダース", "rawSource": "ダース", "sourceTerm": "ダース", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -7221,7 +7221,7 @@ "source": "うつ", "rawSource": "うつ", "sourceTerm": "うつ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -7532,7 +7532,7 @@ "source": "うつ", "rawSource": "うつ", "sourceTerm": "うつ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -7848,7 +7848,7 @@ "source": "ぶつ", "rawSource": "ぶつ", "sourceTerm": "ぶつ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -8159,7 +8159,7 @@ "source": "ぶつ", "rawSource": "ぶつ", "sourceTerm": "ぶつ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -8475,7 +8475,7 @@ "source": "うちこむ", "rawSource": "うちこむ", "sourceTerm": "うちこむ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -8894,7 +8894,7 @@ "source": "うちこむ", "rawSource": "うちこむ", "sourceTerm": "うちこむ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -9313,7 +9313,7 @@ "source": "うち", "rawSource": "うち", "sourceTerm": "うつ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -9626,7 +9626,7 @@ "source": "うち", "rawSource": "うち", "sourceTerm": "うつ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -9944,7 +9944,7 @@ "source": "ぶちこむ", "rawSource": "ぶちこむ", "sourceTerm": "ぶちこむ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -10363,7 +10363,7 @@ "source": "ぶちこむ", "rawSource": "ぶちこむ", "sourceTerm": "ぶちこむ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -10782,7 +10782,7 @@ "source": "ぶち", "rawSource": "ぶち", "sourceTerm": "ぶつ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -11095,7 +11095,7 @@ "source": "ぶち", "rawSource": "ぶち", "sourceTerm": "ぶつ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -11413,7 +11413,7 @@ "source": "がぞう", "rawSource": "がぞう", "sourceTerm": "がぞう", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -11583,7 +11583,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -12025,7 +12025,7 @@ "source": "打ち込む", "rawSource": "打ち込む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -12467,7 +12467,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -12811,7 +12811,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -13155,7 +13155,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -13464,7 +13464,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -13786,7 +13786,7 @@ "type": "termMerged", "source": "打ち込む", "rawSource": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -14556,7 +14556,7 @@ "type": "termMerged", "source": "打ち", "rawSource": "打ち", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -15133,7 +15133,7 @@ "type": "termMerged", "source": "打", "rawSource": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -15435,7 +15435,7 @@ "type": "termMerged", "source": "打", "rawSource": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -15753,7 +15753,7 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -16176,7 +16176,7 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -16599,7 +16599,7 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -17022,7 +17022,7 @@ "source": "打ち込んでいませんでした", "rawSource": "打ち込んでいませんでした", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -17445,7 +17445,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -17758,7 +17758,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -18071,7 +18071,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -18384,7 +18384,7 @@ "source": "打ち", "rawSource": "打ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -18697,7 +18697,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -19008,7 +19008,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -19333,7 +19333,7 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -19752,7 +19752,7 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -20171,7 +20171,7 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -20590,7 +20590,7 @@ "source": "打ち込む", "rawSource": "打(う)ち込(こ)む", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -21009,7 +21009,7 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -21322,7 +21322,7 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -21635,7 +21635,7 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -21948,7 +21948,7 @@ "source": "打ち", "rawSource": "打(う)ち", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -22261,7 +22261,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -22572,7 +22572,7 @@ "source": "打", "rawSource": "打", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -22897,7 +22897,7 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -23316,7 +23316,7 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -23735,7 +23735,7 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -24154,7 +24154,7 @@ "source": "打ち込む", "rawSource": "(打)(ち)(込)(む)", "sourceTerm": "打ち込む", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -24573,7 +24573,7 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -24886,7 +24886,7 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -25199,7 +25199,7 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -25512,7 +25512,7 @@ "source": "打ち", "rawSource": "(打)(ち)", "sourceTerm": "打つ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -25825,7 +25825,7 @@ "source": "打", "rawSource": "(打)", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -26136,7 +26136,7 @@ "source": "打", "rawSource": "(打)", "sourceTerm": "打", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -26461,7 +26461,7 @@ "source": "よみ", "rawSource": "test", "sourceTerm": "よむ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -26620,7 +26620,7 @@ "source": "つよみ", "rawSource": "つtest", "sourceTerm": "つよみ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -26777,7 +26777,7 @@ "source": "よみました", "rawSource": "testました", "sourceTerm": "よむ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -26934,7 +26934,7 @@ "type": "termMerged", "source": "うちこむ", "rawSource": "うちこむ", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -27704,7 +27704,7 @@ "type": "termMerged", "source": "うち", "rawSource": "うち", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -28288,7 +28288,7 @@ "source": "お手前", "rawSource": "お手前", "sourceTerm": "お手前", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -28621,7 +28621,7 @@ "source": "番号", "rawSource": "番号", "sourceTerm": "番号", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -28806,7 +28806,7 @@ "source": "中腰", "rawSource": "中腰", "sourceTerm": "中腰", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -28991,7 +28991,7 @@ "source": "所業", "rawSource": "所業", "sourceTerm": "所業", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -29176,7 +29176,7 @@ "source": "土木工事", "rawSource": "土木工事", "sourceTerm": "土木工事", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -29361,7 +29361,7 @@ "source": "好き", "rawSource": "好き", "sourceTerm": "好き", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -29574,7 +29574,7 @@ "source": "構造", "rawSource": "構造", "sourceTerm": "構造", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -29731,7 +29731,7 @@ "source": "のたもうた", "rawSource": "のたもうた", "sourceTerm": "のたまう", - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "both", "inflectionRules": [ diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index d19170439b..4a81c552bc 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -291,7 +291,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -459,7 +459,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -646,7 +646,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -816,7 +816,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -986,7 +986,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -1156,7 +1156,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -1326,7 +1326,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -1494,7 +1494,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -1681,7 +1681,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -1875,7 +1875,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -2069,7 +2069,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -2263,7 +2263,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -2457,7 +2457,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -2629,7 +2629,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -2801,7 +2801,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -2973,7 +2973,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -3145,7 +3145,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -3313,7 +3313,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -3500,7 +3500,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -3618,7 +3618,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -3792,7 +3792,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -3979,7 +3979,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -4149,7 +4149,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -4325,7 +4325,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -4495,7 +4495,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -4671,7 +4671,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -4865,7 +4865,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -5059,7 +5059,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -5231,7 +5231,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -5409,7 +5409,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -5603,7 +5603,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -5797,7 +5797,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -5969,7 +5969,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -6147,7 +6147,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6275,7 +6275,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6337,7 +6337,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6399,7 +6399,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6461,7 +6461,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6523,7 +6523,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -6587,7 +6587,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -6651,7 +6651,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -6715,7 +6715,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -6779,7 +6779,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6841,7 +6841,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -6909,7 +6909,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -7151,7 +7151,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -7393,7 +7393,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -7613,7 +7613,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -7833,7 +7833,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -8001,7 +8001,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -8188,7 +8188,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -8648,7 +8648,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -9063,7 +9063,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -9231,7 +9231,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -9418,7 +9418,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -9616,7 +9616,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -9814,7 +9814,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -10012,7 +10012,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -10210,7 +10210,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -10382,7 +10382,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -10554,7 +10554,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -10726,7 +10726,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -10898,7 +10898,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -11066,7 +11066,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -11253,7 +11253,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -11447,7 +11447,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -11641,7 +11641,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -11835,7 +11835,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -12029,7 +12029,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -12201,7 +12201,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -12373,7 +12373,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -12545,7 +12545,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -12717,7 +12717,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -12885,7 +12885,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -13072,7 +13072,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -13266,7 +13266,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -13460,7 +13460,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -13654,7 +13654,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -13848,7 +13848,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -14020,7 +14020,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -14192,7 +14192,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -14364,7 +14364,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -14536,7 +14536,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -14704,7 +14704,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -14891,7 +14891,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -15001,7 +15001,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -15109,7 +15109,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -15219,7 +15219,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -15679,7 +15679,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [ @@ -16100,7 +16100,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -16254,7 +16254,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -16354,7 +16354,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -16454,7 +16454,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -16554,7 +16554,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -16654,7 +16654,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -16771,7 +16771,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "algorithm", "inflectionRules": [] @@ -16887,7 +16887,7 @@ { "type": "term", "isPrimary": true, - "possibleInflectionRuleChains": [ + "inflectionRuleChainCandidates": [ { "source": "both", "inflectionRules": [ diff --git a/types/ext/anki-templates.d.ts b/types/ext/anki-templates.d.ts index 4b0cb02a9b..7348b57172 100644 --- a/types/ext/anki-templates.d.ts +++ b/types/ext/anki-templates.d.ts @@ -172,7 +172,7 @@ export type TermDictionaryEntry = { source: string | null; rawSource: string | null; sourceTerm?: string | null; - possibleInflectionRuleChains: Dictionary.PossibleInflectionRuleChain[]; + inflectionRuleChainCandidates: Dictionary.InflectionRuleChainCandidate[]; score: number; isPrimary?: boolean; readonly sequence: number; diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index a224a407f3..ed7769a91e 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -210,7 +210,7 @@ export type TermDictionaryEntry = { /** * Ways that a looked-up word might be an inflected form of this term. */ - possibleInflectionRuleChains: PossibleInflectionRuleChain[]; + inflectionRuleChainCandidates: InflectionRuleChainCandidate[]; /** * A score for the dictionary entry. */ @@ -253,7 +253,7 @@ export type TermDictionaryEntry = { frequencies: TermFrequency[]; }; -export type PossibleInflectionRuleChain = { +export type InflectionRuleChainCandidate = { source: InflectionSource; inflectionRules: InflectionRuleChain; }; diff --git a/types/ext/translation-internal.d.ts b/types/ext/translation-internal.d.ts index 0f88fc3219..15456e4196 100644 --- a/types/ext/translation-internal.d.ts +++ b/types/ext/translation-internal.d.ts @@ -61,6 +61,6 @@ export type DatabaseDeinflection = { transformedText: string; deinflectedText: string; rules: DeinflectionRuleFlags; - possibleInflectionRuleChains: Dictionary.PossibleInflectionRuleChain[]; + inflectionRuleChainCandidates: Dictionary.InflectionRuleChainCandidate[]; databaseEntries: DictionaryDatabase.TermEntry[]; }; From 6325c2973229b428bbac557e22f2bcbf41d2bfe3 Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 17 Jan 2024 11:09:20 +0100 Subject: [PATCH 27/28] anki template upgrade --- ...nki-field-templates-upgrade-v24.handlebars | 52 +++++++++++++++++++ ext/js/data/options-util.js | 4 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 ext/data/templates/anki-field-templates-upgrade-v24.handlebars diff --git a/ext/data/templates/anki-field-templates-upgrade-v24.handlebars b/ext/data/templates/anki-field-templates-upgrade-v24.handlebars new file mode 100644 index 0000000000..2288737cc2 --- /dev/null +++ b/ext/data/templates/anki-field-templates-upgrade-v24.handlebars @@ -0,0 +1,52 @@ +{{#*inline "phonetic-transcriptions"}} + {{~#if (op ">" definition.phoneticTranscriptions.length 0)~}} +
                + {{~#each definition.phoneticTranscriptions~}} + {{~#each phoneticTranscriptions~}} +
              • + {{~set "any" false~}} + {{~#each tags~}} + {{~#if (get "any")}}, {{else}}({{/if~}} + {{name}} + {{~set "any" true~}} + {{~/each~}} + {{~#if (get "any")}}) {{/if~}} + {{ipa~}} +
              • + {{~/each~}} + {{~/each~}} +
              + {{~/if~}} +{{/inline}} + +{{<<<<<<<}} +{{#*inline "conjugation"}} + {{~#if (op ">" definition.inflectionRuleChainCandidates.length 0)~}} + {{~set "multiple" false~}} + {{~#if (op ">" definition.inflectionRuleChainCandidates.length 1)~}} + {{~set "multiple" true~}} + {{~/if~}} + {{~#if (get "multiple")~}}
                {{/if~}} + {{~#each definition.inflectionRuleChainCandidates~}} + {{~#if (op ">" inflectionRules.length 0)~}} + {{~#if (get "multiple")~}}
              • {{/if~}} + {{~#each inflectionRules~}} + {{~#if (op ">" @index 0)}} « {{/if~}} + {{.}} + {{~/each~}} + {{~#if (get "multiple")~}}
              • {{/if~}} + {{~/if~}} + {{~/each~}} + {{~#if (get "multiple")~}}
              {{/if~}} + {{~/if~}} +{{/inline}} +{{=======}} +{{#*inline "conjugation"}} + {{~#if definition.reasons~}} + {{~#each definition.reasons~}} + {{~#if (op ">" @index 0)}} « {{/if~}} + {{.}} + {{~/each~}} + {{~/if~}} +{{/inline}} +{{>>>>>>>>}} diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js index 07f8867aad..0aabed6f73 100644 --- a/ext/js/data/options-util.js +++ b/ext/js/data/options-util.js @@ -1160,7 +1160,9 @@ export class OptionsUtil { * - Added dictionaries[].useDeinflections. * @type {import('options-util').UpdateFunction} */ - _updateVersion24(options) { + async _updateVersion24(options) { + await this._applyAnkiFieldTemplatesPatch(options, '/data/templates/anki-field-templates-upgrade-v24.handlebars'); + for (const {options: profileOptions} of options.profiles) { for (const dictionary of profileOptions.dictionaries) { dictionary.useDeinflections = true; From ebe0c39b9023274745d79799adddb77f010da00f Mon Sep 17 00:00:00 2001 From: Stefan Vukovic Date: Wed, 17 Jan 2024 11:20:14 +0100 Subject: [PATCH 28/28] update descriptions --- ext/data/schemas/dictionary-term-bank-v3-schema.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ext/data/schemas/dictionary-term-bank-v3-schema.json b/ext/data/schemas/dictionary-term-bank-v3-schema.json index e0a91c9aad..066229c304 100644 --- a/ext/data/schemas/dictionary-term-bank-v3-schema.json +++ b/ext/data/schemas/dictionary-term-bank-v3-schema.json @@ -538,18 +538,18 @@ }, { "type": "array", - "description": "Deinflection of the term to a non-inflected term.", + "description": "Deinflection of the term to an uninflected term.", "items": [ { "type": "string", - "description": "The deinflected term." + "description": "The uninflected term." }, { "type": "array", - "description": "A possible inflection combination that produced the inflected term", + "description": "A chain of inflection rules that produced the inflected term", "items": { "type": "string", - "description": "An inflection." + "description": "A single inflection rule." } } ]