diff --git a/lib/bgcalc/keywords/__init__.py b/lib/bgcalc/keywords/__init__.py index 30d7869b17..9ce08a9cda 100644 --- a/lib/bgcalc/keywords/__init__.py +++ b/lib/bgcalc/keywords/__init__.py @@ -138,6 +138,11 @@ async def keywords(corp: KCorpus, ref_corp: KCorpus, args: KeywordsFormArgs, max attrfreq=attrfreq) words = [x[0] for x in wl_items] + # in case no words are found return empty result + # (empty whitelist in keywords would return all words from focus corpus) + if len(words) == 0: + return [] + simple_n = 1.0 # this does not apply for CNC-custom manatee-open keywords keyword = Keyword( corp.unwrap(), ref_corp.unwrap(), c_wl, rc_wl, @@ -153,13 +158,13 @@ async def keywords(corp: KCorpus, ref_corp: KCorpus, args: KeywordsFormArgs, max s = s[:-2] if manatee_is_custom_cnc(): - freqs = kw.get_freqs(2 * len([]) + 4 + 4) # 1 additional slot for size effect + freqs = kw.get_freqs(2 * len([]) + 4 + 4) # 4 additional score slots results.append(CNCKeywordLine( item=s, - score=filter_nan(freqs[4], 3), - logL=filter_nan(freqs[5], 3), - chi2=filter_nan(freqs[6], 3), - din=filter_nan(float(freqs[7]), 5), + score=filter_nan(freqs[4], 3), # manatee score + logL=filter_nan(freqs[5], 3), # additional logL score + chi2=filter_nan(freqs[6], 3), # additional chi2 score + din=filter_nan(float(freqs[7]), 5), # additional din score frq1=int(freqs[0]), frq2=int(freqs[1]), rel_frq1=filter_nan(float(freqs[2]), 5), @@ -170,7 +175,7 @@ async def keywords(corp: KCorpus, ref_corp: KCorpus, args: KeywordsFormArgs, max freqs = kw.get_freqs(2 * len([]) + 4) results.append(KeywordLine( item=s, - score=filter_nan(kw.score, 3), + score=filter_nan(kw.score, 3), # manatee score frq1=int(freqs[0]), frq2=int(freqs[1]), rel_frq1=filter_nan(float(freqs[2]), 5), diff --git a/public/files/js/translations/messages.cs.json b/public/files/js/translations/messages.cs.json index 09b49f2ed3..176dd5c785 100644 --- a/public/files/js/translations/messages.cs.json +++ b/public/files/js/translations/messages.cs.json @@ -962,6 +962,7 @@ "kwords__save_form_label": "Uložit klíčová slova", "kwords__undefined_value": "N/A", "kwords__undefined_value_explained": "Z důvodu nulové frekvence v referenčním korpusu nelze aplikovat příslušný výpočet", - "kwords__max_list_size_explained_{limit}": "Seznam je omezen na maximálně {limit, plural, one{# položku} few{# položky} other{# položek}}" + "kwords__max_list_size_explained_{limit}": "Seznam je omezen na maximálně {limit, plural, one{# položku} few{# položky} other{# položek}}", + "kwords__no_result": "Žádný odpovídající výsledek" } } \ No newline at end of file diff --git a/public/files/js/translations/messages.en.json b/public/files/js/translations/messages.en.json index cc970ad40f..9031bb68d8 100644 --- a/public/files/js/translations/messages.en.json +++ b/public/files/js/translations/messages.en.json @@ -962,6 +962,7 @@ "kwords__save_form_label": "Save keywords", "kwords__undefined_value": "N/A", "kwords__undefined_value_explained": "Due to the zero frequency in the reference corpus, the corresponding calculation cannot be applied", - "kwords__max_list_size_explained_{limit}": "The result list is limited to at most {limit, plural, one{# item} few{# items} other{# items}}" + "kwords__max_list_size_explained_{limit}": "The result list is limited to at most {limit, plural, one{# item} few{# items} other{# items}}", + "kwords__no_result": "No matching result" } } diff --git a/public/files/js/translations/messages.sl.json b/public/files/js/translations/messages.sl.json index e996e7c905..f6d01d987d 100644 --- a/public/files/js/translations/messages.sl.json +++ b/public/files/js/translations/messages.sl.json @@ -961,6 +961,7 @@ "kwords__save_form_label": "Save keywords UNTRANSLATED", "kwords__undefined_value": "N/A", "kwords__undefined_value_explained": "Due to the zero frequency in the reference corpus, the corresponding calculation cannot be applied UNTRANSLATED", - "kwords__max_list_size_explained_{limit}": "The result list is limited to at most {limit, plural, one{# item} few{# items} other{# items}} UNTRANSLATED" + "kwords__max_list_size_explained_{limit}": "The result list is limited to at most {limit, plural, one{# item} few{# items} other{# items}} UNTRANSLATED", + "kwords__no_result": "Ni rezultatov" } } diff --git a/public/files/js/translations/messages.szl.json b/public/files/js/translations/messages.szl.json index f13de2e85e..0e0ff44722 100644 --- a/public/files/js/translations/messages.szl.json +++ b/public/files/js/translations/messages.szl.json @@ -901,9 +901,9 @@ "wordlist__minfreq_err": "Musi być użyty numer srogszy ôd zera", "wordlist__ml_not_avail": "Niydostympne", "wordlist__add_attr": "Przidej atrybut", - "wordlist__no_result_for_{wlpat}": "No matching result for \"{wlpat}\"", - "wordlist__create_filter_list": "Create", - "wordlist__use_ctrl_enter_for_newline": "To enter a new line, use Ctrl+ENTER", + "wordlist__no_result_for_{wlpat}": "No matching result for \"{wlpat}\" UNTRANSLATED", + "wordlist__create_filter_list": "Create UNTRANSLATED", + "wordlist__use_ctrl_enter_for_newline": "To enter a new line, use Ctrl+ENTER UNTRANSLATED", "wordlist__pattern_empty_err": "Search pattern and/or filter words must be entered UNTRANSLATED", "wordlist__ask_empty_pattern": "An empty query will return all the words from the corpus. Continue? UNTRANSLATED", "wordlist__failed_to_precalculate": "Failed to create auxiliary data required for the frequency distribution calculation. Please try again later or contact system administrator. UNTRANSLATED", @@ -960,6 +960,7 @@ "kwords__save_form_label": "Save keywords UNTRANSLATED", "kwords__undefined_value": "N/A", "kwords__undefined_value_explained": "Due to the zero frequency in the reference corpus, the corresponding calculation cannot be applied UNTRANSLATED", - "kwords__max_list_size_explained_{limit}": "The result list is limited to at most {limit, plural, one{# item} few{# items} other{# items}} UNTRANSLATED" + "kwords__max_list_size_explained_{limit}": "The result list is limited to at most {limit, plural, one{# item} few{# items} other{# items}} UNTRANSLATED", + "kwords__no_result": "No matching result" } } diff --git a/public/files/js/views/keywords/result/index.tsx b/public/files/js/views/keywords/result/index.tsx index bd9cc8385e..863b54947d 100644 --- a/public/files/js/views/keywords/result/index.tsx +++ b/public/files/js/views/keywords/result/index.tsx @@ -106,6 +106,11 @@ export function init({ const buildQ = (value:string) => `aword,[${props.attr}="${value}"]`; + if (props.data.length === 0) { + return +

{he.translate('kwords__no_result')}

+
+ } return ( diff --git a/public/files/js/views/keywords/result/style.tsx b/public/files/js/views/keywords/result/style.tsx index e9bd44bdd1..420139a006 100644 --- a/public/files/js/views/keywords/result/style.tsx +++ b/public/files/js/views/keywords/result/style.tsx @@ -59,6 +59,13 @@ export const KeywordsResult = styled.form` .data { margin: 1em; } + + .no-result { + margin: 1em; + padding-top: 2em; + padding-bottom: 2em; + font-size: 120%; + } `; // ------------------- -------------