summaryrefslogtreecommitdiff
path: root/ext/bg/js/search-query-parser.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2020-04-17 01:32:01 +0300
committerGitHub <noreply@github.com>2020-04-17 01:32:01 +0300
commit8c16a6e580bfdd70e27df1816ca90807062cf9b5 (patch)
tree25f551dfaa68427cd873fbd822abf0f2bfe09b76 /ext/bg/js/search-query-parser.js
parente6053eefa594524c7adcec4986a5a2c499adf192 (diff)
parent619df42aedaa8da97d0a16d539b7211349143a0a (diff)
Merge pull request #456 from siikamiika/parse-text-refactor
Parse text refactor
Diffstat (limited to 'ext/bg/js/search-query-parser.js')
-rw-r--r--ext/bg/js/search-query-parser.js29
1 files changed, 3 insertions, 26 deletions
diff --git a/ext/bg/js/search-query-parser.js b/ext/bg/js/search-query-parser.js
index f90c68ee..eb3b681c 100644
--- a/ext/bg/js/search-query-parser.js
+++ b/ext/bg/js/search-query-parser.js
@@ -21,7 +21,6 @@
* apiOptionsSet
* apiTermsFind
* apiTextParse
- * apiTextParseMecab
* docSentenceExtract
*/
@@ -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));
}
}