From 7a4b832ccfeb7f13857340cc93b30214d6b53106 Mon Sep 17 00:00:00 2001 From: StefanVukovic99 Date: Tue, 14 May 2024 21:31:26 +0200 Subject: add test case for search resolution "word" (#939) * fix search resolution infinite loop * add search resolution word test case --- test/data/anki-note-builder-test-results.json | 46 +++++++++ test/data/translator-test-inputs.json | 15 +++ test/data/translator-test-results-note-data1.json | 114 ++++++++++++++++++++++ test/data/translator-test-results.json | 81 +++++++++++++++ 4 files changed, 256 insertions(+) diff --git a/test/data/anki-note-builder-test-results.json b/test/data/anki-note-builder-test-results.json index 0e51b4aa..49e0d8fe 100644 --- a/test/data/anki-note-builder-test-results.json +++ b/test/data/anki-note-builder-test-results.json @@ -4361,5 +4361,51 @@ "url": "url:" } ] + }, + { + "name": "Test search resolution - word", + "results": [ + { + "audio": "", + "clipboard-image": "", + "clipboard-text": "", + "cloze-body": "english", + "cloze-body-kana": "english", + "cloze-prefix": "cloze-prefix", + "cloze-suffix": "cloze-suffix", + "conjugation": "", + "dictionary": "Test Dictionary 2", + "document-title": "title", + "expression": "English", + "frequencies": "", + "frequency-harmonic-rank": "9999999", + "frequency-harmonic-occurrence": "0", + "frequency-average-rank": "9999999", + "frequency-average-occurrence": "0", + "furigana": "English", + "furigana-plain": "English", + "glossary": "
(n, Test Dictionary 2) English definition
", + "glossary-brief": "
English definition
", + "glossary-no-dictionary": "
(n) English definition
", + "glossary-first": "
(n, Test Dictionary 2) English definition
", + "glossary-first-brief": "
English definition
", + "glossary-first-no-dictionary": "
(n) English definition
", + "part-of-speech": "Noun", + "pitch-accents": "No pitch accent data", + "pitch-accent-graphs": "No pitch accent data", + "pitch-accent-graphs-jj": "No pitch accent data", + "pitch-accent-positions": "No pitch accent data", + "pitch-accent-categories": "", + "phonetic-transcriptions": "", + "reading": "English", + "screenshot": "", + "search-query": "fullQuery", + "selection-text": "", + "sentence": "cloze-prefixenglishcloze-suffix", + "sentence-furigana": "cloze-prefixenglishcloze-suffix", + "tags": "n", + "url": "url:" + } + ] } ] diff --git a/test/data/translator-test-inputs.json b/test/data/translator-test-inputs.json index b7a84d7e..9f508a1d 100644 --- a/test/data/translator-test-inputs.json +++ b/test/data/translator-test-inputs.json @@ -470,6 +470,21 @@ "removeNonJapaneseCharacters": false } ] + }, + { + "name": "Test search resolution - word", + "func": "findTerms", + "mode": "split", + "text": "english example", + "options": [ + "default", + { + "type": "terms", + "language": "en", + "removeNonJapaneseCharacters": false, + "searchResolution": "word" + } + ] } ] } diff --git a/test/data/translator-test-results-note-data1.json b/test/data/translator-test-results-note-data1.json index eeb348af..0782c8f5 100644 --- a/test/data/translator-test-results-note-data1.json +++ b/test/data/translator-test-results-note-data1.json @@ -33056,5 +33056,119 @@ "media": {} } ] + }, + { + "name": "Test search resolution - word", + "noteDataList": [ + { + "marker": "{marker}", + "definition": { + "type": "term", + "id": 27, + "source": "English", + "rawSource": "english", + "sourceTerm": "English", + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 1, + "isPrimary": true, + "sequence": 19, + "dictionary": "Test Dictionary 2", + "dictionaryOrder": { + "index": 0, + "priority": 0 + }, + "dictionaryNames": [ + "Test Dictionary 2" + ], + "expression": "English", + "reading": "English", + "expressions": [ + { + "sourceTerm": "English", + "expression": "English", + "reading": "English", + "termTags": [], + "frequencies": [], + "pitches": [], + "furiganaSegments": [ + { + "text": "English", + "furigana": "" + } + ], + "termFrequency": "normal", + "wordClasses": [ + "n" + ] + } + ], + "glossary": [ + "English definition" + ], + "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": "English", + "furigana": "" + } + ] + }, + "glossaryLayoutMode": "default", + "compactTags": false, + "group": false, + "merge": false, + "modeTermKanji": false, + "modeTermKana": false, + "modeKanji": false, + "compactGlossaries": false, + "uniqueExpressions": [ + "English" + ], + "uniqueReadings": [ + "English" + ], + "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 af5ceff7..bc26e0f9 100644 --- a/test/data/translator-test-results.json +++ b/test/data/translator-test-results.json @@ -18685,5 +18685,86 @@ "frequencies": [] } ] + }, + { + "name": "Test search resolution - word", + "originalTextLength": 7, + "dictionaryEntries": [ + { + "type": "term", + "isPrimary": true, + "inflectionRuleChainCandidates": [ + { + "source": "algorithm", + "inflectionRules": [] + } + ], + "score": 1, + "frequencyOrder": 0, + "dictionaryIndex": 0, + "dictionaryPriority": 0, + "sourceTermExactMatchCount": 1, + "maxOriginalTextLength": 7, + "headwords": [ + { + "index": 0, + "term": "English", + "reading": "English", + "sources": [ + { + "originalText": "english", + "transformedText": "English", + "deinflectedText": "English", + "matchType": "exact", + "matchSource": "term", + "isPrimary": true + } + ], + "tags": [], + "wordClasses": [ + "n" + ] + } + ], + "definitions": [ + { + "index": 0, + "headwordIndices": [ + 0 + ], + "dictionary": "Test Dictionary 2", + "dictionaryIndex": 0, + "dictionaryPriority": 0, + "id": 27, + "score": 1, + "frequencyOrder": 0, + "sequences": [ + 19 + ], + "isPrimary": true, + "tags": [ + { + "name": "n", + "category": "partOfSpeech", + "order": 0, + "score": 0, + "content": [ + "noun" + ], + "dictionaries": [ + "Test Dictionary 2" + ], + "redundant": false + } + ], + "entries": [ + "English definition" + ] + } + ], + "pronunciations": [], + "frequencies": [] + } + ] } ] -- cgit v1.2.3