summaryrefslogtreecommitdiff
path: root/ext/bg/js/search-query-parser.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2020-04-16 17:30:09 -0700
committerAlex Yatskov <alex@foosoft.net>2020-04-16 17:30:09 -0700
commit93c4fb9eab2651da24fb816f20dcb967eae1437e (patch)
treedf8f6d5e04da7e6e78db4712d4d3d92c460454b9 /ext/bg/js/search-query-parser.js
parent3b9a87b2ebe843e30536924639d6c14afef936cd (diff)
parent8c16a6e580bfdd70e27df1816ca90807062cf9b5 (diff)
Merge branch 'master' of https://github.com/FooSoft/yomichan
Diffstat (limited to 'ext/bg/js/search-query-parser.js')
-rw-r--r--ext/bg/js/search-query-parser.js31
1 files changed, 4 insertions, 27 deletions
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index 01a0ace5..eb3b681c 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -21,13 +21,12 @@
* apiOptionsSet
* apiTermsFind
* apiTextParse
- * apiTextParseMecab
* docSentenceExtract
*/
class QueryParser extends TextScanner {
constructor({getOptionsContext, setContent, setSpinnerVisible}) {
- super(document.querySelector('#query-parser-content'), [], []);
+ super(document.querySelector('#query-parser-content'), () => [], []);
this.getOptionsContext = getOptionsContext;
this.setContent = setContent;
@@ -128,7 +127,7 @@ class QueryParser extends TextScanner {
this.setPreview(text);
- this.parseResults = await this.parseText(text);
+ this.parseResults = await apiTextParse(text, this.getOptionsContext());
this.refreshSelectedParser();
this.renderParserSelect();
@@ -137,33 +136,11 @@ class QueryParser extends TextScanner {
this.setSpinnerVisible(false);
}
- async parseText(text) {
- const results = [];
- if (this.options.parsing.enableScanningParser) {
- results.push({
- name: 'Scanning parser',
- id: 'scan',
- parsedText: await apiTextParse(text, this.getOptionsContext())
- });
- }
- if (this.options.parsing.enableMecabParser) {
- const mecabResults = await apiTextParseMecab(text, this.getOptionsContext());
- for (const [mecabDictName, mecabDictResults] of mecabResults) {
- results.push({
- name: `MeCab: ${mecabDictName}`,
- id: `mecab-${mecabDictName}`,
- parsedText: mecabDictResults
- });
- }
- }
- return results;
- }
-
setPreview(text) {
const previewTerms = [];
for (let i = 0, ii = text.length; i < ii; i += 2) {
const tempText = text.substring(i, i + 2);
- previewTerms.push([{text: tempText}]);
+ previewTerms.push([{text: tempText, reading: ''}]);
}
this.queryParser.textContent = '';
this.queryParser.appendChild(this.queryParserGenerator.createParseResult(previewTerms, true));
@@ -183,6 +160,6 @@ class QueryParser extends TextScanner {
const parseResult = this.getParseResult();
this.queryParser.textContent = '';
if (!parseResult) { return; }
- this.queryParser.appendChild(this.queryParserGenerator.createParseResult(parseResult.parsedText));
+ this.queryParser.appendChild(this.queryParserGenerator.createParseResult(parseResult.content));
}
}