From 803844442c4b1b8069800a3379705be82de6113b Mon Sep 17 00:00:00 2001 From: Khai Truong Date: Thu, 17 Oct 2024 21:12:59 +0700 Subject: [PATCH] add test --- 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 | 337 +++++++++++++ test/utilities/translator.js | 2 + types/test/translator.d.ts | 1 + 8 files changed, 1008 insertions(+), 4 deletions(-) diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index a7e954152d..0eefac93d6 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 prioritized 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 prioritized 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..7a08b77b69 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 prioritized reading 1", + "func": "findTerms", + "mode": "split", + "text": "自重", + "options": [ + "default", + { + "type": "terms", + "prioritizedReading": "じちょう" + } + ] + }, + { + "name": "Find terms using prioritized reading 2", + "func": "findTerms", + "mode": "split", + "text": "自重", + "options": [ + "default", + { + "type": "terms", + "prioritizedReading": "じじゅう" + } + ] } ] } diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index e43042a0a8..513799d71c 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 prioritized 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 prioritized 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 1f1e0564df..178942f775 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -20454,5 +20454,342 @@ "frequencies": [] } ] + }, + { + "name": "Find term using prioritized 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, + "matchPrioritizedReading": 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, + "matchPrioritizedReading": 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 prioritized 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, + "matchPrioritizedReading": 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, + "matchPrioritizedReading": 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..34748f2892 100644 --- a/test/utilities/translator.js +++ b/test/utilities/translator.js @@ -124,6 +124,7 @@ export function createFindTermsOptions(dictionaryName, optionsPresets, optionsAr sortFrequencyDictionary, sortFrequencyDictionaryOrder, removeNonJapaneseCharacters, + prioritizedReading, 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, + prioritizedReading: typeof prioritizedReading !== 'undefined' ? prioritizedReading : undefined, textReplacements, enabledDictionaryMap, excludeDictionaryDefinitions: Array.isArray(excludeDictionaryDefinitions) ? new Set(excludeDictionaryDefinitions) : null, diff --git a/types/test/translator.d.ts b/types/test/translator.d.ts index efd5cc3fcf..550eb85bd2 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; + prioritizedReading?: string; textReplacements?: (FindTermsTextReplacement[] | null)[]; enabledDictionaryMap?: [key: string, value: FindTermDictionary][]; excludeDictionaryDefinitions?: string[] | null;