summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-09-29 05:41:29 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-09-29 05:41:29 +0300
commitb24c70523479c16eca848f5aafaa887549689ac6 (patch)
tree164cc016a3a9012c1d92469f9ee06a869d72fbea
parent9106b59af628df26f86474fc77abb88c7d9bf9c5 (diff)
basic structure for feature-merge-similar-results
-rw-r--r--ext/bg/js/api.js6
-rw-r--r--ext/bg/js/database.js3
-rw-r--r--ext/bg/js/dictionary.js3
-rw-r--r--ext/bg/js/options.js2
-rw-r--r--ext/bg/js/settings.js4
-rw-r--r--ext/bg/js/translator.js15
-rw-r--r--ext/bg/settings.html13
-rw-r--r--ext/mixed/js/display.js3
8 files changed, 35 insertions, 14 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js
index 9f65bb07..01322357 100644
--- a/ext/bg/js/api.js
+++ b/ext/bg/js/api.js
@@ -29,9 +29,9 @@ async function apiTermsFind(text) {
const options = utilBackend().options;
const translator = utilBackend().translator;
- const searcher = options.general.groupResults ?
- translator.findTermsGrouped.bind(translator) :
- translator.findTermsSplit.bind(translator);
+ const searcher = (options.general.resultOutputMode === 'merge') && translator.findTermsMerged.bind(translator)
+ || (options.general.resultOutputMode === 'split') && translator.findTermsSplit.bind(translator)
+ || (options.general.resultOutputMode === 'group') && translator.findTermsGrouped.bind(translator);
const {definitions, length} = await searcher(
text,
diff --git a/ext/bg/js/database.js b/ext/bg/js/database.js
index 6ceb3ec8..29ab6d4e 100644
--- a/ext/bg/js/database.js
+++ b/ext/bg/js/database.js
@@ -208,7 +208,7 @@ class Database {
});
}
} else {
- for (const [expression, reading, tags, rules, score, glossary] of entries) {
+ for (const [expression, reading, tags, rules, score, glossary, sequence] of entries) {
rows.push({
expression,
reading,
@@ -216,6 +216,7 @@ class Database {
rules,
score,
glossary,
+ sequence,
dictionary: summary.title
});
}
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index 57acbe5e..f3f573d3 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -207,7 +207,8 @@ async function dictFieldFormat(field, definition, mode, options) {
const data = {
marker,
definition,
- group: options.general.groupResults,
+ group: options.general.resultOutputMode === 'group',
+ merge: options.general.resultOutputMode === 'merge',
modeTermKanji: mode === 'term-kanji',
modeTermKana: mode === 'term-kana',
modeKanji: mode === 'kanji'
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 36ab7694..de3da943 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -132,7 +132,7 @@ function optionsSetDefaults(options) {
enable: true,
audioSource: 'jpod101',
audioVolume: 100,
- groupResults: true,
+ resultOutputMode: 'group',
debugInfo: false,
maxResults: 32,
showAdvanced: false,
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index a2f22371..c5a28a45 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -22,9 +22,9 @@ async function formRead() {
const optionsNew = $.extend(true, {}, optionsOld);
optionsNew.general.showGuide = $('#show-usage-guide').prop('checked');
+ optionsNew.general.resultOutputMode = $('#result-output-mode').val();
optionsNew.general.audioSource = $('#audio-playback-source').val();
optionsNew.general.audioVolume = parseFloat($('#audio-playback-volume').val());
- optionsNew.general.groupResults = $('#group-terms-results').prop('checked');
optionsNew.general.debugInfo = $('#show-debug-info').prop('checked');
optionsNew.general.showAdvanced = $('#show-advanced-options').prop('checked');
optionsNew.general.maxResults = parseInt($('#max-displayed-results').val(), 10);
@@ -124,9 +124,9 @@ async function onReady() {
const options = await optionsLoad();
$('#show-usage-guide').prop('checked', options.general.showGuide);
+ $('#result-output-mode').val(options.general.resultOutputMode);
$('#audio-playback-source').val(options.general.audioSource);
$('#audio-playback-volume').val(options.general.audioVolume);
- $('#group-terms-results').prop('checked', options.general.groupResults);
$('#show-debug-info').prop('checked', options.general.debugInfo);
$('#show-advanced-options').prop('checked', options.general.showAdvanced);
$('#max-displayed-results').val(options.general.maxResults);
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js
index c915dbc0..8fa2b60b 100644
--- a/ext/bg/js/translator.js
+++ b/ext/bg/js/translator.js
@@ -48,6 +48,18 @@ class Translator {
return {length, definitions: definitionsGrouped};
}
+ async findTermsMerged(text, dictionaries, alphanumeric) {
+ const titles = Object.keys(dictionaries);
+ const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric);
+
+ const definitionsMerged = dictTermsGroup(definitions, dictionaries);
+ // for (const definition of definitionsMerged) {
+ // await this.buildTermFrequencies(definition, titles);
+ // }
+
+ return {length, definitions: definitionsMerged};
+ }
+
async findTermsSplit(text, dictionaries, alphanumeric) {
const titles = Object.keys(dictionaries);
const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric);
@@ -90,7 +102,8 @@ class Translator {
expression: definition.expression,
reading: definition.reading,
glossary: definition.glossary,
- tags: dictTagsSort(tags)
+ tags: dictTagsSort(tags),
+ sequence: definition.sequence
});
}
}
diff --git a/ext/bg/settings.html b/ext/bg/settings.html
index 4315d74b..6274f3cb 100644
--- a/ext/bg/settings.html
+++ b/ext/bg/settings.html
@@ -36,10 +36,6 @@
</div>
<div class="checkbox">
- <label><input type="checkbox" id="group-terms-results"> Group term results</label>
- </div>
-
- <div class="checkbox">
<label><input type="checkbox" id="show-advanced-options"> Show advanced options</label>
</div>
@@ -48,6 +44,15 @@
</div>
<div class="form-group">
+ <label for="result-output-mode">Result output mode</label>
+ <select class="form-control" id="result-output-mode">
+ <option value="group">Group results by written form and reading</option>
+ <option value="merge">Group results by main dictionary entry ID (experimental)</option>
+ <option value="split">Split definitions to their own results</option>
+ </select>
+ </div>
+
+ <div class="form-group">
<label for="audio-playback-source">Audio playback source</label>
<select class="form-control" id="audio-playback-source">
<option value="disabled">Disabled</option>
diff --git a/ext/mixed/js/display.js b/ext/mixed/js/display.js
index 302a6280..2dd95692 100644
--- a/ext/mixed/js/display.js
+++ b/ext/mixed/js/display.js
@@ -234,7 +234,8 @@ class Display {
const params = {
definitions,
addable: options.anki.enable,
- grouped: options.general.groupResults,
+ grouped: options.general.resultOutputMode === 'group',
+ merged: options.general.resultOutputMode === 'merge',
playback: options.general.audioSource !== 'disabled',
debug: options.general.debugInfo
};