Fixed search for languages without stemmers

This commit is contained in:
squidfunk 2018-02-01 23:47:00 +01:00 committed by Martin Donath
parent 9b717440cc
commit c002cc2881
42 changed files with 39 additions and 44 deletions

View File

@ -375,7 +375,7 @@ Pull Request.
#### Text direction
> Default: `ltr`
> Default: best match for given theme language, automatically set
Material supports both, left-to-right (`ltr`) and right-to-left (`rtl`) text
direction. This enables more languages like Arabic, Hebrew, Syriac and others

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,8 @@
"clipboard.copy",
"clipboard.copied",
"search.language",
"search.pipeline.stopwords",
"search.pipeline.trimmer",
"search.result.none",
"search.result.one",
"search.result.other",
@ -166,7 +168,7 @@
{% endblock %}
</div>
{% block scripts %}
<script src="{{ base_url }}/assets/javascripts/application.cb27f861.js"></script>
<script src="{{ base_url }}/assets/javascripts/application.ababfdab.js"></script>
{% if lang.t("search.language") != "en" %}
{% set languages = lang.t("search.language").split(",") %}
{% if languages | length and languages[0] != "" %}

View File

@ -22,7 +22,7 @@
language: en
# Text direction (can be ltr or rtl)
direction: ltr
direction:
# Feature flags for functionality that alters behavior significantly, and thus
# may be a matter of taste

View File

@ -13,7 +13,6 @@
"search.result.none": "Ingen resultater fundet",
"search.result.one": "1 resultat",
"search.result.other": "# resultater",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Gå til indholdet",
"source.link.title": "Åbn arkiv",
"toc.title": "Indholdsfortegnelse"

View File

@ -13,7 +13,6 @@
"search.result.none": "Keine Suchergebnisse",
"search.result.one": "1 Suchergebnis",
"search.result.other": "# Suchergebnisse",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Zum Inhalt",
"source.link.title": "Quellcode",
"toc.title": "Inhaltsverzeichnis"

View File

@ -1,5 +1,6 @@
{% macro t(key) %}{{ {
"language": "en",
"direction": "ltr",
"clipboard.copy": "Copy to clipboard",
"clipboard.copied": "Copied to clipboard",
"edit.link.title": "Edit this page",
@ -8,6 +9,8 @@
"meta.comments": "Comments",
"meta.source": "Source",
"search.language": "en",
"search.pipeline.stopwords": true,
"search.pipeline.trimmer": true,
"search.placeholder": "Search",
"search.result.placeholder": "Type to start searching",
"search.result.none": "No matching documents",

View File

@ -13,7 +13,6 @@
"search.result.none": "No se encontraron documentos",
"search.result.one": "1 documento encontrado",
"search.result.other": "# documentos encontrados",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Saltar a contenido",
"source.link.title": "Ir al repositorio",
"toc.title": "Tabla de contenidos"

View File

@ -8,13 +8,14 @@
"footer.next": "بعدی",
"meta.comments": "نظرات",
"meta.source": "منبع",
"search.language": "en",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "جستجو",
"search.result.placeholder": "برای شروع جستجو تایپ کنید",
"search.result.none": "سندی یافت نشد",
"search.result.one": "1 سند یافت شد",
"search.result.other": "# سند یافت شد",
"search.tokenizer": "[\s]+",
"skip.link.title": "پرش به محتویات",
"source.link.title": "رفتن به مخزن",
"toc.title": "فهرست موضوعات"

View File

@ -13,7 +13,6 @@
"search.result.none": "Aucun document trouvé",
"search.result.one": "1 document trouvé",
"search.result.other": "# documents trouvés",
"search.tokenizer": "[\s\-]+",
"source.link.title": "Aller au dépôt",
"toc.title": "Table des matières"
}[key] }}{% endmacro %}

View File

@ -13,7 +13,6 @@
"search.result.none": "Nincs találat",
"search.result.one": "1 egyező dokumentum",
"search.result.other": "# egyező dokumentum",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Kihagyás",
"source.link.title": "Főoldalra ugrás",
"toc.title": "Tartalomjegyzék"

View File

@ -13,7 +13,6 @@
"search.result.none": "Nessun documento trovato",
"search.result.one": "1 documento trovato",
"search.result.other": "# documenti trovati",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Vai al contenuto",
"source.link.title": "Apri repository",
"toc.title": "Indice"

View File

@ -13,7 +13,6 @@
"search.result.none": "검색어와 일치하는 문서가 없습니다",
"search.result.one": "1개의 일치하는 문서",
"search.result.other": "#개의 일치하는 문서",
"search.tokenizer": "[\s\-]+",
"source.link.title": "저장소로 이동",
"toc.title": "목차"
}[key] }}{% endmacro %}

View File

@ -13,7 +13,6 @@
"search.result.none": "Geen overeenkomende documenten",
"search.result.one": "1 overeenkomende document",
"search.result.other": "# overeenkomende documenten",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Ga naar inhoud",
"source.link.title": "Ga naar repository",
"toc.title": "Inhoudstafel"

