Skip to content

Commit

Permalink
add test case for search resolution "word" (#939)
Browse files Browse the repository at this point in the history
* fix search resolution infinite loop

* add search resolution word test case
  • Loading branch information
StefanVukovic99 authored May 14, 2024
1 parent 6c218cc commit 7a4b832
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/data/anki-note-builder-test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -4361,5 +4361,51 @@
"url": "<a href=\"url:\">url:</a>"
}
]
},
{
"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": "<div style=\"text-align: left;\"><i>(n, Test Dictionary 2)</i> English definition</div>",
"glossary-brief": "<div style=\"text-align: left;\">English definition</div>",
"glossary-no-dictionary": "<div style=\"text-align: left;\"><i>(n)</i> English definition</div>",
"glossary-first": "<div style=\"text-align: left;\"><i>(n, Test Dictionary 2)</i> English definition</div>",
"glossary-first-brief": "<div style=\"text-align: left;\">English definition</div>",
"glossary-first-no-dictionary": "<div style=\"text-align: left;\"><i>(n)</i> English definition</div>",
"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": "<a href=\"url:\">url:</a>"
}
]
}
]
15 changes: 15 additions & 0 deletions test/data/translator-test-inputs.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
}
]
}
114 changes: 114 additions & 0 deletions test/data/translator-test-results-note-data1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {}
}
]
}
]
81 changes: 81 additions & 0 deletions test/data/translator-test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": []
}
]
}
]

0 comments on commit 7a4b832

Please sign in to comment.