Skip to content

Commit 7a4b832

Browse files
add test case for search resolution "word" (#939)
* fix search resolution infinite loop * add search resolution word test case
1 parent 6c218cc commit 7a4b832

File tree

4 files changed

+256
-0
lines changed

4 files changed

+256
-0
lines changed

test/data/anki-note-builder-test-results.json

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4361,5 +4361,51 @@
43614361
"url": "<a href=\"url:\">url:</a>"
43624362
}
43634363
]
4364+
},
4365+
{
4366+
"name": "Test search resolution - word",
4367+
"results": [
4368+
{
4369+
"audio": "",
4370+
"clipboard-image": "",
4371+
"clipboard-text": "",
4372+
"cloze-body": "english",
4373+
"cloze-body-kana": "english",
4374+
"cloze-prefix": "cloze-prefix",
4375+
"cloze-suffix": "cloze-suffix",
4376+
"conjugation": "",
4377+
"dictionary": "Test Dictionary 2",
4378+
"document-title": "title",
4379+
"expression": "English",
4380+
"frequencies": "",
4381+
"frequency-harmonic-rank": "9999999",
4382+
"frequency-harmonic-occurrence": "0",
4383+
"frequency-average-rank": "9999999",
4384+
"frequency-average-occurrence": "0",
4385+
"furigana": "English",
4386+
"furigana-plain": "English",
4387+
"glossary": "<div style=\"text-align: left;\"><i>(n, Test Dictionary 2)</i> English definition</div>",
4388+
"glossary-brief": "<div style=\"text-align: left;\">English definition</div>",
4389+
"glossary-no-dictionary": "<div style=\"text-align: left;\"><i>(n)</i> English definition</div>",
4390+
"glossary-first": "<div style=\"text-align: left;\"><i>(n, Test Dictionary 2)</i> English definition</div>",
4391+
"glossary-first-brief": "<div style=\"text-align: left;\">English definition</div>",
4392+
"glossary-first-no-dictionary": "<div style=\"text-align: left;\"><i>(n)</i> English definition</div>",
4393+
"part-of-speech": "Noun",
4394+
"pitch-accents": "No pitch accent data",
4395+
"pitch-accent-graphs": "No pitch accent data",
4396+
"pitch-accent-graphs-jj": "No pitch accent data",
4397+
"pitch-accent-positions": "No pitch accent data",
4398+
"pitch-accent-categories": "",
4399+
"phonetic-transcriptions": "",
4400+
"reading": "English",
4401+
"screenshot": "",
4402+
"search-query": "fullQuery",
4403+
"selection-text": "",
4404+
"sentence": "cloze-prefixenglishcloze-suffix",
4405+
"sentence-furigana": "cloze-prefixenglishcloze-suffix",
4406+
"tags": "n",
4407+
"url": "<a href=\"url:\">url:</a>"
4408+
}
4409+
]
43644410
}
43654411
]

test/data/translator-test-inputs.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,21 @@
470470
"removeNonJapaneseCharacters": false
471471
}
472472
]
473+
},
474+
{
475+
"name": "Test search resolution - word",
476+
"func": "findTerms",
477+
"mode": "split",
478+
"text": "english example",
479+
"options": [
480+
"default",
481+
{
482+
"type": "terms",
483+
"language": "en",
484+
"removeNonJapaneseCharacters": false,
485+
"searchResolution": "word"
486+
}
487+
]
473488
}
474489
]
475490
}