View File

@ -13,7 +13,6 @@
"search.result.none": "Ingen treff",
"search.result.one": "1 treff",
"search.result.other": "# treff",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Gå til innhold",
"source.link.title": "Gå til kilde",
"toc.title": "Innholdsfortegnelse"

View File

@ -7,12 +7,14 @@
"footer.next": "Następna strona",
"meta.comments": "Komentarze",
"meta.source": "Kod źródłowy",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "Szukaj",
"search.result.placeholder": "Zacznij pisać, aby szukać",
"search.result.none": "Brak wyników wyszukiwania",
"search.result.one": "Wyniki wyszukiwania: 1",
"search.result.other": "Wyniki wyszukiwania: #",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Przejdź do treści",
"source.link.title": "Idź do repozytorium",
"toc.title": "Spis treści"

View File

@ -13,7 +13,6 @@
"search.result.none": "Nenhum resultado encontrado",
"search.result.one": "1 resultado encontrado",
"search.result.other": "# resultados encontrados",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Ir para o conteúdo",
"source.link.title": "Ir ao repositório",
"toc.title": "Índice"

View File

@ -13,7 +13,6 @@
"search.result.none": "Совпадений не найдено",
"search.result.one": "Найдено 1 совпадение",
"search.result.other": "Найдено # совпадений",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Перейти к содержанию",
"source.link.title": "Перейти к репозиторию",
"toc.title": "Содержание"

View File

@ -13,7 +13,6 @@
"search.result.none": "Inga sökresultat",
"search.result.one": "1 sökresultat",
"search.result.other": "# sökresultat",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Gå till innehållet",
"source.link.title": "Gå till datakatalog",
"toc.title": "Innehållsförteckning"

View File

@ -13,7 +13,6 @@
"search.result.none": "Eşleşen doküman bulunamadı",
"search.result.one": "1 doküman bulundu",
"search.result.other": "# doküman bulundu",
"search.tokenizer": "[\s\-]+",
"source.link.title": "Depoya git",
"toc.title": "İçindekiler"
}[key] }}{% endmacro %}

View File

@ -13,7 +13,6 @@
"search.result.none": "Збігів не знайдено",
"search.result.one": "Знайдено 1 збіг",
"search.result.other": "Знайдено # збігів",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Перейти до змісту",
"source.link.title": "Перейти до репозиторію",
"toc.title": "Зміст"

View File

@ -47,7 +47,6 @@ theme:
# Default values, taken from mkdocs_theme.yml
language: en
direction: ltr
feature:
tabs: true
palette:

View File

