From 0fd70090fb755ba067465c69d8c3bedeb587a69d Mon Sep 17 00:00:00 2001 From: Khai Truong <56820749+khaitruong922@users.noreply.github.com> Date: Tue, 29 Oct 2024 14:23:16 +0700 Subject: [PATCH] Sort entries by primary reading (#1497) * Search term by exact reading when clicking on gloss link * lint * update typing * type * sort by reading match * fix lint and test * add test * fix typing * rename * refactor * refactor * rename to primary reading * remove extract reading implementation --- ext/js/background/backend.js | 8 +- ext/js/display/display.js | 13 +- ext/js/language/translator.js | 68 ++- test/data/anki-note-builder-test-results.json | 178 +++++++ test/data/database-test-cases.json | 6 +- .../valid-dictionary1/term_bank_1.json | 4 +- test/data/translator-test-inputs.json | 26 + .../translator-test-results-note-data1.json | 458 ++++++++++++++++++ test/data/translator-test-results.json | 450 +++++++++++++++++ test/utilities/translator.js | 2 + types/ext/api.d.ts | 1 + types/ext/dictionary.d.ts | 4 + types/ext/translation.d.ts | 4 + types/test/translator.d.ts | 1 + 14 files changed, 1188 insertions(+), 35 deletions(-) diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index 8fe408ee9a..ceb736c40b 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -1463,7 +1463,9 @@ export class Backend { /** @type {import('translator').FindTermsMode} */ const mode = 'simple'; const options = this._getProfileOptions(optionsContext, false); - const details = {matchType: /** @type {import('translation').FindTermsMatchType} */ ('exact'), deinflect: true}; + + /** @type {import('api').FindTermsDetails} */ + const details = {matchType: 'exact', deinflect: true}; const findTermsOptions = this._getTranslatorFindTermsOptions(mode, details, options); /** @type {import('api').ParseTextLine[]} */ const results = []; @@ -2455,9 +2457,10 @@ export class Backend { * @returns {import('translation').FindTermsOptions} An options object. */ _getTranslatorFindTermsOptions(mode, details, options) { - let {matchType, deinflect} = details; + let {matchType, deinflect, primaryReading} = details; if (typeof matchType !== 'string') { matchType = /** @type {import('translation').FindTermsMatchType} */ ('exact'); } if (typeof deinflect !== 'boolean') { deinflect = true; } + if (typeof primaryReading !== 'string') { primaryReading = ''; } const enabledDictionaryMap = this._getTranslatorEnabledDictionaryMap(options); const { general: {mainDictionary, sortFrequencyDictionary, sortFrequencyDictionaryOrder, language}, @@ -2484,6 +2487,7 @@ export class Backend { return { matchType, deinflect, + primaryReading, mainDictionary, sortFrequencyDictionary, sortFrequencyDictionaryOrder, diff --git a/ext/js/display/display.js b/ext/js/display/display.js index af81bed84d..14b943e22e 100644 --- a/ext/js/display/display.js +++ b/ext/js/display/display.js @@ -1265,14 +1265,15 @@ export class Display extends EventDispatcher { /** * @param {boolean} isKanji * @param {string} source + * @param {string} primaryReading * @param {boolean} wildcardsEnabled * @param {import('settings').OptionsContext} optionsContext * @returns {Promise} */ - async _findDictionaryEntries(isKanji, source, wildcardsEnabled, optionsContext) { + async _findDictionaryEntries(isKanji, source, primaryReading, wildcardsEnabled, optionsContext) { /** @type {import('dictionary').DictionaryEntry[]} */ let dictionaryEntries = []; - const {findDetails, source: source2} = this._getFindDetails(source, wildcardsEnabled); + const {findDetails, source: source2} = this._getFindDetails(source, primaryReading, wildcardsEnabled); if (isKanji) { dictionaryEntries = await this._application.api.kanjiFind(source, optionsContext); if (dictionaryEntries.length > 0) { return dictionaryEntries; } @@ -1289,12 +1290,13 @@ export class Display extends EventDispatcher { /** * @param {string} source + * @param {string} primaryReading * @param {boolean} wildcardsEnabled * @returns {{findDetails: import('api').FindTermsDetails, source: string}} */ - _getFindDetails(source, wildcardsEnabled) { + _getFindDetails(source, primaryReading, wildcardsEnabled) { /** @type {import('api').FindTermsDetails} */ - const findDetails = {}; + const findDetails = {primaryReading}; if (wildcardsEnabled) { const match = /^([*\uff0a]*)([\w\W]*?)([*\uff0a]*)$/.exec(source); if (match !== null) { @@ -1327,6 +1329,7 @@ export class Display extends EventDispatcher { if (query === null) { query = ''; } let queryFull = urlSearchParams.get('full'); queryFull = (queryFull !== null ? queryFull : query); + const primaryReading = urlSearchParams.get('primary_reading') ?? ''; const queryOffsetString = urlSearchParams.get('offset'); let queryOffset = 0; if (queryOffsetString !== null) { @@ -1358,7 +1361,7 @@ export class Display extends EventDispatcher { let {dictionaryEntries} = content; if (!Array.isArray(dictionaryEntries)) { - dictionaryEntries = hasEnabledDictionaries && lookup && query.length > 0 ? await this._findDictionaryEntries(type === 'kanji', query, wildcardsEnabled, optionsContext) : []; + dictionaryEntries = hasEnabledDictionaries && lookup && query.length > 0 ? await this._findDictionaryEntries(type === 'kanji', query, primaryReading, wildcardsEnabled, optionsContext) : []; if (this._setContentToken !== token) { return; } content.dictionaryEntries = dictionaryEntries; changeHistory = true; diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 21719da3d1..c5ce979074 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -76,13 +76,13 @@ export class Translator { * @returns {Promise<{dictionaryEntries: import('dictionary').TermDictionaryEntry[], originalTextLength: number}>} An object containing dictionary entries and the length of the original source text. */ async findTerms(mode, text, options) { - const {enabledDictionaryMap, excludeDictionaryDefinitions, sortFrequencyDictionary, sortFrequencyDictionaryOrder, language} = options; + const {enabledDictionaryMap, excludeDictionaryDefinitions, sortFrequencyDictionary, sortFrequencyDictionaryOrder, language, primaryReading} = options; const tagAggregator = new TranslatorTagAggregator(); - let {dictionaryEntries, originalTextLength} = await this._findTermsInternal(text, options, tagAggregator); + let {dictionaryEntries, originalTextLength} = await this._findTermsInternal(text, options, tagAggregator, primaryReading); switch (mode) { case 'group': - dictionaryEntries = this._groupDictionaryEntriesByHeadword(language, dictionaryEntries, tagAggregator); + dictionaryEntries = this._groupDictionaryEntriesByHeadword(language, dictionaryEntries, tagAggregator, primaryReading); break; case 'merge': dictionaryEntries = await this._getRelatedDictionaryEntries(dictionaryEntries, options, tagAggregator); @@ -217,9 +217,10 @@ export class Translator { * @param {string} text * @param {import('translation').FindTermsOptions} options * @param {TranslatorTagAggregator} tagAggregator + * @param {string} primaryReading * @returns {Promise<{dictionaryEntries: import('translation-internal').TermDictionaryEntry[], originalTextLength: number}>} */ - async _findTermsInternal(text, options, tagAggregator) { + async _findTermsInternal(text, options, tagAggregator, primaryReading) { const {removeNonJapaneseCharacters, enabledDictionaryMap} = options; if (removeNonJapaneseCharacters && (['ja', 'zh', 'yue'].includes(options.language))) { text = this._getJapaneseChineseOnlyText(text); @@ -230,16 +231,17 @@ export class Translator { const deinflections = await this._getDeinflections(text, options); - return this._getDictionaryEntries(deinflections, enabledDictionaryMap, tagAggregator); + return this._getDictionaryEntries(deinflections, enabledDictionaryMap, tagAggregator, primaryReading); } /** * @param {import('translation-internal').DatabaseDeinflection[]} deinflections * @param {import('translation').TermEnabledDictionaryMap} enabledDictionaryMap * @param {TranslatorTagAggregator} tagAggregator + * @param {string} primaryReading * @returns {{dictionaryEntries: import('translation-internal').TermDictionaryEntry[], originalTextLength: number}} */ - _getDictionaryEntries(deinflections, enabledDictionaryMap, tagAggregator) { + _getDictionaryEntries(deinflections, enabledDictionaryMap, tagAggregator, primaryReading) { let originalTextLength = 0; /** @type {import('translation-internal').TermDictionaryEntry[]} */ const dictionaryEntries = []; @@ -261,13 +263,13 @@ export class Translator { continue; } if (transformedText.length > existingTransformedLength) { - dictionaryEntries.splice(existingIndex, 1, this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, textProcessorRuleChainCandidates, inflectionRuleChainCandidates, true, enabledDictionaryMap, tagAggregator)); + dictionaryEntries.splice(existingIndex, 1, this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, textProcessorRuleChainCandidates, inflectionRuleChainCandidates, true, enabledDictionaryMap, tagAggregator, primaryReading)); } else { this._mergeInflectionRuleChains(existingEntry, inflectionRuleChainCandidates); this._mergeTextProcessorRuleChains(existingEntry, textProcessorRuleChainCandidates); } } else { - const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, textProcessorRuleChainCandidates, inflectionRuleChainCandidates, true, enabledDictionaryMap, tagAggregator); + const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, textProcessorRuleChainCandidates, inflectionRuleChainCandidates, true, enabledDictionaryMap, tagAggregator, primaryReading); dictionaryEntries.push(dictionaryEntry); ids.add(id); } @@ -680,7 +682,7 @@ export class Translator { * @returns {Promise} */ async _getRelatedDictionaryEntries(dictionaryEntries, options, tagAggregator) { - const {mainDictionary, enabledDictionaryMap, language} = options; + const {mainDictionary, enabledDictionaryMap, language, primaryReading} = options; /** @type {import('translator').SequenceQuery[]} */ const sequenceList = []; /** @type {import('translation-internal').DictionaryEntryGroup[]} */ @@ -711,20 +713,20 @@ export class Translator { if (sequenceList.length > 0) { const secondarySearchDictionaryMap = this._getSecondarySearchDictionaryMap(enabledDictionaryMap); - await this._addRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, sequenceList, enabledDictionaryMap, tagAggregator); + await this._addRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, sequenceList, enabledDictionaryMap, tagAggregator, primaryReading); for (const group of groupedDictionaryEntries) { this._sortTermDictionaryEntriesById(group.dictionaryEntries); } if (ungroupedDictionaryEntriesMap.size > 0 || secondarySearchDictionaryMap.size > 0) { - await this._addSecondaryRelatedDictionaryEntries(language, groupedDictionaryEntries, ungroupedDictionaryEntriesMap, enabledDictionaryMap, secondarySearchDictionaryMap, tagAggregator); + await this._addSecondaryRelatedDictionaryEntries(language, groupedDictionaryEntries, ungroupedDictionaryEntriesMap, enabledDictionaryMap, secondarySearchDictionaryMap, tagAggregator, primaryReading); } } const newDictionaryEntries = []; for (const group of groupedDictionaryEntries) { - newDictionaryEntries.push(this._createGroupedDictionaryEntry(language, group.dictionaryEntries, true, tagAggregator)); + newDictionaryEntries.push(this._createGroupedDictionaryEntry(language, group.dictionaryEntries, true, tagAggregator, primaryReading)); } - newDictionaryEntries.push(...this._groupDictionaryEntriesByHeadword(language, ungroupedDictionaryEntriesMap.values(), tagAggregator)); + newDictionaryEntries.push(...this._groupDictionaryEntriesByHeadword(language, ungroupedDictionaryEntriesMap.values(), tagAggregator, primaryReading)); return newDictionaryEntries; } @@ -734,8 +736,9 @@ export class Translator { * @param {import('translator').SequenceQuery[]} sequenceList * @param {import('translation').TermEnabledDictionaryMap} enabledDictionaryMap * @param {TranslatorTagAggregator} tagAggregator + * @param {string} primaryReading */ - async _addRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, sequenceList, enabledDictionaryMap, tagAggregator) { + async _addRelatedDictionaryEntries(groupedDictionaryEntries, ungroupedDictionaryEntriesMap, sequenceList, enabledDictionaryMap, tagAggregator, primaryReading) { const databaseEntries = await this._database.findTermsBySequenceBulk(sequenceList); for (const databaseEntry of databaseEntries) { const {dictionaryEntries, ids} = groupedDictionaryEntries[databaseEntry.index]; @@ -743,7 +746,7 @@ export class Translator { if (ids.has(id)) { continue; } const {term} = databaseEntry; - const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, term, term, term, [], [], false, enabledDictionaryMap, tagAggregator); + const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, term, term, term, [], [], false, enabledDictionaryMap, tagAggregator, primaryReading); dictionaryEntries.push(dictionaryEntry); ids.add(id); ungroupedDictionaryEntriesMap.delete(id); @@ -757,8 +760,9 @@ export class Translator { * @param {import('translation').TermEnabledDictionaryMap} enabledDictionaryMap * @param {import('translation').TermEnabledDictionaryMap} secondarySearchDictionaryMap * @param {TranslatorTagAggregator} tagAggregator + * @param {string} primaryReading */ - async _addSecondaryRelatedDictionaryEntries(language, groupedDictionaryEntries, ungroupedDictionaryEntriesMap, enabledDictionaryMap, secondarySearchDictionaryMap, tagAggregator) { + async _addSecondaryRelatedDictionaryEntries(language, groupedDictionaryEntries, ungroupedDictionaryEntriesMap, enabledDictionaryMap, secondarySearchDictionaryMap, tagAggregator, primaryReading) { // Prepare grouping info /** @type {import('dictionary-database').TermExactRequest[]} */ const termList = []; @@ -816,7 +820,7 @@ export class Translator { for (const {ids, dictionaryEntries} of target.groups) { if (ids.has(id)) { continue; } - const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, sourceText, sourceText, sourceText, [], [], false, enabledDictionaryMap, tagAggregator); + const dictionaryEntry = this._createTermDictionaryEntryFromDatabaseEntry(databaseEntry, sourceText, sourceText, sourceText, [], [], false, enabledDictionaryMap, tagAggregator, primaryReading); dictionaryEntries.push(dictionaryEntry); ids.add(id); ungroupedDictionaryEntriesMap.delete(id); @@ -828,9 +832,10 @@ export class Translator { * @param {string} language * @param {Iterable} dictionaryEntries * @param {TranslatorTagAggregator} tagAggregator + * @param {string} primaryReading * @returns {import('translation-internal').TermDictionaryEntry[]} */ - _groupDictionaryEntriesByHeadword(language, dictionaryEntries, tagAggregator) { + _groupDictionaryEntriesByHeadword(language, dictionaryEntries, tagAggregator, primaryReading) { /** @type {Map} */ const groups = new Map(); const readingNormalizer = this._readingNormalizers.get(language); @@ -848,7 +853,7 @@ export class Translator { const newDictionaryEntries = []; for (const groupDictionaryEntries of groups.values()) { - newDictionaryEntries.push(this._createGroupedDictionaryEntry(language, groupDictionaryEntries, false, tagAggregator)); + newDictionaryEntries.push(this._createGroupedDictionaryEntry(language, groupDictionaryEntries, false, tagAggregator, primaryReading)); } return newDictionaryEntries; } @@ -1668,12 +1673,13 @@ export class Translator { * @param {string} dictionaryAlias * @param {number} dictionaryPriority * @param {number} sourceTermExactMatchCount + * @param {boolean} matchPrimaryReading * @param {number} maxOriginalTextLength * @param {import('dictionary').TermHeadword[]} headwords * @param {import('dictionary').TermDefinition[]} definitions * @returns {import('translation-internal').TermDictionaryEntry} */ - _createTermDictionaryEntry(isPrimary, textProcessorRuleChainCandidates, inflectionRuleChainCandidates, score, dictionaryIndex, dictionaryAlias, dictionaryPriority, sourceTermExactMatchCount, maxOriginalTextLength, headwords, definitions) { + _createTermDictionaryEntry(isPrimary, textProcessorRuleChainCandidates, inflectionRuleChainCandidates, score, dictionaryIndex, dictionaryAlias, dictionaryPriority, sourceTermExactMatchCount, matchPrimaryReading, maxOriginalTextLength, headwords, definitions) { return { type: 'term', isPrimary, @@ -1685,6 +1691,7 @@ export class Translator { dictionaryAlias, dictionaryPriority, sourceTermExactMatchCount, + matchPrimaryReading, maxOriginalTextLength, headwords, definitions, @@ -1703,9 +1710,10 @@ export class Translator { * @param {boolean} isPrimary * @param {Map} enabledDictionaryMap * @param {TranslatorTagAggregator} tagAggregator + * @param {string} primaryReading * @returns {import('translation-internal').TermDictionaryEntry} */ - _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, textProcessorRuleChainCandidates, inflectionRuleChainCandidates, isPrimary, enabledDictionaryMap, tagAggregator) { + _createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, textProcessorRuleChainCandidates, inflectionRuleChainCandidates, isPrimary, enabledDictionaryMap, tagAggregator, primaryReading) { const { matchType, matchSource, @@ -1723,6 +1731,7 @@ export class Translator { // 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 matchPrimaryReading = primaryReading.length > 0 && reading === primaryReading; const {index: dictionaryIndex, priority: dictionaryPriority} = this._getDictionaryOrder(dictionary, enabledDictionaryMap); const dictionaryAlias = this._getDictionaryAlias(dictionary, enabledDictionaryMap); const sourceTermExactMatchCount = (isPrimary && deinflectedText === term ? 1 : 0); @@ -1747,6 +1756,7 @@ export class Translator { dictionaryAlias, dictionaryPriority, sourceTermExactMatchCount, + matchPrimaryReading, maxOriginalTextLength, [this._createTermHeadword(0, term, reading, [source], headwordTagGroups, rules)], [this._createTermDefinition(0, [0], dictionary, dictionaryIndex, dictionaryAlias, dictionaryPriority, id, score, [sequence], isPrimary, definitionTagGroups, contentDefinitions)], @@ -1758,9 +1768,10 @@ export class Translator { * @param {import('translation-internal').TermDictionaryEntry[]} dictionaryEntries * @param {boolean} checkDuplicateDefinitions * @param {TranslatorTagAggregator} tagAggregator + * @param {string} primaryReading * @returns {import('translation-internal').TermDictionaryEntry} */ - _createGroupedDictionaryEntry(language, dictionaryEntries, checkDuplicateDefinitions, tagAggregator) { + _createGroupedDictionaryEntry(language, dictionaryEntries, checkDuplicateDefinitions, tagAggregator, primaryReading) { // Headwords are generated before sorting, so that the order of dictionaryEntries can be maintained const definitionEntries = []; /** @type {Map} */ @@ -1820,7 +1831,11 @@ export class Translator { const headwordsArray = [...headwords.values()]; let sourceTermExactMatchCount = 0; - for (const {sources} of headwordsArray) { + let matchPrimaryReading = false; + for (const {sources, reading} of headwordsArray) { + if (primaryReading.length > 0 && reading === primaryReading) { + matchPrimaryReading = true; + } for (const source of sources) { if (source.isPrimary && source.matchSource === 'term') { ++sourceTermExactMatchCount; @@ -1838,6 +1853,7 @@ export class Translator { dictionaryAlias, dictionaryPriority, sourceTermExactMatchCount, + matchPrimaryReading, maxOriginalTextLength, headwordsArray, definitions, @@ -2017,8 +2033,12 @@ export class Translator { * @returns {number} */ const compareFunction = (v1, v2) => { + // Sort by reading match + let i = (v2.matchPrimaryReading ? 1 : 0) - (v1.matchPrimaryReading ? 1 : 0); + if (i !== 0) { return i; } + // Sort by length of source term - let i = v2.maxOriginalTextLength - v1.maxOriginalTextLength; + i = v2.maxOriginalTextLength - v1.maxOriginalTextLength; if (i !== 0) { return i; } // Sort by length of the shortest text processing chain diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index a7e954152d..b496d0b880 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -4606,5 +4606,183 @@ "url": "url:" } ] + }, + { + "name": "Find terms using primary reading 1", + "results": [ + { + "audio": "", + "clipboard-image": "", + "clipboard-text": "", + "cloze-body": "自重", + "cloze-body-kana": "じちょう", + "cloze-prefix": "cloze-prefix", + "cloze-suffix": "cloze-suffix", + "conjugation": "", + "dictionary": "Test Dictionary 2", + "dictionary-alias": "termsDictAlias", + "document-title": "title", + "expression": "自重", + "frequencies": "", + "frequency-harmonic-rank": "9999999", + "frequency-harmonic-occurrence": "0", + "frequency-average-rank": "9999999", + "frequency-average-occurrence": "0", + "furigana": "自重じちょう", + "furigana-plain": "自重[じちょう]", + "glossary": "
(n, termsDictAlias) jichou definition
", + "glossary-brief": "
jichou definition
", + "glossary-no-dictionary": "
(n) jichou definition
", + "glossary-first": "
(n, termsDictAlias) jichou definition
", + "glossary-first-brief": "
jichou definition
", + "glossary-first-no-dictionary": "
(n) jichou definition
", + "part-of-speech": "Noun", + "pitch-accents": "", + "pitch-accent-graphs": "", + "pitch-accent-graphs-jj": "", + "pitch-accent-positions": "", + "pitch-accent-categories": "", + "phonetic-transcriptions": "", + "reading": "じちょう", + "screenshot": "", + "search-query": "fullQuery", + "popup-selection-text": "", + "sentence": "cloze-prefix自重cloze-suffix", + "sentence-furigana": "cloze-prefix自重cloze-suffix", + "tags": "n", + "url": "url:" + }, + { + "audio": "", + "clipboard-image": "", + "clipboard-text": "", + "cloze-body": "自重", + "cloze-body-kana": "じじゅう", + "cloze-prefix": "cloze-prefix", + "cloze-suffix": "cloze-suffix", + "conjugation": "", + "dictionary": "Test Dictionary 2", + "dictionary-alias": "termsDictAlias", + "document-title": "title", + "expression": "自重", + "frequencies": "", + "frequency-harmonic-rank": "9999999", + "frequency-harmonic-occurrence": "0", + "frequency-average-rank": "9999999", + "frequency-average-occurrence": "0", + "furigana": "自重じじゅう", + "furigana-plain": "自重[じじゅう]", + "glossary": "
(n, termsDictAlias) jijuu definition
", + "glossary-brief": "
jijuu definition
", + "glossary-no-dictionary": "
(n) jijuu definition
", + "glossary-first": "
(n, termsDictAlias) jijuu definition
", + "glossary-first-brief": "
jijuu definition
", + "glossary-first-no-dictionary": "
(n) jijuu definition
", + "part-of-speech": "Noun", + "pitch-accents": "", + "pitch-accent-graphs": "", + "pitch-accent-graphs-jj": "", + "pitch-accent-positions": "", + "pitch-accent-categories": "", + "phonetic-transcriptions": "", + "reading": "じじゅう", + "screenshot": "", + "search-query": "fullQuery", + "popup-selection-text": "", + "sentence": "cloze-prefix自重cloze-suffix", + "sentence-furigana": "cloze-prefix自重cloze-suffix", + "tags": "n", + "url": "url:" + } + ] + }, + { + "name": "Find terms using primary reading 2", + "results": [ + { + "audio": "", + "clipboard-image": "", + "clipboard-text": "", + "cloze-body": "自重", + "cloze-body-kana": "じじゅう", + "cloze-prefix": "cloze-prefix", + "cloze-suffix": "cloze-suffix", + "conjugation": "", + "dictionary": "Test Dictionary 2", + "dictionary-alias": "termsDictAlias", + "document-title": "title", + "expression": "自重", + "frequencies": "", + "frequency-harmonic-rank": "9999999", + "frequency-harmonic-occurrence": "0", + "frequency-average-rank": "9999999", + "frequency-average-occurrence": "0", + "furigana": "自重じじゅう", + "furigana-plain": "自重[じじゅう]", + "glossary": "
(n, termsDictAlias) jijuu definition
", + "glossary-brief": "
jijuu definition
", + "glossary-no-dictionary": "
(n) jijuu definition
", + "glossary-first": "
(n, termsDictAlias) jijuu definition
", + "glossary-first-brief": "
jijuu definition
", + "glossary-first-no-dictionary": "
(n) jijuu definition
", + "part-of-speech": "Noun", + "pitch-accents": "", + "pitch-accent-graphs": "", + "pitch-accent-graphs-jj": "", + "pitch-accent-positions": "", + "pitch-accent-categories": "", + "phonetic-transcriptions": "", + "reading": "じじゅう", + "screenshot": "", + "search-query": "fullQuery", + "popup-selection-text": "", + "sentence": "cloze-prefix自重cloze-suffix", + "sentence-furigana": "cloze-prefix自重cloze-suffix", + "tags": "n", + "url": "url:" + }, + { + "audio": "", + "clipboard-image": "", + "clipboard-text": "", + "cloze-body": "自重", + "cloze-body-kana": "じちょう", + "cloze-prefix": "cloze-prefix", + "cloze-suffix": "cloze-suffix", + "conjugation": "", + "dictionary": "Test Dictionary 2", + "dictionary-alias": "termsDictAlias", + "document-title": "title", + "expression": "自重", + "frequencies": "", + "frequency-harmonic-rank": "9999999", + "frequency-harmonic-occurrence": "0", + "frequency-average-rank": "9999999", + "frequency-average-occurrence": "0", + "furigana": "自重じちょう", + "furigana-plain": "自重[じちょう]", + "glossary": "
(n, termsDictAlias) jichou definition
", + "glossary-brief": "
jichou definition
", + "glossary-no-dictionary": "
(n) jichou definition
", + "glossary-first": "
(n, termsDictAlias) jichou definition
", + "glossary-first-brief": "
jichou definition
", + "glossary-first-no-dictionary": "
(n) jichou definition
", + "part-of-speech": "Noun", + "pitch-accents": "", + "pitch-accent-graphs": "", + "pitch-accent-graphs-jj": "", + "pitch-accent-positions": "", + "pitch-accent-categories": "", + "phonetic-transcriptions": "", + "reading": "じちょう", + "screenshot": "", + "search-query": "fullQuery", + "popup-selection-text": "", + "sentence": "cloze-prefix自重cloze-suffix", + "sentence-furigana": "cloze-prefix自重cloze-suffix", + "tags": "n", + "url": "url:" + } + ] } ] diff --git a/test/data/database-test-cases.json b/test/data/database-test-cases.json index 6d0cbe2f59..1595ffc4ae 100644 --- a/test/data/database-test-cases.json +++ b/test/data/database-test-cases.json @@ -28,7 +28,7 @@ "ipa": 1 }, "terms": { - "total": 31 + "total": 33 } } }, @@ -37,7 +37,7 @@ { "kanji": 2, "kanjiMeta": 6, - "terms": 31, + "terms": 33, "termMeta": 39, "tagMeta": 15, "media": 6 @@ -46,7 +46,7 @@ "total": { "kanji": 2, "kanjiMeta": 6, - "terms": 31, + "terms": 33, "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 0a635b84d6..7c3e005a40 100644 --- a/test/data/dictionaries/valid-dictionary1/term_bank_1.json +++ b/test/data/dictionaries/valid-dictionary1/term_bank_1.json @@ -345,5 +345,7 @@ ["English", "", "n", "n", 1, ["English definition"], 19, ""], ["language", "", "n", "n", 1, ["language definition"], 20, ""], ["USB", "ユーエスビー", "n", "n", 1, ["USB definition"], 21, ""], - ["마시다", "", "v", "v", 1, ["masida definition"], 22, ""] + ["마시다", "", "v", "v", 1, ["masida definition"], 22, ""], + ["自重", "じちょう", "n", "n", 1, ["jichou definition"], 23, ""], + ["自重", "じじゅう", "n", "n", 2, ["jijuu definition"], 24, ""] ] diff --git a/test/data/translator-test-inputs.json b/test/data/translator-test-inputs.json index 25115e9c23..bceb9d68eb 100644 --- a/test/data/translator-test-inputs.json +++ b/test/data/translator-test-inputs.json @@ -513,6 +513,32 @@ "searchResolution": "word" } ] + }, + { + "name": "Find terms using primary reading 1", + "func": "findTerms", + "mode": "split", + "text": "自重", + "options": [ + "default", + { + "type": "terms", + "primaryReading": "じちょう" + } + ] + }, + { + "name": "Find terms using primary reading 2", + "func": "findTerms", + "mode": "split", + "text": "自重", + "options": [ + "default", + { + "type": "terms", + "primaryReading": "じじゅう" + } + ] } ] } diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index e43042a0a8..dedba5601e 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -35095,5 +35095,463 @@ "media": {} } ] + }, + { + "name": "Find terms using primary reading 1", + "noteDataList": [ + { + "marker": "{marker}", + "definition": { + "type": "term", + "id": 31, + "source": "自重", + "rawSource": "自重", + "sourceTerm": "自重", + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 1, + "isPrimary": true, + "sequence": 23, + "dictionary": "Test Dictionary 2", + "dictionaryAlias": "termsDictAlias", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "dictionaryNames": [ + "Test Dictionary 2" + ], + "expression": "自重", + "reading": "じちょう", + "expressions": [ + { + "sourceTerm": "自重", + "expression": "自重", + "reading": "じちょう", + "termTags": [], + "frequencies": [], + "pitches": [], + "furiganaSegments": [ + { + "text": "自重", + "furigana": "じちょう" + } + ], + "termFrequency": "normal", + "wordClasses": [ + "n" + ] + } + ], + "glossary": [ + "jichou definition" + ], + "glossaryScopedStyles": ".yomitan-glossary ul[data-sc-content='glossary'] {\n color: #ffff00;\n}", + "dictScopedStyles": ".yomitan-glossary [data-dictionary=\"Test Dictionary 2\"] ul[data-sc-content='glossary'] {\n color: #ffff00;\n}", + "definitionTags": [ + { + "name": "n", + "category": "partOfSpeech", + "notes": "noun", + "order": 0, + "score": 0, + "dictionary": "Test Dictionary 2", + "redundant": false + } + ], + "termTags": [], + "frequencies": [], + "frequencyHarmonic": -1, + "frequencyAverage": -1, + "pitches": [], + "phoneticTranscriptions": [], + "sourceTermExactMatchCount": 1, + "url": "url:", + "cloze": { + "sentence": "", + "prefix": "", + "body": "", + "bodyKana": "", + "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": {} + }, + { + "marker": "{marker}", + "definition": { + "type": "term", + "id": 32, + "source": "自重", + "rawSource": "自重", + "sourceTerm": "自重", + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 2, + "isPrimary": true, + "sequence": 24, + "dictionary": "Test Dictionary 2", + "dictionaryAlias": "termsDictAlias", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "dictionaryNames": [ + "Test Dictionary 2" + ], + "expression": "自重", + "reading": "じじゅう", + "expressions": [ + { + "sourceTerm": "自重", + "expression": "自重", + "reading": "じじゅう", + "termTags": [], + "frequencies": [], + "pitches": [], + "furiganaSegments": [ + { + "text": "自重", + "furigana": "じじゅう" + } + ], + "termFrequency": "normal", + "wordClasses": [ + "n" + ] + } + ], + "glossary": [ + "jijuu definition" + ], + "glossaryScopedStyles": ".yomitan-glossary ul[data-sc-content='glossary'] {\n color: #ffff00;\n}", + "dictScopedStyles": ".yomitan-glossary [data-dictionary=\"Test Dictionary 2\"] ul[data-sc-content='glossary'] {\n color: #ffff00;\n}", + "definitionTags": [ + { + "name": "n", + "category": "partOfSpeech", + "notes": "noun", + "order": 0, + "score": 0, + "dictionary": "Test Dictionary 2", + "redundant": false + } + ], + "termTags": [], + "frequencies": [], + "frequencyHarmonic": -1, + "frequencyAverage": -1, + "pitches": [], + "phoneticTranscriptions": [], + "sourceTermExactMatchCount": 1, + "url": "url:", + "cloze": { + "sentence": "", + "prefix": "", + "body": "", + "bodyKana": "", + "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": {} + } + ] + }, + { + "name": "Find terms using primary reading 2", + "noteDataList": [ + { + "marker": "{marker}", + "definition": { + "type": "term", + "id": 32, + "source": "自重", + "rawSource": "自重", + "sourceTerm": "自重", + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 2, + "isPrimary": true, + "sequence": 24, + "dictionary": "Test Dictionary 2", + "dictionaryAlias": "termsDictAlias", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "dictionaryNames": [ + "Test Dictionary 2" + ], + "expression": "自重", + "reading": "じじゅう", + "expressions": [ + { + "sourceTerm": "自重", + "expression": "自重", + "reading": "じじゅう", + "termTags": [], + "frequencies": [], + "pitches": [], + "furiganaSegments": [ + { + "text": "自重", + "furigana": "じじゅう" + } + ], + "termFrequency": "normal", + "wordClasses": [ + "n" + ] + } + ], + "glossary": [ + "jijuu definition" + ], + "glossaryScopedStyles": ".yomitan-glossary ul[data-sc-content='glossary'] {\n color: #ffff00;\n}", + "dictScopedStyles": ".yomitan-glossary [data-dictionary=\"Test Dictionary 2\"] ul[data-sc-content='glossary'] {\n color: #ffff00;\n}", + "definitionTags": [ + { + "name": "n", + "category": "partOfSpeech", + "notes": "noun", + "order": 0, + "score": 0, + "dictionary": "Test Dictionary 2", + "redundant": false + } + ], + "termTags": [], + "frequencies": [], + "frequencyHarmonic": -1, + "frequencyAverage": -1, + "pitches": [], + "phoneticTranscriptions": [], + "sourceTermExactMatchCount": 1, + "url": "url:", + "cloze": { + "sentence": "", + "prefix": "", + "body": "", + "bodyKana": "", + "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": {} + }, + { + "marker": "{marker}", + "definition": { + "type": "term", + "id": 31, + "source": "自重", + "rawSource": "自重", + "sourceTerm": "自重", + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 1, + "isPrimary": true, + "sequence": 23, + "dictionary": "Test Dictionary 2", + "dictionaryAlias": "termsDictAlias", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "dictionaryNames": [ + "Test Dictionary 2" + ], + "expression": "自重", + "reading": "じちょう", + "expressions": [ + { + "sourceTerm": "自重", + "expression": "自重", + "reading": "じちょう", + "termTags": [], + "frequencies": [], + "pitches": [], + "furiganaSegments": [ + { + "text": "自重", + "furigana": "じちょう" + } + ], + "termFrequency": "normal", + "wordClasses": [ + "n" + ] + } + ], + "glossary": [ + "jichou definition" + ], + "glossaryScopedStyles": ".yomitan-glossary ul[data-sc-content='glossary'] {\n color: #ffff00;\n}", + "dictScopedStyles": ".yomitan-glossary [data-dictionary=\"Test Dictionary 2\"] ul[data-sc-content='glossary'] {\n color: #ffff00;\n}", + "definitionTags": [ + { + "name": "n", + "category": "partOfSpeech", + "notes": "noun", + "order": 0, + "score": 0, + "dictionary": "Test Dictionary 2", + "redundant": false + } + ], + "termTags": [], + "frequencies": [], + "frequencyHarmonic": -1, + "frequencyAverage": -1, + "pitches": [], + "phoneticTranscriptions": [], + "sourceTermExactMatchCount": 1, + "url": "url:", + "cloze": { + "sentence": "", + "prefix": "", + "body": "", + "bodyKana": "", + "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": {} + } + ] } ] diff --git a/test/data/translator-test-results.json b/test/data/translator-test-results.json index 1cd5b4ba9d..bd09e49945 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -314,6 +314,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -494,6 +495,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -693,6 +695,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -874,6 +877,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -1055,6 +1059,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -1236,6 +1241,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -1417,6 +1423,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -1597,6 +1604,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -1796,6 +1804,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -2002,6 +2011,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -2208,6 +2218,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -2414,6 +2425,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -2625,6 +2637,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -2811,6 +2824,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -2997,6 +3011,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -3183,6 +3198,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -3364,6 +3380,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -3544,6 +3561,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -3743,6 +3761,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -3866,6 +3885,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -4052,6 +4072,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 3, "headwords": [ { @@ -4247,6 +4268,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -4433,6 +4455,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -4614,6 +4637,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -4801,6 +4825,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -4982,6 +5007,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -5169,6 +5195,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -5375,6 +5402,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -5586,6 +5614,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -5772,6 +5801,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -5959,6 +5989,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -6165,6 +6196,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -6376,6 +6408,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -6562,6 +6595,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -6749,6 +6783,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 3, "headwords": [ { @@ -6882,6 +6917,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -6949,6 +6985,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -7016,6 +7053,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -7083,6 +7121,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -7155,6 +7194,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -7227,6 +7267,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -7299,6 +7340,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -7371,6 +7413,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -7438,6 +7481,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -7505,6 +7549,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -7578,6 +7623,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -7833,6 +7879,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -8093,6 +8140,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -8328,6 +8376,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -8558,6 +8607,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -8738,6 +8788,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -8937,6 +8988,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 2, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -9424,6 +9476,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 2, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -9857,6 +9910,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -10037,6 +10091,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -10257,6 +10312,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 12, "headwords": [ { @@ -10484,6 +10540,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 12, "headwords": [ { @@ -10711,6 +10768,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 12, "headwords": [ { @@ -10938,6 +10996,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 12, "headwords": [ { @@ -11149,6 +11208,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -11335,6 +11395,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -11521,6 +11582,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -11707,6 +11769,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -11888,6 +11951,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -12068,6 +12132,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 1, "headwords": [ { @@ -12269,6 +12334,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 10, "headwords": [ { @@ -12477,6 +12543,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 10, "headwords": [ { @@ -12685,6 +12752,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 10, "headwords": [ { @@ -12893,6 +12961,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 10, "headwords": [ { @@ -13106,6 +13175,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 5, "headwords": [ { @@ -13294,6 +13364,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 5, "headwords": [ { @@ -13482,6 +13553,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 5, "headwords": [ { @@ -13670,6 +13742,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 5, "headwords": [ { @@ -13853,6 +13926,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -14035,6 +14109,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -14236,6 +14311,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 12, "headwords": [ { @@ -14444,6 +14520,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 12, "headwords": [ { @@ -14652,6 +14729,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 12, "headwords": [ { @@ -14860,6 +14938,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 12, "headwords": [ { @@ -15073,6 +15152,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 6, "headwords": [ { @@ -15261,6 +15341,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 6, "headwords": [ { @@ -15449,6 +15530,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 6, "headwords": [ { @@ -15637,6 +15719,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 6, "headwords": [ { @@ -15820,6 +15903,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 3, "headwords": [ { @@ -16002,6 +16086,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 3, "headwords": [ { @@ -16208,6 +16293,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -16323,6 +16409,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 5, "headwords": [ { @@ -16447,6 +16534,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 7, "headwords": [ { @@ -16560,6 +16648,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -17047,6 +17136,7 @@ "dictionaryAlias": "", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -17486,6 +17576,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 3, "headwords": [ { @@ -17646,6 +17737,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -17752,6 +17844,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -17858,6 +17951,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -17964,6 +18058,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -18070,6 +18165,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -18193,6 +18289,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -18340,6 +18437,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 5, "headwords": [ { @@ -18426,6 +18524,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -18498,6 +18597,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 7, "headwords": [ { @@ -18586,6 +18686,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 3, "headwords": [ { @@ -18674,6 +18775,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -18857,6 +18959,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -19046,6 +19149,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -19229,6 +19333,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -19418,6 +19523,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -19535,6 +19641,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -19719,6 +19826,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 2, "headwords": [ { @@ -19925,6 +20033,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 0, + "matchPrimaryReading": false, "maxOriginalTextLength": 7, "headwords": [ { @@ -20011,6 +20120,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 7, "headwords": [ { @@ -20099,6 +20209,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 8, "headwords": [ { @@ -20192,6 +20303,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 4, "headwords": [ { @@ -20278,6 +20390,7 @@ "dictionaryAlias": "termsDictAlias", "dictionaryPriority": 0, "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, "maxOriginalTextLength": 7, "headwords": [ { @@ -20341,5 +20454,342 @@ "frequencies": [] } ] + }, + { + "name": "Find term using primary reading 1", + "originalTextLength": 2, + "dictionaryEntries": [ + { + "type": "term", + "isPrimary": true, + "textProcessorRuleChainCandidates": [ + [] + ], + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 1, + "frequencyOrder": 0, + "dictionaryIndex": 0, + "dictionaryAlias": "termsDictAlias", + "dictionaryPriority": 0, + "sourceTermExactMatchCount": 1, + "matchPrimaryReading": true, + "maxOriginalTextLength": 2, + "headwords": [ + { + "index": 0, + "term": "自重", + "reading": "じちょう", + "sources": [ + { + "originalText": "自重", + "transformedText": "自重", + "deinflectedText": "自重", + "matchType": "exact", + "matchSource": "term", + "isPrimary": true + } + ], + "tags": [], + "wordClasses": [ + "n" + ] + } + ], + "definitions": [ + { + "index": 0, + "headwordIndices": [ + 0 + ], + "dictionary": "Test Dictionary 2", + "dictionaryIndex": 0, + "dictionaryAlias": "termsDictAlias", + "dictionaryPriority": 0, + "id": 31, + "score": 1, + "frequencyOrder": 0, + "sequences": [ + 23 + ], + "isPrimary": true, + "tags": [ + { + "name": "n", + "category": "partOfSpeech", + "order": 0, + "score": 0, + "content": [ + "noun" + ], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ], + "entries": [ + "jichou definition" + ] + } + ], + "pronunciations": [], + "frequencies": [] + }, + { + "type": "term", + "isPrimary": true, + "textProcessorRuleChainCandidates": [ + [] + ], + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 2, + "frequencyOrder": 0, + "dictionaryIndex": 0, + "dictionaryAlias": "termsDictAlias", + "dictionaryPriority": 0, + "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, + "maxOriginalTextLength": 2, + "headwords": [ + { + "index": 0, + "term": "自重", + "reading": "じじゅう", + "sources": [ + { + "originalText": "自重", + "transformedText": "自重", + "deinflectedText": "自重", + "matchType": "exact", + "matchSource": "term", + "isPrimary": true + } + ], + "tags": [], + "wordClasses": [ + "n" + ] + } + ], + "definitions": [ + { + "index": 0, + "headwordIndices": [ + 0 + ], + "dictionary": "Test Dictionary 2", + "dictionaryIndex": 0, + "dictionaryAlias": "termsDictAlias", + "dictionaryPriority": 0, + "id": 32, + "score": 2, + "frequencyOrder": 0, + "sequences": [ + 24 + ], + "isPrimary": true, + "tags": [ + { + "name": "n", + "category": "partOfSpeech", + "order": 0, + "score": 0, + "content": [ + "noun" + ], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ], + "entries": [ + "jijuu definition" + ] + } + ], + "pronunciations": [], + "frequencies": [] + } + ] + }, + { + "name": "Find term using primary reading 2", + "originalTextLength": 2, + "dictionaryEntries": [ + + { + "type": "term", + "isPrimary": true, + "textProcessorRuleChainCandidates": [ + [] + ], + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 2, + "frequencyOrder": 0, + "dictionaryIndex": 0, + "dictionaryAlias": "termsDictAlias", + "dictionaryPriority": 0, + "sourceTermExactMatchCount": 1, + "matchPrimaryReading": true, + "maxOriginalTextLength": 2, + "headwords": [ + { + "index": 0, + "term": "自重", + "reading": "じじゅう", + "sources": [ + { + "originalText": "自重", + "transformedText": "自重", + "deinflectedText": "自重", + "matchType": "exact", + "matchSource": "term", + "isPrimary": true + } + ], + "tags": [], + "wordClasses": [ + "n" + ] + } + ], + "definitions": [ + { + "index": 0, + "headwordIndices": [ + 0 + ], + "dictionary": "Test Dictionary 2", + "dictionaryIndex": 0, + "dictionaryAlias": "termsDictAlias", + "dictionaryPriority": 0, + "id": 32, + "score": 2, + "frequencyOrder": 0, + "sequences": [ + 24 + ], + "isPrimary": true, + "tags": [ + { + "name": "n", + "category": "partOfSpeech", + "order": 0, + "score": 0, + "content": [ + "noun" + ], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ], + "entries": [ + "jijuu definition" + ] + } + ], + "pronunciations": [], + "frequencies": [] + }, + { + "type": "term", + "isPrimary": true, + "textProcessorRuleChainCandidates": [ + [] + ], + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 1, + "frequencyOrder": 0, + "dictionaryIndex": 0, + "dictionaryAlias": "termsDictAlias", + "dictionaryPriority": 0, + "sourceTermExactMatchCount": 1, + "matchPrimaryReading": false, + "maxOriginalTextLength": 2, + "headwords": [ + { + "index": 0, + "term": "自重", + "reading": "じちょう", + "sources": [ + { + "originalText": "自重", + "transformedText": "自重", + "deinflectedText": "自重", + "matchType": "exact", + "matchSource": "term", + "isPrimary": true + } + ], + "tags": [], + "wordClasses": [ + "n" + ] + } + ], + "definitions": [ + { + "index": 0, + "headwordIndices": [ + 0 + ], + "dictionary": "Test Dictionary 2", + "dictionaryIndex": 0, + "dictionaryAlias": "termsDictAlias", + "dictionaryPriority": 0, + "id": 31, + "score": 1, + "frequencyOrder": 0, + "sequences": [ + 23 + ], + "isPrimary": true, + "tags": [ + { + "name": "n", + "category": "partOfSpeech", + "order": 0, + "score": 0, + "content": [ + "noun" + ], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ], + "entries": [ + "jichou definition" + ] + } + ], + "pronunciations": [], + "frequencies": [] + } + ] } ] diff --git a/test/utilities/translator.js b/test/utilities/translator.js index e288c8df2e..314b1a680b 100644 --- a/test/utilities/translator.js +++ b/test/utilities/translator.js @@ -124,6 +124,7 @@ export function createFindTermsOptions(dictionaryName, optionsPresets, optionsAr sortFrequencyDictionary, sortFrequencyDictionaryOrder, removeNonJapaneseCharacters, + primaryReading, excludeDictionaryDefinitions, searchResolution, language, @@ -136,6 +137,7 @@ export function createFindTermsOptions(dictionaryName, optionsPresets, optionsAr sortFrequencyDictionary: typeof sortFrequencyDictionary !== 'undefined' ? sortFrequencyDictionary : null, sortFrequencyDictionaryOrder: typeof sortFrequencyDictionaryOrder !== 'undefined' ? sortFrequencyDictionaryOrder : 'ascending', removeNonJapaneseCharacters: typeof removeNonJapaneseCharacters !== 'undefined' ? removeNonJapaneseCharacters : false, + primaryReading: typeof primaryReading !== 'undefined' ? primaryReading : '', textReplacements, enabledDictionaryMap, excludeDictionaryDefinitions: Array.isArray(excludeDictionaryDefinitions) ? new Set(excludeDictionaryDefinitions) : null, diff --git a/types/ext/api.d.ts b/types/ext/api.d.ts index 46be7938eb..45996c48c2 100644 --- a/types/ext/api.d.ts +++ b/types/ext/api.d.ts @@ -48,6 +48,7 @@ import type { export type FindTermsDetails = { matchType?: Translation.FindTermsMatchType; deinflect?: boolean; + primaryReading?: string; }; export type ParseTextResultItem = { diff --git a/types/ext/dictionary.d.ts b/types/ext/dictionary.d.ts index ac9b7940ca..5a6fef4ab7 100644 --- a/types/ext/dictionary.d.ts +++ b/types/ext/dictionary.d.ts @@ -247,6 +247,10 @@ export type TermDictionaryEntry = { * The number of primary sources that had an exact text match for the term. */ sourceTermExactMatchCount: number; + /** + * Whether the term reading matched the primary reading. + */ + matchPrimaryReading: boolean; /** * The maximum length of the original text for all primary sources. */ diff --git a/types/ext/translation.d.ts b/types/ext/translation.d.ts index 4d60507ce3..a24fb744bd 100644 --- a/types/ext/translation.d.ts +++ b/types/ext/translation.d.ts @@ -68,6 +68,10 @@ export type FindTermsOptions = { * Whether or not deinflection should be performed. */ deinflect: boolean; + /** + * The reading which will be sorted to the top of the results. + */ + primaryReading: string; /** * The name of the primary dictionary to search. */ diff --git a/types/test/translator.d.ts b/types/test/translator.d.ts index efd5cc3fcf..2d18b75d13 100644 --- a/types/test/translator.d.ts +++ b/types/test/translator.d.ts @@ -44,6 +44,7 @@ export type FindTermsOptionsPreset = { sortFrequencyDictionary?: string | null; sortFrequencyDictionaryOrder?: FindTermsSortOrder; removeNonJapaneseCharacters?: boolean; + primaryReading?: string; textReplacements?: (FindTermsTextReplacement[] | null)[]; enabledDictionaryMap?: [key: string, value: FindTermDictionary][]; excludeDictionaryDefinitions?: string[] | null;