test/data/translator-test-results-note-data1.json

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33056,5 +33056,119 @@
3305633056
"media": {}
3305733057
}
3305833058
]
33059+
},
33060+
{
33061+
"name": "Test search resolution - word",
33062+
"noteDataList": [
33063+
{
33064+
"marker": "{marker}",
33065+
"definition": {
33066+
"type": "term",
33067+
"id": 27,
33068+
"source": "English",
33069+
"rawSource": "english",
33070+
"sourceTerm": "English",
33071+
"inflectionRuleChainCandidates": [
33072+
{
33073+
"source": "algorithm",
33074+
"inflectionRules": []
33075+
}
33076+
],
33077+
"score": 1,
33078+
"isPrimary": true,
33079+
"sequence": 19,
33080+
"dictionary": "Test Dictionary 2",
33081+
"dictionaryOrder": {
33082+
"index": 0,
33083+
"priority": 0
33084+
},
33085+
"dictionaryNames": [
33086+
"Test Dictionary 2"
33087+
],
33088+
"expression": "English",
33089+
"reading": "English",
33090+
"expressions": [
33091+
{
33092+
"sourceTerm": "English",
33093+
"expression": "English",
33094+
"reading": "English",
33095+
"termTags": [],
33096+
"frequencies": [],
33097+
"pitches": [],
33098+
"furiganaSegments": [
33099+
{
33100+
"text": "English",
33101+
"furigana": ""
33102+
}
33103+
],
33104+
"termFrequency": "normal",
33105+
"wordClasses": [
33106+
"n"
33107+
]
33108+
}
33109+
],
33110+
"glossary": [
33111+
"English definition"
33112+
],
33113+
"definitionTags": [
33114+
{
33115+
"name": "n",
33116+
"category": "partOfSpeech",
33117+
"notes": "noun",
33118+
"order": 0,
33119+
"score": 0,
33120+
"dictionary": "Test Dictionary 2",
33121+
"redundant": false
33122+
}
33123+
],
33124+
"termTags": [],
33125+
"frequencies": [],
33126+
"frequencyHarmonic": -1,
33127+
"frequencyAverage": -1,
33128+
"pitches": [],
33129+
"phoneticTranscriptions": [],
33130+
"sourceTermExactMatchCount": 1,
33131+
"url": "url:",
33132+
"cloze": {
33133+
"sentence": "",
33134+
"prefix": "",
33135+
"body": "",
33136+
"bodyKana": "",
33137+
"suffix": ""
33138+
},
33139+
"furiganaSegments": [
33140+
{
33141+
"text": "English",
33142+
"furigana": ""
33143+
}
33144+
]
33145+
},
33146+
"glossaryLayoutMode": "default",
33147+
"compactTags": false,
33148+
"group": false,
33149+
"merge": false,
33150+
"modeTermKanji": false,
33151+
"modeTermKana": false,
33152+
"modeKanji": false,
33153+
"compactGlossaries": false,
33154+
"uniqueExpressions": [
33155+
"English"
33156+
],
33157+
"uniqueReadings": [
33158+
"English"
33159+
],
33160+
"pitches": [],
33161+
"pitchCount": 0,
33162+
"phoneticTranscriptions": [],
33163+
"context": {
33164+
"query": "query",
33165+
"fullQuery": "fullQuery",
33166+
"document": {
33167+
"title": "title"
33168+
}
33169+
},
33170+
"media": {}
33171+
}
33172+
]
3305933173
}
3306033174
]

test/data/translator-test-results.json

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18685,5 +18685,86 @@
1868518685
"frequencies": []
1868618686
}
1868718687
]
18688+
},
18689+
{
18690+
"name": "Test search resolution - word",
18691+
"originalTextLength": 7,
18692+
"dictionaryEntries": [
18693+
{
18694+
"type": "term",
18695+
"isPrimary": true,
18696+
"inflectionRuleChainCandidates": [
18697+
{
18698+
"source": "algorithm",
18699+
"inflectionRules": []
18700+
}
18701+
],
18702+
"score": 1,
18703+
"frequencyOrder": 0,
18704+
"dictionaryIndex": 0,
18705+
"dictionaryPriority": 0,
18706+
"sourceTermExactMatchCount": 1,
18707+
"maxOriginalTextLength": 7,
18708+
"headwords": [
18709+
{
18710+
"index": 0,
18711+
"term": "English",
18712+
"reading": "English",
18713+
"sources": [
18714+
{
18715+
"originalText": "english",
18716+
"transformedText": "English",
18717+
"deinflectedText": "English",
18718+
"matchType": "exact",
18719+
"matchSource": "term",
18720+
"isPrimary": true
18721+
}
18722+
],
18723+
"tags": [],
18724+
"wordClasses": [
18725+
"n"
18726+
]
18727+
}
18728+
],
18729+
"definitions": [
18730+
{
18731+
"index": 0,
18732+
"headwordIndices": [
18733+
0
18734+
],
18735+
"dictionary": "Test Dictionary 2",
18736+
"dictionaryIndex": 0,
18737+
"dictionaryPriority": 0,
18738+
"id": 27,
18739+
"score": 1,
18740+
"frequencyOrder": 0,
18741+
"sequences": [
18742+
19
18743+
],
18744+
"isPrimary": true,
18745+
"tags": [
18746+
{
18747+
"name": "n",
18748+
"category": "partOfSpeech",
18749+
"order": 0,
18750+
"score": 0,
18751+
"content": [
18752+
"noun"
18753+
],
18754+
"dictionaries": [
18755+
"Test Dictionary 2"
18756+
],
18757+
"redundant": false
18758+
}
18759+
],
18760+
"entries": [
18761+
"English definition"
18762+
]
18763+
}
18764+
],
18765+
"pronunciations": [],
18766+
"frequencies": []
18767+
}
18768+
]
1868818769
}
1868918770
]

0 commit comments

Comments
 (0)