@ -170,13 +170,22 @@ export default class Result {
/* Create stack and index */
this.stack_ = []
this.index_ = lunr(function() {
const filters = {
"search.pipeline.trimmer": lunr.trimmer,
"search.pipeline.stopwords": lunr.stopWordFilter
}
/* Disable stop words filter and trimmer, if desired */
const pipeline = Object.keys(filters).reduce((result, name) => {
if (!translate(name).match(/^false$/i))
result.push(filters[name])
return result
}, [])
/* Remove stemmer, as it cripples search experience */
this.pipeline.reset()
this.pipeline.add(
lunr.trimmer,
lunr.stopWordFilter
)
if (pipeline)
this.pipeline.add(...pipeline)
/* Set up alternate search languages */
if (lang.length === 1 && lang[0] !== "en" && lunr[lang[0]]) {

View File

@ -64,6 +64,8 @@
"clipboard.copy",
"clipboard.copied",
"search.language",
"search.pipeline.stopwords",
"search.pipeline.trimmer",
"search.result.none",
"search.result.one",
"search.result.other",

View File

@ -22,7 +22,7 @@
language: en
# Text direction (can be ltr or rtl)
direction: ltr
direction:
# Feature flags for functionality that alters behavior significantly, and thus
# may be a matter of taste

View File

@ -36,7 +36,6 @@
"search.result.none": "Ingen resultater fundet",
"search.result.one": "1 resultat",
"search.result.other": "# resultater",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Gå til indholdet",
"source.link.title": "Åbn arkiv",
"toc.title": "Indholdsfortegnelse"

View File

@ -36,7 +36,6 @@
"search.result.none": "Keine Suchergebnisse",
"search.result.one": "1 Suchergebnis",
"search.result.other": "# Suchergebnisse",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Zum Inhalt",
"source.link.title": "Quellcode",
"toc.title": "Inhaltsverzeichnis"

View File

@ -23,6 +23,7 @@
<!-- Translations: English -->
{% macro t(key) %}{{ {
"language": "en",
"direction": "ltr",
"clipboard.copy": "Copy to clipboard",
"clipboard.copied": "Copied to clipboard",
"edit.link.title": "Edit this page",
@ -31,6 +32,8 @@
"meta.comments": "Comments",
"meta.source": "Source",
"search.language": "en",
"search.pipeline.stopwords": true,
"search.pipeline.trimmer": true,
"search.placeholder": "Search",
"search.result.placeholder": "Type to start searching",
"search.result.none": "No matching documents",

View File

@ -36,7 +36,6 @@
"search.result.none": "No se encontraron documentos",
"search.result.one": "1 documento encontrado",
"search.result.other": "# documentos encontrados",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Saltar a contenido",
"source.link.title": "Ir al repositorio",
"toc.title": "Tabla de contenidos"

View File

@ -31,13 +31,14 @@
"footer.next": "بعدی",
"meta.comments": "نظرات",
"meta.source": "منبع",
"search.language": "en",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "جستجو",
"search.result.placeholder": "برای شروع جستجو تایپ کنید",
"search.result.none": "سندی یافت نشد",
"search.result.one": "1 سند یافت شد",
"search.result.other": "# سند یافت شد",
"search.tokenizer": "[\s]+",
"skip.link.title": "پرش به محتویات",
"source.link.title": "رفتن به مخزن",
"toc.title": "فهرست موضوعات"

View File

@ -36,7 +36,6 @@
"search.result.none": "Aucun document trouvé",
"search.result.one": "1 document trouvé",
"search.result.other": "# documents trouvés",
"search.tokenizer": "[\s\-]+",
"source.link.title": "Aller au dépôt",
"toc.title": "Table des matières"
}[key] }}{% endmacro %}

View File

@ -36,7 +36,6 @@
"search.result.none": "Nincs találat",
"search.result.one": "1 egyező dokumentum",
"search.result.other": "# egyező dokumentum",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Kihagyás",
"source.link.title": "Főoldalra ugrás",
"toc.title": "Tartalomjegyzék"

View File

@ -36,7 +36,6 @@
"search.result.none": "Nessun documento trovato",
"search.result.one": "1 documento trovato",
"search.result.other": "# documenti trovati",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Vai al contenuto",
"source.link.title": "Apri repository",
"toc.title": "Indice"

View File

@ -36,7 +36,6 @@
"search.result.none": "검색어와 일치하는 문서가 없습니다",
"search.result.one": "1개의 일치하는 문서",
"search.result.other": "#개의 일치하는 문서",
"search.tokenizer": "[\s\-]+",
"source.link.title": "저장소로 이동",
"toc.title": "목차"
}[key] }}{% endmacro %}

View File

@ -36,7 +36,6 @@
"search.result.none": "Geen overeenkomende documenten",
"search.result.one": "1 overeenkomende document",
"search.result.other": "# overeenkomende documenten",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Ga naar inhoud",
"source.link.title": "Ga naar repository",
"toc.title": "Inhoudstafel"

View File

@ -36,7 +36,6 @@
"search.result.none": "Ingen treff",
"search.result.one": "1 treff",
"search.result.other": "# treff",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Gå til innhold",
"source.link.title": "Gå til kilde",
"toc.title": "Innholdsfortegnelse"

View File

@ -30,12 +30,14 @@
"footer.next": "Następna strona",
"meta.comments": "Komentarze",
"meta.source": "Kod źródłowy",
"search.language": "",
"search.pipeline.stopwords": false,
"search.pipeline.trimmer": false,
"search.placeholder": "Szukaj",
"search.result.placeholder": "Zacznij pisać, aby szukać",
"search.result.none": "Brak wyników wyszukiwania",
"search.result.one": "Wyniki wyszukiwania: 1",
"search.result.other": "Wyniki wyszukiwania: #",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Przejdź do treści",
"source.link.title": "Idź do repozytorium",
"toc.title": "Spis treści"

View File

@ -36,7 +36,6 @@
"search.result.none": "Nenhum resultado encontrado",
"search.result.one": "1 resultado encontrado",
"search.result.other": "# resultados encontrados",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Ir para o conteúdo",
"source.link.title": "Ir ao repositório",
"toc.title": "Índice"

View File

@ -36,7 +36,6 @@
"search.result.none": "Совпадений не найдено",
"search.result.one": "Найдено 1 совпадение",
"search.result.other": "Найдено # совпадений",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Перейти к содержанию",
"source.link.title": "Перейти к репозиторию",
"toc.title": "Содержание"

View File

@ -36,7 +36,6 @@
"search.result.none": "Inga sökresultat",
"search.result.one": "1 sökresultat",
"search.result.other": "# sökresultat",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Gå till innehållet",
"source.link.title": "Gå till datakatalog",
"toc.title": "Innehållsförteckning"

View File

@ -36,7 +36,6 @@
"search.result.none": "Eşleşen doküman bulunamadı",
"search.result.one": "1 doküman bulundu",
"search.result.other": "# doküman bulundu",
"search.tokenizer": "[\s\-]+",
"source.link.title": "Depoya git",
"toc.title": "İçindekiler"
}[key] }}{% endmacro %}

View File

@ -36,7 +36,6 @@
"search.result.none": "Збігів не знайдено",
"search.result.one": "Знайдено 1 збіг",
"search.result.other": "Знайдено # збігів",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Перейти до змісту",
"source.link.title": "Перейти до репозиторію",
"toc.title": "Зміст"