From 906bc9dec09328dc41cee516a20babd09494f1dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93scar?= Date: Mon, 8 Jan 2024 01:00:52 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20search=20functionalit?= =?UTF-8?q?y=20(#250)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + config.toml | 25 + content/blog/javascript/index.ca.md | 4 +- content/blog/javascript/index.es.md | 4 +- content/blog/javascript/index.md | 4 +- .../blog/mastering-tabi-settings/index.ca.md | 53 +- .../blog/mastering-tabi-settings/index.es.md | 55 +- content/blog/mastering-tabi-settings/index.md | 53 +- content/projects/tabi/index.ca.md | 1 + content/projects/tabi/index.es.md | 1 + content/projects/tabi/index.md | 1 + i18n/ca.toml | 7 + i18n/de.toml | 7 + i18n/en.toml | 7 + i18n/es.toml | 7 + i18n/fr.toml | 7 + i18n/hi.toml | 7 + i18n/it.toml | 7 + i18n/ja.toml | 7 + i18n/ko.toml | 7 + i18n/pt-PT.toml | 7 + i18n/ru.toml | 7 + i18n/uk.toml | 7 + i18n/zh-Hans.toml | 7 + i18n/zh-Hant.toml | 7 + sass/main.scss | 1 + sass/parts/_misc.scss | 12 + sass/parts/_search.scss | 157 + static/js/lunr/lunr.da.js | 280 ++ static/js/lunr/lunr.da.min.js | 1 + static/js/lunr/lunr.de.js | 380 ++ static/js/lunr/lunr.de.min.js | 1 + static/js/lunr/lunr.du.js | 444 +++ static/js/lunr/lunr.du.min.js | 1 + static/js/lunr/lunr.es.js | 595 ++++ static/js/lunr/lunr.es.min.js | 1 + static/js/lunr/lunr.fi.js | 536 +++ static/js/lunr/lunr.fi.min.js | 1 + static/js/lunr/lunr.fr.js | 698 ++++ static/js/lunr/lunr.fr.min.js | 1 + static/js/lunr/lunr.hu.js | 561 +++ static/js/lunr/lunr.hu.min.js | 1 + static/js/lunr/lunr.it.js | 612 ++++ static/js/lunr/lunr.it.min.js | 1 + static/js/lunr/lunr.jp.js | 120 + static/js/lunr/lunr.jp.min.js | 1 + static/js/lunr/lunr.no.js | 253 ++ static/js/lunr/lunr.no.min.js | 1 + static/js/lunr/lunr.pt.js | 566 +++ static/js/lunr/lunr.pt.min.js | 1 + static/js/lunr/lunr.ro.js | 554 +++ static/js/lunr/lunr.ro.min.js | 1 + static/js/lunr/lunr.ru.js | 387 ++ static/js/lunr/lunr.ru.min.js | 1 + static/js/lunr/lunr.sv.js | 252 ++ static/js/lunr/lunr.sv.min.js | 1 + static/js/lunr/lunr.tr.js | 1070 ++++++ static/js/lunr/lunr.tr.min.js | 1 + static/js/lunr/lunr.zh.js | 156 + static/js/lunr/lunr.zh.min.js | 1 + static/js/lunr/lunrStemmerSupport.js | 304 ++ static/js/lunr/lunrStemmerSupport.min.js | 1 + static/js/searchElasticlunr.js | 3118 +++++++++++++++++ static/js/searchElasticlunr.min.js | 1 + templates/partials/footer.html | 5 + templates/partials/header.html | 27 + templates/partials/nav.html | 12 + templates/partials/search_modal.html | 24 + theme.toml | 7 + 69 files changed, 11443 insertions(+), 6 deletions(-) create mode 100644 sass/parts/_search.scss create mode 100644 static/js/lunr/lunr.da.js create mode 100644 static/js/lunr/lunr.da.min.js create mode 100644 static/js/lunr/lunr.de.js create mode 100644 static/js/lunr/lunr.de.min.js create mode 100644 static/js/lunr/lunr.du.js create mode 100644 static/js/lunr/lunr.du.min.js create mode 100644 static/js/lunr/lunr.es.js create mode 100644 static/js/lunr/lunr.es.min.js create mode 100644 static/js/lunr/lunr.fi.js create mode 100644 static/js/lunr/lunr.fi.min.js create mode 100644 static/js/lunr/lunr.fr.js create mode 100644 static/js/lunr/lunr.fr.min.js create mode 100644 static/js/lunr/lunr.hu.js create mode 100644 static/js/lunr/lunr.hu.min.js create mode 100644 static/js/lunr/lunr.it.js create mode 100644 static/js/lunr/lunr.it.min.js create mode 100644 static/js/lunr/lunr.jp.js create mode 100644 static/js/lunr/lunr.jp.min.js create mode 100644 static/js/lunr/lunr.no.js create mode 100644 static/js/lunr/lunr.no.min.js create mode 100644 static/js/lunr/lunr.pt.js create mode 100644 static/js/lunr/lunr.pt.min.js create mode 100644 static/js/lunr/lunr.ro.js create mode 100644 static/js/lunr/lunr.ro.min.js create mode 100644 static/js/lunr/lunr.ru.js create mode 100644 static/js/lunr/lunr.ru.min.js create mode 100644 static/js/lunr/lunr.sv.js create mode 100644 static/js/lunr/lunr.sv.min.js create mode 100644 static/js/lunr/lunr.tr.js create mode 100644 static/js/lunr/lunr.tr.min.js create mode 100644 static/js/lunr/lunr.zh.js create mode 100644 static/js/lunr/lunr.zh.min.js create mode 100755 static/js/lunr/lunrStemmerSupport.js create mode 100755 static/js/lunr/lunrStemmerSupport.min.js create mode 100644 static/js/searchElasticlunr.js create mode 100644 static/js/searchElasticlunr.min.js create mode 100644 templates/partials/search_modal.html diff --git a/README.md b/README.md index 60e0c0e..8496303 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ tabi has a perfect score on Google's Lighthouse audit: - [X] [Comprehensive multi-language support](https://welpo.github.io/tabi/blog/faq-languages/#how-does-tabi-handle-multilingual-support). Add as many languages as you wish. - [X] Support for [comments using giscus, utterances, Hyvor Talk, or Isso](https://welpo.github.io/tabi/blog/comments/). - [X] Code syntax highlighting with colours based on [Catppuccin](https://github.com/catppuccin/catppuccin) Frappé. +- [X] [Local search](https://welpo.github.io/tabi/blog/mastering-tabi-settings/#search) with an accessible, multi-lingual interface. - [X] [KaTeX](https://katex.org/) support for mathematical notation. - [X] [Stylized and human readable Atom feed](https://welpo.github.io/tabi/atom.xml). - [X] [Stylized and human readable sitemap](https://welpo.github.io/tabi/sitemap.xml). diff --git a/config.toml b/config.toml index 1a762cf..d36c8f6 100644 --- a/config.toml +++ b/config.toml @@ -5,6 +5,7 @@ author = "welpo" generate_feed = true compile_sass = true minify_html = true +build_search_index = true # To translate the entire theme, there must be a file with the same ISO 639-1 # (or IETF BCP 47) Code in the `i18n` folder of your site or the tabi theme @@ -15,6 +16,22 @@ default_language = "en" taxonomies = [{name = "tags", feed = true}] +[search] +# Whether to include the title of the page/section in the index. +include_title = true +# Whether to include the description of the page/section in the index. +include_description = true +# Whether to include the path of the page/section in the index. +include_path = true +# Whether to include the rendered content of the page/section in the index. +include_content = true +# At which character to truncate the content to. Useful if you have a lot of pages and the index would +# become too big to load on the site. Defaults to not being set. +# truncate_content_length = 100 +# Wether to produce the search index as a javascript file or as a JSON file. +# Accepted value "elasticlunr_javascript" or "elasticlunr_json". +index_format = "elasticlunr_json" + [markdown] highlight_code = true highlight_theme = "css" @@ -30,6 +47,7 @@ generate_feed = true compile_sass = true minify_html = true taxonomies = [{name = "tags", feed = true}] +build_search_index = true [languages.ca] title = "~/tabi" @@ -43,6 +61,13 @@ taxonomies = [{name = "tags", feed = true}] # Check out the documentation (or the comments below) to learn how to customise tabi: # https://welpo.github.io/tabi/blog/mastering-tabi-settings/ +# Search index format. +# For Zola 0.17.X users only. +# This MUST MATCH the setting in [search].index_format. +# Example: If [search].index_format is "elasticlunr_javascript", set: +# index_format = "elasticlunr_javascript" +# index_format = "" + # Enable JavaScript theme toggler to allow users to switch between dark/light mode. # If disabled, your site will only use the theme specified in the `default_theme` variable. theme_switcher = true diff --git a/content/blog/javascript/index.ca.md b/content/blog/javascript/index.ca.md index deacf1d..68829bf 100644 --- a/content/blog/javascript/index.ca.md +++ b/content/blog/javascript/index.ca.md @@ -1,7 +1,7 @@ +++ title = "Sense JavaScript obligatori" date = 2023-01-06 -updated = 2023-10-06 +updated = 2024-01-07 description = "JavaScript només s'utilitza quan HTML i CSS no són suficients." [taxonomies] @@ -16,6 +16,8 @@ Aquest tema no requereix JavaScript obligatori. Opcionalment, pot carregar una q ## Opcions habilitades globalment +- [**Cerca**](@/blog/mastering-tabi-settings/index.ca.md#cerca). Activada establint un idioma per defecte i `build_search_index = true` a la secció principal de `config.toml`. (~23KB de JavaScript) + - L'**interruptor de mode clar/fosc** es pot habilitar configurant `theme_switcher = true` a la secció `[extra]` del teu `config.toml` (~1KB de JavaScript). - **Decodificació de correu electrònic** (~400 bytes). Per protegir contra robots de correu brossa, pots configurar `encode_plaintext_email = true`. Si el teu lloc web està en un repositori públic, considera utilitzar el teu `email` com una cadena codificada en base64[^1]. diff --git a/content/blog/javascript/index.es.md b/content/blog/javascript/index.es.md index 0e7dd52..12375aa 100644 --- a/content/blog/javascript/index.es.md +++ b/content/blog/javascript/index.es.md @@ -1,7 +1,7 @@ +++ title = "Sin JavaScript obligatorio" date = 2023-01-06 -updated = 2023-10-06 +updated = 2024-01-07 description = "JavaScript solo se utiliza cuando HTML y CSS no son suficientes." [taxonomies] @@ -16,6 +16,8 @@ Este tema no requiere JavaScript de manera obligatoria. Opcionalmente, puede car ## Opciones habilitadas globalmente +- [**Búsqueda**](@/blog/mastering-tabi-settings/index.es.md#busqueda). Habilitada estableciendo un idioma por defecto y `build_search_index = true` en la sección principal de `config.toml`. (~23KB de JavaScript) + - El **interruptor de modo claro/oscuro** puede habilitarse configurando `theme_switcher = true` en la sección `[extra]` de tu `config.toml` (~1KB de JavaScript). - **Descodificación de correo electrónico** (~400 bytes). Para proteger contra bots que recopilan correos electrónicos desde tu sitio web, puedes configurar `encode_plaintext_email = true`. Si tu sitio está en un repositorio público, para mayor protección, considera configurar tu `email` como una cadena codificada en base64[^1]. diff --git a/content/blog/javascript/index.md b/content/blog/javascript/index.md index 9fc9d3f..0139a53 100644 --- a/content/blog/javascript/index.md +++ b/content/blog/javascript/index.md @@ -1,7 +1,7 @@ +++ title = "No mandatory JavaScript" date = 2023-01-06 -updated = 2023-10-06 +updated = 2024-01-07 description = "JavaScript is only used when HTML and CSS aren't enough." [taxonomies] @@ -16,6 +16,8 @@ This theme has no mandatory JavaScript. Optionally, it can load a minimal amount ## Globally enabled settings +- [**Search**](@/blog/mastering-tabi-settings/index.md#search). Enabled by setting a default language and `build_search_index = true` on the main section of `config.toml`. (~23KB of JavaScript) + - The **light/dark mode switch** can be enabled by setting `theme_switcher = true` in the `[extra]` section of your `config.toml` (~1KB of JavaScript). - **E-mail decoding** (~400 bytes). To protect against spambots scraping your e-mail from your website, you can set `encode_plaintext_email = true`. If your site is on a public repository, for extra protection, consider setting your `email` as a base64-encoded string[^1] directly. diff --git a/content/blog/mastering-tabi-settings/index.ca.md b/content/blog/mastering-tabi-settings/index.ca.md index 97fd25d..4001311 100644 --- a/content/blog/mastering-tabi-settings/index.ca.md +++ b/content/blog/mastering-tabi-settings/index.ca.md @@ -1,7 +1,7 @@ +++ title = "Domina la configuració de tabi: guia completa" date = 2023-09-18 -updated = 2024-01-05 +updated = 2024-01-07 description = "Descobreix les múltiples maneres en què pots personalitzar tabi." [taxonomies] @@ -34,6 +34,57 @@ Per a les configuracions que segueixen aquesta jerarquia, el valor establert a u --- +## Cerca + +| Pàgina | Secció | `config.toml` | Segueix la jerarquia | Requereix JavaScript | +|:------:|:------:|:-------------:|:--------------------:|:--------------------:| +| ❌ | ❌ | ✅ | ❌ | ✅ | + +tabi permet cerca local accessible i multilingüe amb [Elasticlunr](http://elasticlunr.com/). Per activar-la, necessites: + +1. Establir un `default_language` a `config.toml`. +2. Establir `build_search_index = true`. +3. Opcionalment, configurar la secció `[search]`. + +Per exemple: + +```toml +base_url = "https://example.com" +default_language = "en" +build_search_index = true + +[search] +index_format = "elasticlunr_json" # O el menys eficient "elasticlunr_javascript". +include_title = true +include_description = true +include_path = true +include_content = true +``` + +**Nota**: per suport de cerca en Xinès/Japonès, necessites utilitzar una [build personalitzada de Zola](https://github.com/getzola/zola/blob/master/Cargo.toml#L54-L55). Addicionalment, actualment no hi ha suport per a la cerca en català. + +### Consideracions per a usuaris de Zola 0.17.X + +Zola 0.17.X no proporciona accés a la variable `search.index_format` ([informe del bug](https://github.com/getzola/zola/issues/2165)). En utilitzar tabi, s'assumeix l'ús de l'índex JSON, que és més eficient. No obstant això, a causa d'[un altre bug](https://github.com/getzola/zola/issues/2193) solucionat en 0.18.0, l'índex JSON per a llocs multilingües no es genera correctament. + +Els usuaris amb versions de Zola anteriors a 0.18.0 que vulguin utilitzar l'índex JavaScript necessiten establir la variable `index_format` a dos llocs: + +```toml +[search] +index_format = "elasticlunr_javascript" + +[extra] +index_format = "elasticlunr_javascript" +``` + +Això assegura que tabi carregui els arxius correctes. Recomanem actualitzar a Zola 0.18.0 o posterior per a una funcionalitat òptima. + +### Detalls d'implementació + +Per a detalls tècnics sobre la implementació de la cerca, incloent quan es carrega l'índex, característiques d'accessibilitat i altres detalls, consulta el [Pull Request #250](https://github.com/welpo/tabi/pull/250). + +--- + ## Suport multilingüe tabi ofereix suport multilingüe complet per al teu lloc Zola, des de configurar un idioma predeterminat fins a afegir tots els que vulguis. Consulta les [preguntes freqüents sobre idiomes](/ca/blog/faq-languages/) per a més informació. diff --git a/content/blog/mastering-tabi-settings/index.es.md b/content/blog/mastering-tabi-settings/index.es.md index 6d8521c..e151483 100644 --- a/content/blog/mastering-tabi-settings/index.es.md +++ b/content/blog/mastering-tabi-settings/index.es.md @@ -1,7 +1,7 @@ +++ title = "Domina la configuración de tabi: guía completa" date = 2023-09-18 -updated = 2024-01-05 +updated = 2024-01-07 description = "Descubre las múltiples maneras en que puedes personalizar tabi." [taxonomies] @@ -32,6 +32,59 @@ En todos los casos, las opciones de tabi se establecen en la sección `[extra]`. Para las configuraciones que siguen esta jerarquía, el valor establecido en una página reemplaza el valor de una sección, que a su vez reemplaza el valor global. En resumen: cuanto más específica sea la configuración, mayor prioridad tendrá, o `página > sección > config.toml`. +--- + +## Búsqueda + +| Página | Sección | `config.toml` | Sigue la jerarquía | Requiere JavaScript | +|:------:|:-------:|:-------------:|:---------------:|:-------------------:| +| ❌ | ❌ | ✅ | ❌ | ✅ | + +tabi soporta búsqueda local accesible y multilingüe con [Elasticlunr](http://elasticlunr.com/). Para activarla, necesitas: + +1. Establecer un `default_language` en `config.toml`. +2. Establecer `build_search_index = true`. +3. Opcionalmente, configurar la sección `[search]`. + +Por ejemplo: + +```toml +base_url = "https://example.com" +default_language = "en" +build_search_index = true + +[search] +index_format = "elasticlunr_json" # O el menos eficiente "elasticlunr_javascript". +include_title = true +include_description = true +include_path = true +include_content = true +``` + +**Nota**: para soporte de búsqueda en Chino/Japonés, necesitas usar una [build personalizada de Zola](https://github.com/getzola/zola/blob/master/Cargo.toml#L54-L55). + +### Consideraciones para usuarios de Zola 0.17.X + +Zola 0.17.X no proporciona acceso a la variable `search.index_format` ([reporte del bug](https://github.com/getzola/zola/issues/2165)). Al usar tabi, se asume el uso del índice JSON, que es más eficiente. Sin embargo, debido a [otro bug](https://github.com/getzola/zola/issues/2193) solucionado en 0.18.0, el índice JSON para sitios multilingües no se genera correctamente. + +Los usuarios con versiones de Zola anteriores a 0.18.0 que quieran usar el índice JavaScript necesitan establecer la variable `index_format` en dos lugares: + +```toml +[search] +index_format = "elasticlunr_javascript" + +[extra] +index_format = "elasticlunr_javascript" +``` + +Esto asegura que tabi cargue los archivos correctos. Recomendamos actualizar a Zola 0.18.0 o posterior para una funcionalidad óptima. + +### Detalles de implementación + +Para detalles técnicos sobre la implementación de la búsqueda en tabi, incluyendo cuándo se carga el índice, características de accesibilidad y otros detalles, consulta el [Pull Request #250](https://github.com/welpo/tabi/pull/250). + +--- + ## Soporte multilingüe tabi ofrece soporte multilingüe completo para tu sitio Zola, desde configurar un idioma predeterminado hasta añadir todos los que desees. Consulta la [preguntas frecuentes sobre idiomas](/es/blog/faq-languages/) para más información. diff --git a/content/blog/mastering-tabi-settings/index.md b/content/blog/mastering-tabi-settings/index.md index 780ee71..deef148 100644 --- a/content/blog/mastering-tabi-settings/index.md +++ b/content/blog/mastering-tabi-settings/index.md @@ -1,7 +1,7 @@ +++ title = "Mastering tabi Settings: A Comprehensive Guide" date = 2023-09-18 -updated = 2024-01-05 +updated = 2024-01-07 description = "Discover the many ways you can customise your tabi site." [taxonomies] @@ -34,6 +34,57 @@ For settings which follow this hierarchy, the value set on a page overrides the --- +## Search + +| Page | Section | `config.toml` | Follows Hierarchy | Requires JavaScript | +|:----:|:-------:|:-------------:|:-----------------:|:-------------------:| +| ❌ | ❌ | ✅ | ❌ | ✅ | + +tabi supports accessible, local multi-lingual search with [Elasticlunr](http://elasticlunr.com/). To enable it, you need to: + +1. Set a `default_language` in `config.toml`. +2. Set `build_search_index = true`. +3. Optionally, configure the `[search]`. + +Here's an example configuration: + +```toml +base_url = "https://example.com" +default_language = "en" +build_search_index = true + +[search] +index_format = "elasticlunr_json" # Or the less efficient "elasticlunr_javascript". +include_title = true +include_description = true +include_path = true +include_content = true +``` + +**Note**: for Chinese/Japanese search support, you need to use a [custom Zola build](https://github.com/getzola/zola/blob/master/Cargo.toml#L54-L55). + +### Considerations for Zola 0.17.X Users + +Zola 0.17.X doesn't provide access to the `search.index_format` variable ([bug report](https://github.com/getzola/zola/issues/2165)). When using tabi, this variable defaults to the more efficient JSON index. However, due to [another bug](https://github.com/getzola/zola/issues/2193) fixed in 0.18.0, the JSON index for multi-language sites is not generated correctly. + +Users with Zola versions prior to 0.18.0 who want to use the JavaScript index need to set the `index_format` variable in two places: + +```toml +[search] +index_format = "elasticlunr_javascript" + +[extra] +index_format = "elasticlunr_javascript" +``` + +This ensures tabi loads the right files. We recommend upgrading to Zola 0.18.0 or later for optimal functionality. + +### Implementation Details + +For technical details about the search implementation in tabi, including when the index loads, accessibility features, and other specifics, see the [Pull Request #250](https://github.com/welpo/tabi/pull/250). + +--- + ## Multilingual Support tabi offers comprehensive multilingual support for your Zola site, from setting a default language to adding as many as you wish. Refer to the [multilingual FAQ](blog/faq-languages/) for more information. diff --git a/content/projects/tabi/index.ca.md b/content/projects/tabi/index.ca.md index 4f1f29c..11becfd 100644 --- a/content/projects/tabi/index.ca.md +++ b/content/projects/tabi/index.ca.md @@ -24,6 +24,7 @@ social_media_card = "social_cards/ca_projects_tabi.jpg" - Puntuació perfecta en Lighthouse (Rendiment, Accessibilitat, Millors Pràctiques i SEO). - Ressaltat de sintaxi de codi amb colors basats en [Catppuccin](https://github.com/catppuccin/catppuccin) Frappé. - Suport per a [comentaris usant giscus, utterances, Hyvor Talk o Isso](https://welpo.github.io/tabi/ca/blog/comments/). +- [Cerca local](https://welpo.github.io/tabi/ca/blog/mastering-tabi-settings/#cerca) amb una interfície accessible i multilingüe. - Tot el JavaScript es pot [deshabilitar completament](https://welpo.github.io/tabi/ca/blog/javascript/). - [Codificació de correu](https://welpo.github.io/tabi/ca/blog/mastering-tabi-settings/#correu-electronic-codificat) per a protecció contra spam. - [Mapa del lloc estilitzat i llegible per humans](https://welpo.github.io/tabi/sitemap.xml). diff --git a/content/projects/tabi/index.es.md b/content/projects/tabi/index.es.md index 9a3d5a4..19d6ea3 100644 --- a/content/projects/tabi/index.es.md +++ b/content/projects/tabi/index.es.md @@ -25,6 +25,7 @@ social_media_card = "social_cards/es_projects_tabi.jpg" - Resaltado de sintaxis de código con colores basados en [Catppuccin](https://github.com/catppuccin/catppuccin) Frappé. - Soporte para [comentarios usando giscus, utterances, Hyvor Talk o Isso](https://welpo.github.io/tabi/es/blog/comments/). - Todo el JavaScript se puede [deshabilitar completamente](https://welpo.github.io/tabi/es/blog/javascript/). +- [Búsqueda local](https://welpo.github.io/tabi/es/blog/mastering-tabi-settings/#busqueda) con una interfaz accesible y multilingüe. - [Codificación de correo](https://welpo.github.io/tabi/es/blog/mastering-tabi-settings/#encoded-email) para protección contra spam. - [Mapa de sitio web estilizado y legible por humanos](https://welpo.github.io/tabi/sitemap.xml). - [Feed de Atom estilizado y legible por humanos](https://welpo.github.io/tabi/es/atom.xml). diff --git a/content/projects/tabi/index.md b/content/projects/tabi/index.md index 2929110..3f6861e 100644 --- a/content/projects/tabi/index.md +++ b/content/projects/tabi/index.md @@ -25,6 +25,7 @@ social_media_card = "social_cards/projects_tabi.jpg" - [Comprehensive multi-language support](https://welpo.github.io/tabi/blog/faq-languages/#how-does-tabi-handle-multilingual-support). Add as many languages as you wish. - Support for [comments using giscus, utterances, Hyvor Talk, or Isso](https://welpo.github.io/tabi/blog/comments/). - Code syntax highlighting with colours based on [Catppuccin](https://github.com/catppuccin/catppuccin) Frappé. +- [Local search](https://welpo.github.io/tabi/blog/mastering-tabi-settings/#search) with an accessible, multi-lingual interface. - [KaTeX](https://katex.org/) support for mathematical notation. - [Stylized and human readable Atom feed](https://welpo.github.io/tabi/atom.xml). - [Stylized and human readable sitemap](https://welpo.github.io/tabi/sitemap.xml). diff --git a/i18n/ca.toml b/i18n/ca.toml index d2e8677..d9a9629 100644 --- a/i18n/ca.toml +++ b/i18n/ca.toml @@ -14,6 +14,13 @@ privacy = "política de privadesa" site_statistics = "estadístiques del lloc" sitemap = "mapa del lloc" +# Search. +search = "Cercar" +search_icon_title = "Fes clic o prem $SHORTCUT per obrir la cerca" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Esborrar cerca" # Title of the X icon next to search input. +result = "resultat" # "1 result" +results = "resultats" # "3 results" (also used for 0 results). + # Navigation. read_more = "Llegir més" post = "entrada" diff --git a/i18n/de.toml b/i18n/de.toml index bff310b..c02555b 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -18,6 +18,13 @@ privacy = "datenschutzrichtlinie" site_statistics = "seitenstatistiken" sitemap = "seitenübersicht" +# Search. +search = "Suchen" +search_icon_title = "Klicken oder $SHORTCUT drücken, um die Suche zu öffnen" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Suche löschen" # Title of the X icon next to search input. +result = "ergebnis" # "1 result" +results = "ergebnisse" # "3 results" (also used for 0 results). + # Navigation. read_more = "Weiterlesen" post = "beitrag" diff --git a/i18n/en.toml b/i18n/en.toml index f25047d..b299197 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -14,6 +14,13 @@ privacy = "privacy policy" site_statistics = "site statistics" sitemap = "sitemap" +# Search. +search = "Search" +search_icon_title = "Click or press $SHORTCUT to open search" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Clear search" # Title of the X icon next to search input. +result = "result" # "1 result" +results = "results" # "3 results" (also used for 0 results). + # Navigation. read_more = "Read more" post = "post" diff --git a/i18n/es.toml b/i18n/es.toml index 11a2539..ca05045 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -14,6 +14,13 @@ privacy = "política de privacidad" site_statistics = "estadísticas del sitio" sitemap = "mapa del sitio" +# Search. +search = "Buscar" +search_icon_title = "Haz clic o usa $SHORTCUT para abrir la búsqueda" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Borrar búsqueda" # Title of the X icon next to search input. +result = "resultado" # "1 result" +results = "resultados" # "3 results" (also used for 0 results). + # Navigation. read_more = "Leer más" post = "entrada" diff --git a/i18n/fr.toml b/i18n/fr.toml index 203442c..164358c 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -18,6 +18,13 @@ privacy = "politique de confidentialité" site_statistics = "statistiques du site" sitemap = "plan du site" +# Search. +search = "Rechercher" +search_icon_title = "Cliquez ou appuyez sur $SHORTCUT pour ouvrir la recherche" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Effacer la recherche" # Title of the X icon next to search input. +result = "résultat" # "1 result" +results = "résultats" # "3 results" (also used for 0 results). + # Navigation. read_more = "Lire plus" post = "article" diff --git a/i18n/hi.toml b/i18n/hi.toml index 5b43300..173cf20 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -16,6 +16,13 @@ privacy = "गोपनीयता नीति" site_statistics = "साइट सांख्यिकी" sitemap = "साइटमैप" +# Search. +search = "खोजें" +search_icon_title = "$SHORTCUT दबाएँ या क्लिक करें खोज खोलने के लिए" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "खोज साफ करें" # Title of the X icon next to search input. +result = "परिणाम" # "1 result" +results = "परिणाम" # "3 results" (also used for 0 results). + # Navigation. read_more = "और पढ़ें" post = "पोस्ट" diff --git a/i18n/it.toml b/i18n/it.toml index b1b94a6..bffcb81 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -14,6 +14,13 @@ privacy = "politica sulla privacy" site_statistics = "statistiche del sito" sitemap = "mappa del sito" +# Search. +search = "Cerca" +search_icon_title = "Clicca o premi $SHORTCUT per aprire la ricerca" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Cancella ricerca" # Title of the X icon next to search input. +result = "risultato" # "1 result" +results = "risultati" # "3 result" (also used for 0 results). + # Navigation. read_more = "Leggi di più" post = "post" diff --git a/i18n/ja.toml b/i18n/ja.toml index 89d1ce5..40de90b 100644 --- a/i18n/ja.toml +++ b/i18n/ja.toml @@ -18,6 +18,13 @@ privacy = "プライバシーポリシー" site_statistics = "サイト統計" sitemap = "サイトマップ" +# Search. +search = "検索" +search_icon_title = "$SHORTCUTを押すか、クリックして検索を開く" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "検索をクリア" # Title of the X icon next to search input. +result = "結果" # "1 result" +results = "結果" # "3 results" (also used for 0 results). + # Navigation. read_more = "続きを読む" post = "投稿" diff --git a/i18n/ko.toml b/i18n/ko.toml index dcc64d1..cebb030 100644 --- a/i18n/ko.toml +++ b/i18n/ko.toml @@ -18,6 +18,13 @@ privacy = "개인정보 처리방침" site_statistics = "사이트 통계" sitemap = "사이트맵" +# Search. +search = "검색" +search_icon_title = "클릭하거나 $SHORTCUT을 눌러 검색 열기" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "검색 지우기" # Title of the X icon next to search input. +result = "결과" # "1 result" +results = "결과" # "3 results" (also used for 0 results). + # Navigation. read_more = "더 읽기" post = "게시물" diff --git a/i18n/pt-PT.toml b/i18n/pt-PT.toml index adf2b11..8d814bb 100644 --- a/i18n/pt-PT.toml +++ b/i18n/pt-PT.toml @@ -14,6 +14,13 @@ privacy = "política de privacidade" site_statistics = "estatísticas do site" sitemap = "mapa do site" +# Search. +search = "Pesquisar" +search_icon_title = "Clique ou pressione $SHORTCUT para abrir a pesquisa" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Limpar pesquisa" # Title of the X icon next to search input. +result = "resultado" # "1 result" +results = "resultados" # "3 results" (also used for 0 results). + # Navigation. read_more = "Ler mais" post = "publicação" diff --git a/i18n/ru.toml b/i18n/ru.toml index 6a15b17..b59ed74 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -14,6 +14,13 @@ privacy = "политика конфиденциальности" site_statistics = "статистика сайта" sitemap = "карта сайта" +# Search. +search = "Поиск" +search_icon_title = "Нажмите или используйте $SHORTCUT для открытия поиска" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Очистить поиск" # Title of the X icon next to search input. +result = "результат" # "1 result" +results = "результаты" # "3 results" (also used for 0 results). + # Navigation. read_more = "Читать далее" post = "пост" diff --git a/i18n/uk.toml b/i18n/uk.toml index 6c4ee0c..bfd23fd 100644 --- a/i18n/uk.toml +++ b/i18n/uk.toml @@ -18,6 +18,13 @@ privacy = "політика конфіденційності" site_statistics = "статистика сайту" sitemap = "карта сайту" +# Search. +search = "Пошук" +search_icon_title = "Натисніть або використовуйте $SHORTCUT, щоб відкрити пошук" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "Очистити пошук" # Title of the X icon next to search input. +result = "результат" # "1 result" +results = "результати" # "3 results" (also used for 0 results). + # Navigation. read_more = "Читати далі" post = "пост" diff --git a/i18n/zh-Hans.toml b/i18n/zh-Hans.toml index 3e9b6e0..c6a3c92 100644 --- a/i18n/zh-Hans.toml +++ b/i18n/zh-Hans.toml @@ -14,6 +14,13 @@ privacy = "隐私政策" # Machine translated. site_statistics = "网站统计" # Machine translated. sitemap = "站点地图" # Machine translated. +# Search. +search = "搜索" +search_icon_title = "点击或按 $SHORTCUT 开启搜索" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "清除搜索" # Title of the X icon next to search input. +result = "结果" # "1 result" +results = "结果" # "3 results" (also used for 0 results). + # Navigation. read_more = "阅读全文" post = "文章" diff --git a/i18n/zh-Hant.toml b/i18n/zh-Hant.toml index 88d9bc3..80d41ae 100644 --- a/i18n/zh-Hant.toml +++ b/i18n/zh-Hant.toml @@ -14,6 +14,13 @@ privacy = "隱私政策" # Machine translated. site_statistics = "網站統計" # Machine translated. sitemap = "網站地圖" # Machine translated. +# Search. +search = "搜尋" +search_icon_title = "點擊或按 $SHORTCUT 來開啟搜尋" # $SHORTCUT will be replaced with the actual keyboard shortcut. +clear_search = "清除搜尋" # Title of the X icon next to search input. +result = "結果" # "1 result" +results = "結果" # "3 results" (also used for 0 results). + # Navigation. read_more = "閱讀全文" post = "文章" diff --git a/sass/main.scss b/sass/main.scss index 81abd62..da495ea 100644 --- a/sass/main.scss +++ b/sass/main.scss @@ -14,6 +14,7 @@ @use 'parts/_pagination.scss'; @use 'parts/_posts_list.scss'; @use 'parts/_quick_navigation_buttons.scss'; +@use 'parts/_search.scss'; @use 'parts/_spoiler.scss'; @use 'parts/_syntax_theme.scss'; @use 'parts/_table.scss'; diff --git a/sass/parts/_misc.scss b/sass/parts/_misc.scss index 54e8a7d..09ad1d9 100644 --- a/sass/parts/_misc.scss +++ b/sass/parts/_misc.scss @@ -168,6 +168,18 @@ details summary { cursor: pointer; } +.interactive-icon { + cursor: pointer; + + path { + fill: var(--text-color); + } + + :hover path { + fill: var(--meta-color); + } +} + .article-navigation { display: flex; margin-top: 2rem; diff --git a/sass/parts/_search.scss b/sass/parts/_search.scss new file mode 100644 index 0000000..05caf75 --- /dev/null +++ b/sass/parts/_search.scss @@ -0,0 +1,157 @@ +$icon-size: 1.3rem; + +#searchModal { + background: color-mix(in srgb, var(--primary-color) 5%, transparent); + text-align: left; + + #searchContainer { + padding: 1rem; + } + + #searchBar { + display: flex; + position: relative; + justify-content: center; + align-items: center; + box-sizing: border-box; + padding: 1rem; + + .search-icon { + position: absolute; + left: 1rem; + width: $icon-size; + height: $icon-size; + + path { + fill: var(--text-color); + } + } + + .close-icon { + position: absolute; + right: $icon-size; + margin-right: 0.5rem; + margin-left: 1rem; + width: $icon-size; + height: $icon-size; + } + + #searchInput { + flex: 1; + border: 1px solid var(--divider-color); + border-radius: 20px; + background-color: var(--input-background-color); + padding: 0.75rem 1rem 0.75rem 3rem; + width: calc(100% - 2rem); + color: var(--text-color); + font-size: 1rem; + } + } + + #results-container { + display: none; + border-top: var(--divider-color) solid 0.5px; + border-bottom-right-radius: 1rem; + border-bottom-left-radius: 1rem; + overflow: hidden; + + #results-info { + padding: 0.5rem; + color: var(--meta-color); + font-size: 0.8rem; + text-align: center; + } + + #results { + display: flex; + flex-direction: column; + max-height: 50vh; + overflow-y: auto; + + b { + font-weight: 590; + } + + a { + display: block; + + &:hover { + background-color: inherit; + } + } + + > div { + cursor: pointer; + padding: 0.5rem 1rem; + + &[aria-selected="true"] { + background-color: var(--primary-color); + color: var(--hover-color); + + a, + span { + color: inherit; + } + } + } + + span:first-child { + display: block; + color: var(--primary-color); + font-weight: 590; + } + + span:nth-child(2) { + color: var(--text-color); + } + } + + } +} + +.search-icon { + display: block; + position: relative; + align-self: center; + margin-right: 0.5rem; + margin-left: 1rem; + width: $icon-size; + height: $icon-size; +} + +.search-modal { + -webkit-backdrop-filter: blur(8px); + display: none; + position: fixed; + top: 0; + left: 0; + z-index: 1000; + backdrop-filter: blur(8px); + background-color: rgba(0, 0, 0, 0.1); + width: 100%; + height: 100%; + overflow: auto; + + #modal-content { + position: relative; + margin: 8% auto; + border: var(--divider-color) solid 0.5px; + border-radius: 1rem; + background-color: var(--background-color); + width: 80%; + max-width: 28rem; + } +} + +@media only screen and (max-width: 600px) { + .search-modal { + #modal-content { + top: 3.5rem; + width: 92%; + + #results { + max-height: 70vh; + } + } + } +} diff --git a/static/js/lunr/lunr.da.js b/static/js/lunr/lunr.da.js new file mode 100644 index 0000000..32c6d01 --- /dev/null +++ b/static/js/lunr/lunr.da.js @@ -0,0 +1,280 @@ +/*! + * Lunr languages, `Danish` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.da = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.da.trimmer, + lunr.da.stopWordFilter, + lunr.da.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.da.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.da.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.da.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.da.trimmer, 'trimmer-da'); + + /* lunr stemmer function */ + lunr.da.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function DanishStemmer() { + var a_0 = [new Among("hed", -1, 1), new Among("ethed", 0, 1), + new Among("ered", -1, 1), new Among("e", -1, 1), + new Among("erede", 3, 1), new Among("ende", 3, 1), + new Among("erende", 5, 1), new Among("ene", 3, 1), + new Among("erne", 3, 1), new Among("ere", 3, 1), + new Among("en", -1, 1), new Among("heden", 10, 1), + new Among("eren", 10, 1), new Among("er", -1, 1), + new Among("heder", 13, 1), new Among("erer", 13, 1), + new Among("s", -1, 2), new Among("heds", 16, 1), + new Among("es", 16, 1), new Among("endes", 18, 1), + new Among("erendes", 19, 1), new Among("enes", 18, 1), + new Among("ernes", 18, 1), new Among("eres", 18, 1), + new Among("ens", 16, 1), new Among("hedens", 24, 1), + new Among("erens", 24, 1), new Among("ers", 16, 1), + new Among("ets", 16, 1), new Among("erets", 28, 1), + new Among("et", -1, 1), new Among("eret", 30, 1) + ], + a_1 = [ + new Among("gd", -1, -1), new Among("dt", -1, -1), + new Among("gt", -1, -1), new Among("kt", -1, -1) + ], + a_2 = [ + new Among("ig", -1, 1), new Among("lig", 0, 1), + new Among("elig", 1, 1), new Among("els", -1, 1), + new Among("l\u00F8st", -1, 2) + ], + g_v = [17, 65, 16, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 128 + ], + g_s_ending = [239, 254, 42, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 16 + ], + I_x, I_p1, S_ch, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function r_mark_regions() { + var v_1, c = sbp.cursor + 3; + I_p1 = sbp.limit; + if (0 <= c && c <= sbp.limit) { + I_x = c; + while (true) { + v_1 = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 248)) { + sbp.cursor = v_1; + break; + } + sbp.cursor = v_1; + if (v_1 >= sbp.limit) + return; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 248)) { + if (sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + } + I_p1 = sbp.cursor; + if (I_p1 < I_x) + I_p1 = I_x; + } + } + + function r_main_suffix() { + var among_var, v_1; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_0, 32); + sbp.limit_backward = v_1; + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + if (sbp.in_grouping_b(g_s_ending, 97, 229)) + sbp.slice_del(); + break; + } + } + } + } + + function r_consonant_pair() { + var v_1 = sbp.limit - sbp.cursor, + v_2; + if (sbp.cursor >= I_p1) { + v_2 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + if (sbp.find_among_b(a_1, 4)) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_2; + sbp.cursor = sbp.limit - v_1; + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + sbp.bra = sbp.cursor; + sbp.slice_del(); + } + } else + sbp.limit_backward = v_2; + } + } + + function r_other_suffix() { + var among_var, v_1 = sbp.limit - sbp.cursor, + v_2, v_3; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "st")) { + sbp.bra = sbp.cursor; + if (sbp.eq_s_b(2, "ig")) + sbp.slice_del(); + } + sbp.cursor = sbp.limit - v_1; + if (sbp.cursor >= I_p1) { + v_2 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_2, 5); + sbp.limit_backward = v_2; + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_del(); + v_3 = sbp.limit - sbp.cursor; + r_consonant_pair(); + sbp.cursor = sbp.limit - v_3; + break; + case 2: + sbp.slice_from("l\u00F8s"); + break; + } + } + } + } + + function r_undouble() { + var v_1; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + if (sbp.out_grouping_b(g_v, 97, 248)) { + sbp.bra = sbp.cursor; + S_ch = sbp.slice_to(S_ch); + sbp.limit_backward = v_1; + if (sbp.eq_v_b(S_ch)) + sbp.slice_del(); + } else + sbp.limit_backward = v_1; + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_main_suffix(); + sbp.cursor = sbp.limit; + r_consonant_pair(); + sbp.cursor = sbp.limit; + r_other_suffix(); + sbp.cursor = sbp.limit; + r_undouble(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.da.stemmer, 'stemmer-da'); + + /* stop word filter function */ + lunr.da.stopWordFilter = function(token) { + if (lunr.da.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.da.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.da.stopWordFilter.stopWords.length = 95; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.da.stopWordFilter.stopWords.elements = ' ad af alle alt anden at blev blive bliver da de dem den denne der deres det dette dig din disse dog du efter eller en end er et for fra ham han hans har havde have hende hendes her hos hun hvad hvis hvor i ikke ind jeg jer jo kunne man mange med meget men mig min mine mit mod ned noget nogle nu når og også om op os over på selv sig sin sine sit skal skulle som sådan thi til ud under var vi vil ville vor være været'.split(' '); + + lunr.Pipeline.registerFunction(lunr.da.stopWordFilter, 'stopWordFilter-da'); + }; +})) diff --git a/static/js/lunr/lunr.da.min.js b/static/js/lunr/lunr.da.min.js new file mode 100644 index 0000000..eb41d29 --- /dev/null +++ b/static/js/lunr/lunr.da.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,t,i;r.da=function(){this.pipeline.reset(),this.pipeline.add(r.da.trimmer,r.da.stopWordFilter,r.da.stemmer)},r.da.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.da.trimmer=r.trimmerSupport.generateTrimmer(r.da.wordCharacters),r.Pipeline.registerFunction(r.da.trimmer,"trimmer-da"),r.da.stemmer=(e=r.stemmerSupport.Among,t=r.stemmerSupport.SnowballProgram,i=new function(){var n,s,o,d=[new e("hed",-1,1),new e("ethed",0,1),new e("ered",-1,1),new e("e",-1,1),new e("erede",3,1),new e("ende",3,1),new e("erende",5,1),new e("ene",3,1),new e("erne",3,1),new e("ere",3,1),new e("en",-1,1),new e("heden",10,1),new e("eren",10,1),new e("er",-1,1),new e("heder",13,1),new e("erer",13,1),new e("s",-1,2),new e("heds",16,1),new e("es",16,1),new e("endes",18,1),new e("erendes",19,1),new e("enes",18,1),new e("ernes",18,1),new e("eres",18,1),new e("ens",16,1),new e("hedens",24,1),new e("erens",24,1),new e("ers",16,1),new e("ets",16,1),new e("erets",28,1),new e("et",-1,1),new e("eret",30,1)],i=[new e("gd",-1,-1),new e("dt",-1,-1),new e("gt",-1,-1),new e("kt",-1,-1)],a=[new e("ig",-1,1),new e("lig",0,1),new e("elig",1,1),new e("els",-1,1),new e("løst",-1,2)],u=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],l=[239,254,42,3,0,0,0,0,0,0,0,0,0,0,0,0,16],c=new t;function m(){var e,r=c.limit-c.cursor;c.cursor>=s&&(e=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,c.find_among_b(i,4)?(c.bra=c.cursor,c.limit_backward=e,c.cursor=c.limit-r,c.cursor>c.limit_backward&&(c.cursor--,c.bra=c.cursor,c.slice_del())):c.limit_backward=e)}this.setCurrent=function(e){c.setCurrent(e)},this.getCurrent=function(){return c.getCurrent()},this.stem=function(){var e,r=c.cursor;if(function(){var e,r=c.cursor+3;if(s=c.limit,0<=r&&r<=c.limit){for(n=r;;){if(e=c.cursor,c.in_grouping(u,97,248)){c.cursor=e;break}if((c.cursor=e)>=c.limit)return;c.cursor++}for(;!c.out_grouping(u,97,248);){if(c.cursor>=c.limit)return;c.cursor++}(s=c.cursor)=s&&(r=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,e=c.find_among_b(d,32),c.limit_backward=r,e))switch(c.bra=c.cursor,e){case 1:c.slice_del();break;case 2:c.in_grouping_b(l,97,229)&&c.slice_del()}c.cursor=c.limit,m(),c.cursor=c.limit;var i,t,r=c.limit-c.cursor;if(c.ket=c.cursor,c.eq_s_b(2,"st")&&(c.bra=c.cursor,c.eq_s_b(2,"ig"))&&c.slice_del(),c.cursor=c.limit-r,c.cursor>=s&&(r=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,i=c.find_among_b(a,5),c.limit_backward=r,i))switch(c.bra=c.cursor,i){case 1:c.slice_del(),t=c.limit-c.cursor,m(),c.cursor=c.limit-t;break;case 2:c.slice_from("løs")}return c.cursor=c.limit,c.cursor>=s&&(e=c.limit_backward,c.limit_backward=s,c.ket=c.cursor,c.out_grouping_b(u,97,248)?(c.bra=c.cursor,o=c.slice_to(o),c.limit_backward=e,c.eq_v_b(o)&&c.slice_del()):c.limit_backward=e),!0}},function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}),r.Pipeline.registerFunction(r.da.stemmer,"stemmer-da"),r.da.stopWordFilter=function(e){if(-1===r.da.stopWordFilter.stopWords.indexOf(e))return e},r.da.stopWordFilter.stopWords=new r.SortedSet,r.da.stopWordFilter.stopWords.length=95,r.da.stopWordFilter.stopWords.elements=" ad af alle alt anden at blev blive bliver da de dem den denne der deres det dette dig din disse dog du efter eller en end er et for fra ham han hans har havde have hende hendes her hos hun hvad hvis hvor i ikke ind jeg jer jo kunne man mange med meget men mig min mine mit mod ned noget nogle nu når og også om op os over på selv sig sin sine sit skal skulle som sådan thi til ud under var vi vil ville vor være været".split(" "),r.Pipeline.registerFunction(r.da.stopWordFilter,"stopWordFilter-da")}}); diff --git a/static/js/lunr/lunr.de.js b/static/js/lunr/lunr.de.js new file mode 100644 index 0000000..5cd9243 --- /dev/null +++ b/static/js/lunr/lunr.de.js @@ -0,0 +1,380 @@ +/*! + * Lunr languages, `German` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.de = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.de.trimmer, + lunr.de.stopWordFilter, + lunr.de.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.de.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.de.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.de.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.de.trimmer, 'trimmer-de'); + + /* lunr stemmer function */ + lunr.de.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function GermanStemmer() { + var a_0 = [new Among("", -1, 6), new Among("U", 0, 2), + new Among("Y", 0, 1), new Among("\u00E4", 0, 3), + new Among("\u00F6", 0, 4), new Among("\u00FC", 0, 5) + ], + a_1 = [ + new Among("e", -1, 2), new Among("em", -1, 1), + new Among("en", -1, 2), new Among("ern", -1, 1), + new Among("er", -1, 1), new Among("s", -1, 3), + new Among("es", 5, 2) + ], + a_2 = [new Among("en", -1, 1), + new Among("er", -1, 1), new Among("st", -1, 2), + new Among("est", 2, 1) + ], + a_3 = [new Among("ig", -1, 1), + new Among("lich", -1, 1) + ], + a_4 = [new Among("end", -1, 1), + new Among("ig", -1, 2), new Among("ung", -1, 1), + new Among("lich", -1, 3), new Among("isch", -1, 2), + new Among("ik", -1, 2), new Among("heit", -1, 3), + new Among("keit", -1, 4) + ], + g_v = [17, 65, 16, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 8, 0, 32, 8 + ], + g_s_ending = [117, 30, 5], + g_st_ending = [ + 117, 30, 4 + ], + I_x, I_p2, I_p1, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function habr1(c1, c2, v_1) { + if (sbp.eq_s(1, c1)) { + sbp.ket = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 252)) { + sbp.slice_from(c2); + sbp.cursor = v_1; + return true; + } + } + return false; + } + + function r_prelude() { + var v_1 = sbp.cursor, + v_2, v_3, v_4, v_5; + while (true) { + v_2 = sbp.cursor; + sbp.bra = v_2; + if (sbp.eq_s(1, "\u00DF")) { + sbp.ket = sbp.cursor; + sbp.slice_from("ss"); + } else { + if (v_2 >= sbp.limit) + break; + sbp.cursor = v_2 + 1; + } + } + sbp.cursor = v_1; + while (true) { + v_3 = sbp.cursor; + while (true) { + v_4 = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 252)) { + v_5 = sbp.cursor; + sbp.bra = v_5; + if (habr1("u", "U", v_4)) + break; + sbp.cursor = v_5; + if (habr1("y", "Y", v_4)) + break; + } + if (v_4 >= sbp.limit) { + sbp.cursor = v_3; + return; + } + sbp.cursor = v_4 + 1; + } + } + } + + function habr2() { + while (!sbp.in_grouping(g_v, 97, 252)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 252)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + return false; + } + + function r_mark_regions() { + I_p1 = sbp.limit; + I_p2 = I_p1; + var c = sbp.cursor + 3; + if (0 <= c && c <= sbp.limit) { + I_x = c; + if (!habr2()) { + I_p1 = sbp.cursor; + if (I_p1 < I_x) + I_p1 = I_x; + if (!habr2()) + I_p2 = sbp.cursor; + } + } + } + + function r_postlude() { + var among_var, v_1; + while (true) { + v_1 = sbp.cursor; + sbp.bra = v_1; + among_var = sbp.find_among(a_0, 6); + if (!among_var) + return; + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("y"); + break; + case 2: + case 5: + sbp.slice_from("u"); + break; + case 3: + sbp.slice_from("a"); + break; + case 4: + sbp.slice_from("o"); + break; + case 6: + if (sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + break; + } + } + } + + function r_R1() { + return I_p1 <= sbp.cursor; + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function r_standard_suffix() { + var among_var, v_1 = sbp.limit - sbp.cursor, + v_2, v_3, v_4; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_1, 7); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "s")) { + sbp.bra = sbp.cursor; + if (sbp.eq_s_b(3, "nis")) + sbp.slice_del(); + } + break; + case 3: + if (sbp.in_grouping_b(g_s_ending, 98, 116)) + sbp.slice_del(); + break; + } + } + } + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_2, 4); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + if (sbp.in_grouping_b(g_st_ending, 98, 116)) { + var c = sbp.cursor - 3; + if (sbp.limit_backward <= c && c <= sbp.limit) { + sbp.cursor = c; + sbp.slice_del(); + } + } + break; + } + } + } + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_4, 8); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R2()) { + switch (among_var) { + case 1: + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "ig")) { + sbp.bra = sbp.cursor; + v_2 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "e")) { + sbp.cursor = sbp.limit - v_2; + if (r_R2()) + sbp.slice_del(); + } + } + break; + case 2: + v_3 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "e")) { + sbp.cursor = sbp.limit - v_3; + sbp.slice_del(); + } + break; + case 3: + sbp.slice_del(); + sbp.ket = sbp.cursor; + v_4 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(2, "er")) { + sbp.cursor = sbp.limit - v_4; + if (!sbp.eq_s_b(2, "en")) + break; + } + sbp.bra = sbp.cursor; + if (r_R1()) + sbp.slice_del(); + break; + case 4: + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_3, 2); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R2() && among_var == 1) + sbp.slice_del(); + } + break; + } + } + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_prelude(); + sbp.cursor = v_1; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_standard_suffix(); + sbp.cursor = sbp.limit_backward; + r_postlude(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.de.stemmer, 'stemmer-de'); + + /* stop word filter function */ + lunr.de.stopWordFilter = function(token) { + if (lunr.de.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.de.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.de.stopWordFilter.stopWords.length = 232; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.de.stopWordFilter.stopWords.elements = ' aber alle allem allen aller alles als also am an ander andere anderem anderen anderer anderes anderm andern anderr anders auch auf aus bei bin bis bist da damit dann das dasselbe dazu daß dein deine deinem deinen deiner deines dem demselben den denn denselben der derer derselbe derselben des desselben dessen dich die dies diese dieselbe dieselben diesem diesen dieser dieses dir doch dort du durch ein eine einem einen einer eines einig einige einigem einigen einiger einiges einmal er es etwas euch euer eure eurem euren eurer eures für gegen gewesen hab habe haben hat hatte hatten hier hin hinter ich ihm ihn ihnen ihr ihre ihrem ihren ihrer ihres im in indem ins ist jede jedem jeden jeder jedes jene jenem jenen jener jenes jetzt kann kein keine keinem keinen keiner keines können könnte machen man manche manchem manchen mancher manches mein meine meinem meinen meiner meines mich mir mit muss musste nach nicht nichts noch nun nur ob oder ohne sehr sein seine seinem seinen seiner seines selbst sich sie sind so solche solchem solchen solcher solches soll sollte sondern sonst um und uns unse unsem unsen unser unses unter viel vom von vor war waren warst was weg weil weiter welche welchem welchen welcher welches wenn werde werden wie wieder will wir wird wirst wo wollen wollte während würde würden zu zum zur zwar zwischen über'.split(' '); + + lunr.Pipeline.registerFunction(lunr.de.stopWordFilter, 'stopWordFilter-de'); + }; +})) diff --git a/static/js/lunr/lunr.de.min.js b/static/js/lunr/lunr.de.min.js new file mode 100644 index 0000000..7d099c6 --- /dev/null +++ b/static/js/lunr/lunr.de.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,n,i;r.de=function(){this.pipeline.reset(),this.pipeline.add(r.de.trimmer,r.de.stopWordFilter,r.de.stemmer)},r.de.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.de.trimmer=r.trimmerSupport.generateTrimmer(r.de.wordCharacters),r.Pipeline.registerFunction(r.de.trimmer,"trimmer-de"),r.de.stemmer=(e=r.stemmerSupport.Among,n=r.stemmerSupport.SnowballProgram,i=new function(){var t,o,c,u=[new e("",-1,6),new e("U",0,2),new e("Y",0,1),new e("ä",0,3),new e("ö",0,4),new e("ü",0,5)],d=[new e("e",-1,2),new e("em",-1,1),new e("en",-1,2),new e("ern",-1,1),new e("er",-1,1),new e("s",-1,3),new e("es",5,2)],l=[new e("en",-1,1),new e("er",-1,1),new e("st",-1,2),new e("est",2,1)],a=[new e("ig",-1,1),new e("lich",-1,1)],m=[new e("end",-1,1),new e("ig",-1,2),new e("ung",-1,1),new e("lich",-1,3),new e("isch",-1,2),new e("ik",-1,2),new e("heit",-1,3),new e("keit",-1,4)],w=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32,8],h=[117,30,5],b=[117,30,4],f=new n;function _(e,r,n){return f.eq_s(1,e)&&(f.ket=f.cursor,f.in_grouping(w,97,252))&&(f.slice_from(r),f.cursor=n,1)}function p(){for(;!f.in_grouping(w,97,252);){if(f.cursor>=f.limit)return 1;f.cursor++}for(;!f.out_grouping(w,97,252);){if(f.cursor>=f.limit)return 1;f.cursor++}}function g(){return c<=f.cursor}function k(){return o<=f.cursor}this.setCurrent=function(e){f.setCurrent(e)},this.getCurrent=function(){return f.getCurrent()},this.stem=function(){var e=f.cursor;!function(){for(var e,r,n,i,s=f.cursor;;)if(e=f.cursor,f.bra=e,f.eq_s(1,"ß"))f.ket=f.cursor,f.slice_from("ss");else{if(e>=f.limit)break;f.cursor=e+1}for(f.cursor=s;;)for(r=f.cursor;;){if(n=f.cursor,f.in_grouping(w,97,252)){if(i=f.cursor,f.bra=i,_("u","U",n))break;if(f.cursor=i,_("y","Y",n))break}if(n>=f.limit)return f.cursor=r;f.cursor=n+1}}(),f.cursor=e,c=f.limit,o=c,0<=(s=f.cursor+3)&&s<=f.limit&&(t=s,p()||((c=f.cursor)=f.limit)return;f.cursor++}}}(),!0}},function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}),r.Pipeline.registerFunction(r.de.stemmer,"stemmer-de"),r.de.stopWordFilter=function(e){if(-1===r.de.stopWordFilter.stopWords.indexOf(e))return e},r.de.stopWordFilter.stopWords=new r.SortedSet,r.de.stopWordFilter.stopWords.length=232,r.de.stopWordFilter.stopWords.elements=" aber alle allem allen aller alles als also am an ander andere anderem anderen anderer anderes anderm andern anderr anders auch auf aus bei bin bis bist da damit dann das dasselbe dazu daß dein deine deinem deinen deiner deines dem demselben den denn denselben der derer derselbe derselben des desselben dessen dich die dies diese dieselbe dieselben diesem diesen dieser dieses dir doch dort du durch ein eine einem einen einer eines einig einige einigem einigen einiger einiges einmal er es etwas euch euer eure eurem euren eurer eures für gegen gewesen hab habe haben hat hatte hatten hier hin hinter ich ihm ihn ihnen ihr ihre ihrem ihren ihrer ihres im in indem ins ist jede jedem jeden jeder jedes jene jenem jenen jener jenes jetzt kann kein keine keinem keinen keiner keines können könnte machen man manche manchem manchen mancher manches mein meine meinem meinen meiner meines mich mir mit muss musste nach nicht nichts noch nun nur ob oder ohne sehr sein seine seinem seinen seiner seines selbst sich sie sind so solche solchem solchen solcher solches soll sollte sondern sonst um und uns unse unsem unsen unser unses unter viel vom von vor war waren warst was weg weil weiter welche welchem welchen welcher welches wenn werde werden wie wieder will wir wird wirst wo wollen wollte während würde würden zu zum zur zwar zwischen über".split(" "),r.Pipeline.registerFunction(r.de.stopWordFilter,"stopWordFilter-de")}}); diff --git a/static/js/lunr/lunr.du.js b/static/js/lunr/lunr.du.js new file mode 100644 index 0000000..cf4eda5 --- /dev/null +++ b/static/js/lunr/lunr.du.js @@ -0,0 +1,444 @@ +/*! + * Lunr languages, `Dutch` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.du = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.du.trimmer, + lunr.du.stopWordFilter, + lunr.du.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.du.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.du.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.du.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.du.trimmer, 'trimmer-du'); + + /* lunr stemmer function */ + lunr.du.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function DutchStemmer() { + var a_0 = [new Among("", -1, 6), new Among("\u00E1", 0, 1), + new Among("\u00E4", 0, 1), new Among("\u00E9", 0, 2), + new Among("\u00EB", 0, 2), new Among("\u00ED", 0, 3), + new Among("\u00EF", 0, 3), new Among("\u00F3", 0, 4), + new Among("\u00F6", 0, 4), new Among("\u00FA", 0, 5), + new Among("\u00FC", 0, 5) + ], + a_1 = [new Among("", -1, 3), + new Among("I", 0, 2), new Among("Y", 0, 1) + ], + a_2 = [ + new Among("dd", -1, -1), new Among("kk", -1, -1), + new Among("tt", -1, -1) + ], + a_3 = [new Among("ene", -1, 2), + new Among("se", -1, 3), new Among("en", -1, 2), + new Among("heden", 2, 1), new Among("s", -1, 3) + ], + a_4 = [ + new Among("end", -1, 1), new Among("ig", -1, 2), + new Among("ing", -1, 1), new Among("lijk", -1, 3), + new Among("baar", -1, 4), new Among("bar", -1, 5) + ], + a_5 = [ + new Among("aa", -1, -1), new Among("ee", -1, -1), + new Among("oo", -1, -1), new Among("uu", -1, -1) + ], + g_v = [17, 65, + 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128 + ], + g_v_I = [1, 0, 0, + 17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128 + ], + g_v_j = [ + 17, 67, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128 + ], + I_p2, I_p1, B_e_found, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function r_prelude() { + var among_var, v_1 = sbp.cursor, + v_2, v_3; + while (true) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among(a_0, 11); + if (among_var) { + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("a"); + continue; + case 2: + sbp.slice_from("e"); + continue; + case 3: + sbp.slice_from("i"); + continue; + case 4: + sbp.slice_from("o"); + continue; + case 5: + sbp.slice_from("u"); + continue; + case 6: + if (sbp.cursor >= sbp.limit) + break; + sbp.cursor++; + continue; + } + } + break; + } + sbp.cursor = v_1; + sbp.bra = v_1; + if (sbp.eq_s(1, "y")) { + sbp.ket = sbp.cursor; + sbp.slice_from("Y"); + } else + sbp.cursor = v_1; + while (true) { + v_2 = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 232)) { + v_3 = sbp.cursor; + sbp.bra = v_3; + if (sbp.eq_s(1, "i")) { + sbp.ket = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 232)) { + sbp.slice_from("I"); + sbp.cursor = v_2; + } + } else { + sbp.cursor = v_3; + if (sbp.eq_s(1, "y")) { + sbp.ket = sbp.cursor; + sbp.slice_from("Y"); + sbp.cursor = v_2; + } else if (habr1(v_2)) + break; + } + } else if (habr1(v_2)) + break; + } + } + + function habr1(v_1) { + sbp.cursor = v_1; + if (v_1 >= sbp.limit) + return true; + sbp.cursor++; + return false; + } + + function r_mark_regions() { + I_p1 = sbp.limit; + I_p2 = I_p1; + if (!habr2()) { + I_p1 = sbp.cursor; + if (I_p1 < 3) + I_p1 = 3; + if (!habr2()) + I_p2 = sbp.cursor; + } + } + + function habr2() { + while (!sbp.in_grouping(g_v, 97, 232)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 232)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + return false; + } + + function r_postlude() { + var among_var; + while (true) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among(a_1, 3); + if (among_var) { + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("y"); + break; + case 2: + sbp.slice_from("i"); + break; + case 3: + if (sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + break; + } + } + } + } + + function r_R1() { + return I_p1 <= sbp.cursor; + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function r_undouble() { + var v_1 = sbp.limit - sbp.cursor; + if (sbp.find_among_b(a_2, 3)) { + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + sbp.bra = sbp.cursor; + sbp.slice_del(); + } + } + } + + function r_e_ending() { + var v_1; + B_e_found = false; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "e")) { + sbp.bra = sbp.cursor; + if (r_R1()) { + v_1 = sbp.limit - sbp.cursor; + if (sbp.out_grouping_b(g_v, 97, 232)) { + sbp.cursor = sbp.limit - v_1; + sbp.slice_del(); + B_e_found = true; + r_undouble(); + } + } + } + } + + function r_en_ending() { + var v_1; + if (r_R1()) { + v_1 = sbp.limit - sbp.cursor; + if (sbp.out_grouping_b(g_v, 97, 232)) { + sbp.cursor = sbp.limit - v_1; + if (!sbp.eq_s_b(3, "gem")) { + sbp.cursor = sbp.limit - v_1; + sbp.slice_del(); + r_undouble(); + } + } + } + } + + function r_standard_suffix() { + var among_var, v_1 = sbp.limit - sbp.cursor, + v_2, v_3, v_4, v_5, v_6; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_3, 5); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (r_R1()) + sbp.slice_from("heid"); + break; + case 2: + r_en_ending(); + break; + case 3: + if (r_R1() && sbp.out_grouping_b(g_v_j, 97, 232)) + sbp.slice_del(); + break; + } + } + sbp.cursor = sbp.limit - v_1; + r_e_ending(); + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(4, "heid")) { + sbp.bra = sbp.cursor; + if (r_R2()) { + v_2 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "c")) { + sbp.cursor = sbp.limit - v_2; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "en")) { + sbp.bra = sbp.cursor; + r_en_ending(); + } + } + } + } + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_4, 6); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (r_R2()) { + sbp.slice_del(); + v_3 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "ig")) { + sbp.bra = sbp.cursor; + if (r_R2()) { + v_4 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "e")) { + sbp.cursor = sbp.limit - v_4; + sbp.slice_del(); + break; + } + } + } + sbp.cursor = sbp.limit - v_3; + r_undouble(); + } + break; + case 2: + if (r_R2()) { + v_5 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "e")) { + sbp.cursor = sbp.limit - v_5; + sbp.slice_del(); + } + } + break; + case 3: + if (r_R2()) { + sbp.slice_del(); + r_e_ending(); + } + break; + case 4: + if (r_R2()) + sbp.slice_del(); + break; + case 5: + if (r_R2() && B_e_found) + sbp.slice_del(); + break; + } + } + sbp.cursor = sbp.limit - v_1; + if (sbp.out_grouping_b(g_v_I, 73, 232)) { + v_6 = sbp.limit - sbp.cursor; + if (sbp.find_among_b(a_5, 4) && sbp.out_grouping_b(g_v, 97, 232)) { + sbp.cursor = sbp.limit - v_6; + sbp.ket = sbp.cursor; + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + sbp.bra = sbp.cursor; + sbp.slice_del(); + } + } + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_prelude(); + sbp.cursor = v_1; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_standard_suffix(); + sbp.cursor = sbp.limit_backward; + r_postlude(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.du.stemmer, 'stemmer-du'); + + /* stop word filter function */ + lunr.du.stopWordFilter = function(token) { + if (lunr.du.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.du.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.du.stopWordFilter.stopWords.length = 103; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.du.stopWordFilter.stopWords.elements = ' aan al alles als altijd andere ben bij daar dan dat de der deze die dit doch doen door dus een eens en er ge geen geweest haar had heb hebben heeft hem het hier hij hoe hun iemand iets ik in is ja je kan kon kunnen maar me meer men met mij mijn moet na naar niet niets nog nu of om omdat onder ons ook op over reeds te tegen toch toen tot u uit uw van veel voor want waren was wat werd wezen wie wil worden wordt zal ze zelf zich zij zijn zo zonder zou'.split(' '); + + lunr.Pipeline.registerFunction(lunr.du.stopWordFilter, 'stopWordFilter-du'); + }; +})) diff --git a/static/js/lunr/lunr.du.min.js b/static/js/lunr/lunr.du.min.js new file mode 100644 index 0000000..8ac0d07 --- /dev/null +++ b/static/js/lunr/lunr.du.min.js @@ -0,0 +1 @@ +!function(r,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():e()(r.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var r,i,o;e.du=function(){this.pipeline.reset(),this.pipeline.add(e.du.trimmer,e.du.stopWordFilter,e.du.stemmer)},e.du.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.du.trimmer=e.trimmerSupport.generateTrimmer(e.du.wordCharacters),e.Pipeline.registerFunction(e.du.trimmer,"trimmer-du"),e.du.stemmer=(r=e.stemmerSupport.Among,i=e.stemmerSupport.SnowballProgram,o=new function(){var c,a,l,m=[new r("",-1,6),new r("á",0,1),new r("ä",0,1),new r("é",0,2),new r("ë",0,2),new r("í",0,3),new r("ï",0,3),new r("ó",0,4),new r("ö",0,4),new r("ú",0,5),new r("ü",0,5)],d=[new r("",-1,3),new r("I",0,2),new r("Y",0,1)],e=[new r("dd",-1,-1),new r("kk",-1,-1),new r("tt",-1,-1)],f=[new r("ene",-1,2),new r("se",-1,3),new r("en",-1,2),new r("heden",2,1),new r("s",-1,3)],_=[new r("end",-1,1),new r("ig",-1,2),new r("ing",-1,1),new r("lijk",-1,3),new r("baar",-1,4),new r("bar",-1,5)],w=[new r("aa",-1,-1),new r("ee",-1,-1),new r("oo",-1,-1),new r("uu",-1,-1)],b=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],p=[1,0,0,17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],g=[17,67,16,1,0,0,0,0,0,0,0,0,0,0,0,0,128],k=new i;function h(r){if((k.cursor=r)>=k.limit)return 1;k.cursor++}function v(){for(;!k.in_grouping(b,97,232);){if(k.cursor>=k.limit)return 1;k.cursor++}for(;!k.out_grouping(b,97,232);){if(k.cursor>=k.limit)return 1;k.cursor++}}function q(){return a<=k.cursor}function z(){return c<=k.cursor}function W(){var r=k.limit-k.cursor;k.find_among_b(e,3)&&(k.cursor=k.limit-r,k.ket=k.cursor,k.cursor>k.limit_backward)&&(k.cursor--,k.bra=k.cursor,k.slice_del())}function j(){var r;l=!1,k.ket=k.cursor,k.eq_s_b(1,"e")&&(k.bra=k.cursor,q())&&(r=k.limit-k.cursor,k.out_grouping_b(b,97,232))&&(k.cursor=k.limit-r,k.slice_del(),l=!0,W())}function F(){var r;q()&&(r=k.limit-k.cursor,k.out_grouping_b(b,97,232))&&(k.cursor=k.limit-r,k.eq_s_b(3,"gem")||(k.cursor=k.limit-r,k.slice_del(),W()))}this.setCurrent=function(r){k.setCurrent(r)},this.getCurrent=function(){return k.getCurrent()},this.stem=function(){for(var r,e,i,o=k.cursor,t=k.cursor;;){if(k.bra=k.cursor,r=k.find_among(m,11))switch(k.ket=k.cursor,r){case 1:k.slice_from("a");continue;case 2:k.slice_from("e");continue;case 3:k.slice_from("i");continue;case 4:k.slice_from("o");continue;case 5:k.slice_from("u");continue;case 6:if(!(k.cursor>=k.limit)){k.cursor++;continue}}break}for(k.cursor=t,k.bra=t,k.eq_s(1,"y")?(k.ket=k.cursor,k.slice_from("Y")):k.cursor=t;;)if(e=k.cursor,k.in_grouping(b,97,232)){if(i=k.cursor,k.bra=i,k.eq_s(1,"i"))k.ket=k.cursor,k.in_grouping(b,97,232)&&(k.slice_from("I"),k.cursor=e);else if(k.cursor=i,k.eq_s(1,"y"))k.ket=k.cursor,k.slice_from("Y"),k.cursor=e;else if(h(e))break}else if(h(e))break;k.cursor=o,a=k.limit,c=a,v()||((a=k.cursor)<3&&(a=3),v())||(c=k.cursor),k.limit_backward=o,k.cursor=k.limit;var s,n,u,t=k.limit-k.cursor;if(k.ket=k.cursor,o=k.find_among_b(f,5))switch(k.bra=k.cursor,o){case 1:q()&&k.slice_from("heid");break;case 2:F();break;case 3:q()&&k.out_grouping_b(g,97,232)&&k.slice_del()}if(k.cursor=k.limit-t,j(),k.cursor=k.limit-t,k.ket=k.cursor,k.eq_s_b(4,"heid")&&(k.bra=k.cursor,z())&&(u=k.limit-k.cursor,k.eq_s_b(1,"c")||(k.cursor=k.limit-u,k.slice_del(),k.ket=k.cursor,k.eq_s_b(2,"en")&&(k.bra=k.cursor,F()))),k.cursor=k.limit-t,k.ket=k.cursor,o=k.find_among_b(_,6))switch(k.bra=k.cursor,o){case 1:if(z()){if(k.slice_del(),s=k.limit-k.cursor,k.ket=k.cursor,k.eq_s_b(2,"ig")&&(k.bra=k.cursor,z())&&(n=k.limit-k.cursor,!k.eq_s_b(1,"e"))){k.cursor=k.limit-n,k.slice_del();break}k.cursor=k.limit-s,W()}break;case 2:z()&&(n=k.limit-k.cursor,k.eq_s_b(1,"e")||(k.cursor=k.limit-n,k.slice_del()));break;case 3:z()&&(k.slice_del(),j());break;case 4:z()&&k.slice_del();break;case 5:z()&&l&&k.slice_del()}return k.cursor=k.limit-t,k.out_grouping_b(p,73,232)&&(u=k.limit-k.cursor,k.find_among_b(w,4))&&k.out_grouping_b(b,97,232)&&(k.cursor=k.limit-u,k.ket=k.cursor,k.cursor>k.limit_backward)&&(k.cursor--,k.bra=k.cursor,k.slice_del()),k.cursor=k.limit_backward,function(){for(var r;;)if(k.bra=k.cursor,r=k.find_among(d,3))switch(k.ket=k.cursor,r){case 1:k.slice_from("y");break;case 2:k.slice_from("i");break;case 3:if(k.cursor>=k.limit)return;k.cursor++}}(),!0}},function(r){return o.setCurrent(r),o.stem(),o.getCurrent()}),e.Pipeline.registerFunction(e.du.stemmer,"stemmer-du"),e.du.stopWordFilter=function(r){if(-1===e.du.stopWordFilter.stopWords.indexOf(r))return r},e.du.stopWordFilter.stopWords=new e.SortedSet,e.du.stopWordFilter.stopWords.length=103,e.du.stopWordFilter.stopWords.elements=" aan al alles als altijd andere ben bij daar dan dat de der deze die dit doch doen door dus een eens en er ge geen geweest haar had heb hebben heeft hem het hier hij hoe hun iemand iets ik in is ja je kan kon kunnen maar me meer men met mij mijn moet na naar niet niets nog nu of om omdat onder ons ook op over reeds te tegen toch toen tot u uit uw van veel voor want waren was wat werd wezen wie wil worden wordt zal ze zelf zich zij zijn zo zonder zou".split(" "),e.Pipeline.registerFunction(e.du.stopWordFilter,"stopWordFilter-du")}}); diff --git a/static/js/lunr/lunr.es.js b/static/js/lunr/lunr.es.js new file mode 100644 index 0000000..aa43b27 --- /dev/null +++ b/static/js/lunr/lunr.es.js @@ -0,0 +1,595 @@ +/*! + * Lunr languages, `Spanish` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.es = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.es.trimmer, + lunr.es.stopWordFilter, + lunr.es.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.es.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.es.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.es.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.es.trimmer, 'trimmer-es'); + + /* lunr stemmer function */ + lunr.es.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function SpanishStemmer() { + var a_0 = [new Among("", -1, 6), new Among("\u00E1", 0, 1), + new Among("\u00E9", 0, 2), new Among("\u00ED", 0, 3), + new Among("\u00F3", 0, 4), new Among("\u00FA", 0, 5) + ], + a_1 = [ + new Among("la", -1, -1), new Among("sela", 0, -1), + new Among("le", -1, -1), new Among("me", -1, -1), + new Among("se", -1, -1), new Among("lo", -1, -1), + new Among("selo", 5, -1), new Among("las", -1, -1), + new Among("selas", 7, -1), new Among("les", -1, -1), + new Among("los", -1, -1), new Among("selos", 10, -1), + new Among("nos", -1, -1) + ], + a_2 = [new Among("ando", -1, 6), + new Among("iendo", -1, 6), new Among("yendo", -1, 7), + new Among("\u00E1ndo", -1, 2), new Among("i\u00E9ndo", -1, 1), + new Among("ar", -1, 6), new Among("er", -1, 6), + new Among("ir", -1, 6), new Among("\u00E1r", -1, 3), + new Among("\u00E9r", -1, 4), new Among("\u00EDr", -1, 5) + ], + a_3 = [ + new Among("ic", -1, -1), new Among("ad", -1, -1), + new Among("os", -1, -1), new Among("iv", -1, 1) + ], + a_4 = [ + new Among("able", -1, 1), new Among("ible", -1, 1), + new Among("ante", -1, 1) + ], + a_5 = [new Among("ic", -1, 1), + new Among("abil", -1, 1), new Among("iv", -1, 1) + ], + a_6 = [ + new Among("ica", -1, 1), new Among("ancia", -1, 2), + new Among("encia", -1, 5), new Among("adora", -1, 2), + new Among("osa", -1, 1), new Among("ista", -1, 1), + new Among("iva", -1, 9), new Among("anza", -1, 1), + new Among("log\u00EDa", -1, 3), new Among("idad", -1, 8), + new Among("able", -1, 1), new Among("ible", -1, 1), + new Among("ante", -1, 2), new Among("mente", -1, 7), + new Among("amente", 13, 6), new Among("aci\u00F3n", -1, 2), + new Among("uci\u00F3n", -1, 4), new Among("ico", -1, 1), + new Among("ismo", -1, 1), new Among("oso", -1, 1), + new Among("amiento", -1, 1), new Among("imiento", -1, 1), + new Among("ivo", -1, 9), new Among("ador", -1, 2), + new Among("icas", -1, 1), new Among("ancias", -1, 2), + new Among("encias", -1, 5), new Among("adoras", -1, 2), + new Among("osas", -1, 1), new Among("istas", -1, 1), + new Among("ivas", -1, 9), new Among("anzas", -1, 1), + new Among("log\u00EDas", -1, 3), new Among("idades", -1, 8), + new Among("ables", -1, 1), new Among("ibles", -1, 1), + new Among("aciones", -1, 2), new Among("uciones", -1, 4), + new Among("adores", -1, 2), new Among("antes", -1, 2), + new Among("icos", -1, 1), new Among("ismos", -1, 1), + new Among("osos", -1, 1), new Among("amientos", -1, 1), + new Among("imientos", -1, 1), new Among("ivos", -1, 9) + ], + a_7 = [ + new Among("ya", -1, 1), new Among("ye", -1, 1), + new Among("yan", -1, 1), new Among("yen", -1, 1), + new Among("yeron", -1, 1), new Among("yendo", -1, 1), + new Among("yo", -1, 1), new Among("yas", -1, 1), + new Among("yes", -1, 1), new Among("yais", -1, 1), + new Among("yamos", -1, 1), new Among("y\u00F3", -1, 1) + ], + a_8 = [ + new Among("aba", -1, 2), new Among("ada", -1, 2), + new Among("ida", -1, 2), new Among("ara", -1, 2), + new Among("iera", -1, 2), new Among("\u00EDa", -1, 2), + new Among("ar\u00EDa", 5, 2), new Among("er\u00EDa", 5, 2), + new Among("ir\u00EDa", 5, 2), new Among("ad", -1, 2), + new Among("ed", -1, 2), new Among("id", -1, 2), + new Among("ase", -1, 2), new Among("iese", -1, 2), + new Among("aste", -1, 2), new Among("iste", -1, 2), + new Among("an", -1, 2), new Among("aban", 16, 2), + new Among("aran", 16, 2), new Among("ieran", 16, 2), + new Among("\u00EDan", 16, 2), new Among("ar\u00EDan", 20, 2), + new Among("er\u00EDan", 20, 2), new Among("ir\u00EDan", 20, 2), + new Among("en", -1, 1), new Among("asen", 24, 2), + new Among("iesen", 24, 2), new Among("aron", -1, 2), + new Among("ieron", -1, 2), new Among("ar\u00E1n", -1, 2), + new Among("er\u00E1n", -1, 2), new Among("ir\u00E1n", -1, 2), + new Among("ado", -1, 2), new Among("ido", -1, 2), + new Among("ando", -1, 2), new Among("iendo", -1, 2), + new Among("ar", -1, 2), new Among("er", -1, 2), + new Among("ir", -1, 2), new Among("as", -1, 2), + new Among("abas", 39, 2), new Among("adas", 39, 2), + new Among("idas", 39, 2), new Among("aras", 39, 2), + new Among("ieras", 39, 2), new Among("\u00EDas", 39, 2), + new Among("ar\u00EDas", 45, 2), new Among("er\u00EDas", 45, 2), + new Among("ir\u00EDas", 45, 2), new Among("es", -1, 1), + new Among("ases", 49, 2), new Among("ieses", 49, 2), + new Among("abais", -1, 2), new Among("arais", -1, 2), + new Among("ierais", -1, 2), new Among("\u00EDais", -1, 2), + new Among("ar\u00EDais", 55, 2), new Among("er\u00EDais", 55, 2), + new Among("ir\u00EDais", 55, 2), new Among("aseis", -1, 2), + new Among("ieseis", -1, 2), new Among("asteis", -1, 2), + new Among("isteis", -1, 2), new Among("\u00E1is", -1, 2), + new Among("\u00E9is", -1, 1), new Among("ar\u00E9is", 64, 2), + new Among("er\u00E9is", 64, 2), new Among("ir\u00E9is", 64, 2), + new Among("ados", -1, 2), new Among("idos", -1, 2), + new Among("amos", -1, 2), new Among("\u00E1bamos", 70, 2), + new Among("\u00E1ramos", 70, 2), new Among("i\u00E9ramos", 70, 2), + new Among("\u00EDamos", 70, 2), new Among("ar\u00EDamos", 74, 2), + new Among("er\u00EDamos", 74, 2), new Among("ir\u00EDamos", 74, 2), + new Among("emos", -1, 1), new Among("aremos", 78, 2), + new Among("eremos", 78, 2), new Among("iremos", 78, 2), + new Among("\u00E1semos", 78, 2), new Among("i\u00E9semos", 78, 2), + new Among("imos", -1, 2), new Among("ar\u00E1s", -1, 2), + new Among("er\u00E1s", -1, 2), new Among("ir\u00E1s", -1, 2), + new Among("\u00EDs", -1, 2), new Among("ar\u00E1", -1, 2), + new Among("er\u00E1", -1, 2), new Among("ir\u00E1", -1, 2), + new Among("ar\u00E9", -1, 2), new Among("er\u00E9", -1, 2), + new Among("ir\u00E9", -1, 2), new Among("i\u00F3", -1, 2) + ], + a_9 = [ + new Among("a", -1, 1), new Among("e", -1, 2), + new Among("o", -1, 1), new Among("os", -1, 1), + new Among("\u00E1", -1, 1), new Among("\u00E9", -1, 2), + new Among("\u00ED", -1, 1), new Among("\u00F3", -1, 1) + ], + g_v = [17, + 65, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17, 4, 10 + ], + I_p2, I_p1, I_pV, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function habr1() { + if (sbp.out_grouping(g_v, 97, 252)) { + while (!sbp.in_grouping(g_v, 97, 252)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + return false; + } + return true; + } + + function habr2() { + if (sbp.in_grouping(g_v, 97, 252)) { + var v_1 = sbp.cursor; + if (habr1()) { + sbp.cursor = v_1; + if (!sbp.in_grouping(g_v, 97, 252)) + return true; + while (!sbp.out_grouping(g_v, 97, 252)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + } + return false; + } + return true; + } + + function habr3() { + var v_1 = sbp.cursor, + v_2; + if (habr2()) { + sbp.cursor = v_1; + if (!sbp.out_grouping(g_v, 97, 252)) + return; + v_2 = sbp.cursor; + if (habr1()) { + sbp.cursor = v_2; + if (!sbp.in_grouping(g_v, 97, 252) || sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + } + } + I_pV = sbp.cursor; + } + + function habr4() { + while (!sbp.in_grouping(g_v, 97, 252)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 252)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + return true; + } + + function r_mark_regions() { + var v_1 = sbp.cursor; + I_pV = sbp.limit; + I_p1 = I_pV; + I_p2 = I_pV; + habr3(); + sbp.cursor = v_1; + if (habr4()) { + I_p1 = sbp.cursor; + if (habr4()) + I_p2 = sbp.cursor; + } + } + + function r_postlude() { + var among_var; + while (true) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among(a_0, 6); + if (among_var) { + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("a"); + continue; + case 2: + sbp.slice_from("e"); + continue; + case 3: + sbp.slice_from("i"); + continue; + case 4: + sbp.slice_from("o"); + continue; + case 5: + sbp.slice_from("u"); + continue; + case 6: + if (sbp.cursor >= sbp.limit) + break; + sbp.cursor++; + continue; + } + } + break; + } + } + + function r_RV() { + return I_pV <= sbp.cursor; + } + + function r_R1() { + return I_p1 <= sbp.cursor; + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function r_attached_pronoun() { + var among_var; + sbp.ket = sbp.cursor; + if (sbp.find_among_b(a_1, 13)) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among_b(a_2, 11); + if (among_var && r_RV()) + switch (among_var) { + case 1: + sbp.bra = sbp.cursor; + sbp.slice_from("iendo"); + break; + case 2: + sbp.bra = sbp.cursor; + sbp.slice_from("ando"); + break; + case 3: + sbp.bra = sbp.cursor; + sbp.slice_from("ar"); + break; + case 4: + sbp.bra = sbp.cursor; + sbp.slice_from("er"); + break; + case 5: + sbp.bra = sbp.cursor; + sbp.slice_from("ir"); + break; + case 6: + sbp.slice_del(); + break; + case 7: + if (sbp.eq_s_b(1, "u")) + sbp.slice_del(); + break; + } + } + } + + function habr5(a, n) { + if (!r_R2()) + return true; + sbp.slice_del(); + sbp.ket = sbp.cursor; + var among_var = sbp.find_among_b(a, n); + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1 && r_R2()) + sbp.slice_del(); + } + return false; + } + + function habr6(c1) { + if (!r_R2()) + return true; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, c1)) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + } + return false; + } + + function r_standard_suffix() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_6, 46); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (!r_R2()) + return false; + sbp.slice_del(); + break; + case 2: + if (habr6("ic")) + return false; + break; + case 3: + if (!r_R2()) + return false; + sbp.slice_from("log"); + break; + case 4: + if (!r_R2()) + return false; + sbp.slice_from("u"); + break; + case 5: + if (!r_R2()) + return false; + sbp.slice_from("ente"); + break; + case 6: + if (!r_R1()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_3, 4); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R2()) { + sbp.slice_del(); + if (among_var == 1) { + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "at")) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + } + } + } + } + break; + case 7: + if (habr5(a_4, 3)) + return false; + break; + case 8: + if (habr5(a_5, 3)) + return false; + break; + case 9: + if (habr6("at")) + return false; + break; + } + return true; + } + return false; + } + + function r_y_verb_suffix() { + var among_var, v_1; + if (sbp.cursor >= I_pV) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_pV; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_7, 12); + sbp.limit_backward = v_1; + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1) { + if (!sbp.eq_s_b(1, "u")) + return false; + sbp.slice_del(); + } + return true; + } + } + return false; + } + + function r_verb_suffix() { + var among_var, v_1, v_2, v_3; + if (sbp.cursor >= I_pV) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_pV; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_8, 96); + sbp.limit_backward = v_1; + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + v_2 = sbp.limit - sbp.cursor; + if (sbp.eq_s_b(1, "u")) { + v_3 = sbp.limit - sbp.cursor; + if (sbp.eq_s_b(1, "g")) + sbp.cursor = sbp.limit - v_3; + else + sbp.cursor = sbp.limit - v_2; + } else + sbp.cursor = sbp.limit - v_2; + sbp.bra = sbp.cursor; + case 2: + sbp.slice_del(); + break; + } + } + } + } + + function r_residual_suffix() { + var among_var, v_1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_9, 8); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (r_RV()) + sbp.slice_del(); + break; + case 2: + if (r_RV()) { + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "u")) { + sbp.bra = sbp.cursor; + v_1 = sbp.limit - sbp.cursor; + if (sbp.eq_s_b(1, "g")) { + sbp.cursor = sbp.limit - v_1; + if (r_RV()) + sbp.slice_del(); + } + } + } + break; + } + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_attached_pronoun(); + sbp.cursor = sbp.limit; + if (!r_standard_suffix()) { + sbp.cursor = sbp.limit; + if (!r_y_verb_suffix()) { + sbp.cursor = sbp.limit; + r_verb_suffix(); + } + } + sbp.cursor = sbp.limit; + r_residual_suffix(); + sbp.cursor = sbp.limit_backward; + r_postlude(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.es.stemmer, 'stemmer-es'); + + /* stop word filter function */ + lunr.es.stopWordFilter = function(token) { + if (lunr.es.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.es.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.es.stopWordFilter.stopWords.length = 309; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.es.stopWordFilter.stopWords.elements = ' a al algo algunas algunos ante antes como con contra cual cuando de del desde donde durante e el ella ellas ellos en entre era erais eran eras eres es esa esas ese eso esos esta estaba estabais estaban estabas estad estada estadas estado estados estamos estando estar estaremos estará estarán estarás estaré estaréis estaría estaríais estaríamos estarían estarías estas este estemos esto estos estoy estuve estuviera estuvierais estuvieran estuvieras estuvieron estuviese estuvieseis estuviesen estuvieses estuvimos estuviste estuvisteis estuviéramos estuviésemos estuvo está estábamos estáis están estás esté estéis estén estés fue fuera fuerais fueran fueras fueron fuese fueseis fuesen fueses fui fuimos fuiste fuisteis fuéramos fuésemos ha habida habidas habido habidos habiendo habremos habrá habrán habrás habré habréis habría habríais habríamos habrían habrías habéis había habíais habíamos habían habías han has hasta hay haya hayamos hayan hayas hayáis he hemos hube hubiera hubierais hubieran hubieras hubieron hubiese hubieseis hubiesen hubieses hubimos hubiste hubisteis hubiéramos hubiésemos hubo la las le les lo los me mi mis mucho muchos muy más mí mía mías mío míos nada ni no nos nosotras nosotros nuestra nuestras nuestro nuestros o os otra otras otro otros para pero poco por porque que quien quienes qué se sea seamos sean seas seremos será serán serás seré seréis sería seríais seríamos serían serías seáis sido siendo sin sobre sois somos son soy su sus suya suyas suyo suyos sí también tanto te tendremos tendrá tendrán tendrás tendré tendréis tendría tendríais tendríamos tendrían tendrías tened tenemos tenga tengamos tengan tengas tengo tengáis tenida tenidas tenido tenidos teniendo tenéis tenía teníais teníamos tenían tenías ti tiene tienen tienes todo todos tu tus tuve tuviera tuvierais tuvieran tuvieras tuvieron tuviese tuvieseis tuviesen tuvieses tuvimos tuviste tuvisteis tuviéramos tuviésemos tuvo tuya tuyas tuyo tuyos tú un una uno unos vosotras vosotros vuestra vuestras vuestro vuestros y ya yo él éramos'.split(' '); + + lunr.Pipeline.registerFunction(lunr.es.stopWordFilter, 'stopWordFilter-es'); + }; +})) diff --git a/static/js/lunr/lunr.es.min.js b/static/js/lunr/lunr.es.min.js new file mode 100644 index 0000000..dc48558 --- /dev/null +++ b/static/js/lunr/lunr.es.min.js @@ -0,0 +1 @@ +!function(e,s){"function"==typeof define&&define.amd?define(s):"object"==typeof exports?module.exports=s():s()(e.lunr)}(this,function(){return function(s){if(void 0===s)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===s.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,r,n;s.es=function(){this.pipeline.reset(),this.pipeline.add(s.es.trimmer,s.es.stopWordFilter,s.es.stemmer)},s.es.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",s.es.trimmer=s.trimmerSupport.generateTrimmer(s.es.wordCharacters),s.Pipeline.registerFunction(s.es.trimmer,"trimmer-es"),s.es.stemmer=(e=s.stemmerSupport.Among,r=s.stemmerSupport.SnowballProgram,n=new function(){var u,w,c,m=[new e("",-1,6),new e("á",0,1),new e("é",0,2),new e("í",0,3),new e("ó",0,4),new e("ú",0,5)],l=[new e("la",-1,-1),new e("sela",0,-1),new e("le",-1,-1),new e("me",-1,-1),new e("se",-1,-1),new e("lo",-1,-1),new e("selo",5,-1),new e("las",-1,-1),new e("selas",7,-1),new e("les",-1,-1),new e("los",-1,-1),new e("selos",10,-1),new e("nos",-1,-1)],d=[new e("ando",-1,6),new e("iendo",-1,6),new e("yendo",-1,7),new e("ándo",-1,2),new e("iéndo",-1,1),new e("ar",-1,6),new e("er",-1,6),new e("ir",-1,6),new e("ár",-1,3),new e("ér",-1,4),new e("ír",-1,5)],b=[new e("ic",-1,-1),new e("ad",-1,-1),new e("os",-1,-1),new e("iv",-1,1)],f=[new e("able",-1,1),new e("ible",-1,1),new e("ante",-1,1)],_=[new e("ic",-1,1),new e("abil",-1,1),new e("iv",-1,1)],h=[new e("ica",-1,1),new e("ancia",-1,2),new e("encia",-1,5),new e("adora",-1,2),new e("osa",-1,1),new e("ista",-1,1),new e("iva",-1,9),new e("anza",-1,1),new e("logía",-1,3),new e("idad",-1,8),new e("able",-1,1),new e("ible",-1,1),new e("ante",-1,2),new e("mente",-1,7),new e("amente",13,6),new e("ación",-1,2),new e("ución",-1,4),new e("ico",-1,1),new e("ismo",-1,1),new e("oso",-1,1),new e("amiento",-1,1),new e("imiento",-1,1),new e("ivo",-1,9),new e("ador",-1,2),new e("icas",-1,1),new e("ancias",-1,2),new e("encias",-1,5),new e("adoras",-1,2),new e("osas",-1,1),new e("istas",-1,1),new e("ivas",-1,9),new e("anzas",-1,1),new e("logías",-1,3),new e("idades",-1,8),new e("ables",-1,1),new e("ibles",-1,1),new e("aciones",-1,2),new e("uciones",-1,4),new e("adores",-1,2),new e("antes",-1,2),new e("icos",-1,1),new e("ismos",-1,1),new e("osos",-1,1),new e("amientos",-1,1),new e("imientos",-1,1),new e("ivos",-1,9)],p=[new e("ya",-1,1),new e("ye",-1,1),new e("yan",-1,1),new e("yen",-1,1),new e("yeron",-1,1),new e("yendo",-1,1),new e("yo",-1,1),new e("yas",-1,1),new e("yes",-1,1),new e("yais",-1,1),new e("yamos",-1,1),new e("yó",-1,1)],v=[new e("aba",-1,2),new e("ada",-1,2),new e("ida",-1,2),new e("ara",-1,2),new e("iera",-1,2),new e("ía",-1,2),new e("aría",5,2),new e("ería",5,2),new e("iría",5,2),new e("ad",-1,2),new e("ed",-1,2),new e("id",-1,2),new e("ase",-1,2),new e("iese",-1,2),new e("aste",-1,2),new e("iste",-1,2),new e("an",-1,2),new e("aban",16,2),new e("aran",16,2),new e("ieran",16,2),new e("ían",16,2),new e("arían",20,2),new e("erían",20,2),new e("irían",20,2),new e("en",-1,1),new e("asen",24,2),new e("iesen",24,2),new e("aron",-1,2),new e("ieron",-1,2),new e("arán",-1,2),new e("erán",-1,2),new e("irán",-1,2),new e("ado",-1,2),new e("ido",-1,2),new e("ando",-1,2),new e("iendo",-1,2),new e("ar",-1,2),new e("er",-1,2),new e("ir",-1,2),new e("as",-1,2),new e("abas",39,2),new e("adas",39,2),new e("idas",39,2),new e("aras",39,2),new e("ieras",39,2),new e("ías",39,2),new e("arías",45,2),new e("erías",45,2),new e("irías",45,2),new e("es",-1,1),new e("ases",49,2),new e("ieses",49,2),new e("abais",-1,2),new e("arais",-1,2),new e("ierais",-1,2),new e("íais",-1,2),new e("aríais",55,2),new e("eríais",55,2),new e("iríais",55,2),new e("aseis",-1,2),new e("ieseis",-1,2),new e("asteis",-1,2),new e("isteis",-1,2),new e("áis",-1,2),new e("éis",-1,1),new e("aréis",64,2),new e("eréis",64,2),new e("iréis",64,2),new e("ados",-1,2),new e("idos",-1,2),new e("amos",-1,2),new e("ábamos",70,2),new e("áramos",70,2),new e("iéramos",70,2),new e("íamos",70,2),new e("aríamos",74,2),new e("eríamos",74,2),new e("iríamos",74,2),new e("emos",-1,1),new e("aremos",78,2),new e("eremos",78,2),new e("iremos",78,2),new e("ásemos",78,2),new e("iésemos",78,2),new e("imos",-1,2),new e("arás",-1,2),new e("erás",-1,2),new e("irás",-1,2),new e("ís",-1,2),new e("ará",-1,2),new e("erá",-1,2),new e("irá",-1,2),new e("aré",-1,2),new e("eré",-1,2),new e("iré",-1,2),new e("ió",-1,2)],g=[new e("a",-1,1),new e("e",-1,2),new e("o",-1,1),new e("os",-1,1),new e("á",-1,1),new e("é",-1,2),new e("í",-1,1),new e("ó",-1,1)],k=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,1,17,4,10],y=new r;function q(){if(!y.out_grouping(k,97,252))return 1;for(;!y.in_grouping(k,97,252);){if(y.cursor>=y.limit)return 1;y.cursor++}}function W(){for(;!y.in_grouping(k,97,252);){if(y.cursor>=y.limit)return;y.cursor++}for(;!y.out_grouping(k,97,252);){if(y.cursor>=y.limit)return;y.cursor++}return 1}function F(){return c<=y.cursor}function C(){return u<=y.cursor}function S(e,s){if(!C())return 1;y.slice_del(),y.ket=y.cursor,(e=y.find_among_b(e,s))&&(y.bra=y.cursor,1==e)&&C()&&y.slice_del()}function P(e){if(!C())return 1;y.slice_del(),y.ket=y.cursor,y.eq_s_b(2,e)&&(y.bra=y.cursor,C())&&y.slice_del()}this.setCurrent=function(e){y.setCurrent(e)},this.getCurrent=function(){return y.getCurrent()},this.stem=function(){var e,s,r,n,i,a,o=y.cursor,t=y.cursor;if(c=y.limit,u=w=c,function(){var e=y.cursor;if(function(){if(!y.in_grouping(k,97,252))return 1;var e=y.cursor;if(q()){if(y.cursor=e,!y.in_grouping(k,97,252))return 1;for(;!y.out_grouping(k,97,252);){if(y.cursor>=y.limit)return 1;y.cursor++}}}()){if(y.cursor=e,!y.out_grouping(k,97,252))return;if(e=y.cursor,q()){if(y.cursor=e,!y.in_grouping(k,97,252)||y.cursor>=y.limit)return;y.cursor++}}c=y.cursor}(),y.cursor=t,W()&&(w=y.cursor,W())&&(u=y.cursor),y.limit_backward=o,y.cursor=y.limit,y.ket=y.cursor,y.find_among_b(l,13)&&(y.bra=y.cursor,e=y.find_among_b(d,11))&&F())switch(e){case 1:y.bra=y.cursor,y.slice_from("iendo");break;case 2:y.bra=y.cursor,y.slice_from("ando");break;case 3:y.bra=y.cursor,y.slice_from("ar");break;case 4:y.bra=y.cursor,y.slice_from("er");break;case 5:y.bra=y.cursor,y.slice_from("ir");break;case 6:y.slice_del();break;case 7:y.eq_s_b(1,"u")&&y.slice_del()}if(y.cursor=y.limit,!function(){var e;if(y.ket=y.cursor,e=y.find_among_b(h,46)){switch(y.bra=y.cursor,e){case 1:if(!C())return;y.slice_del();break;case 2:if(P("ic"))return;break;case 3:if(!C())return;y.slice_from("log");break;case 4:if(!C())return;y.slice_from("u");break;case 5:if(!C())return;y.slice_from("ente");break;case 6:if(!(w<=y.cursor))return;y.slice_del(),y.ket=y.cursor,(e=y.find_among_b(b,4))&&(y.bra=y.cursor,C())&&(y.slice_del(),1==e)&&(y.ket=y.cursor,y.eq_s_b(2,"at"))&&(y.bra=y.cursor,C())&&y.slice_del();break;case 7:if(S(f,3))return;break;case 8:if(S(_,3))return;break;case 9:if(P("at"))return}return 1}}()&&(y.cursor=y.limit,!function(){var e,s;if(y.cursor>=c&&(s=y.limit_backward,y.limit_backward=c,y.ket=y.cursor,e=y.find_among_b(p,12),y.limit_backward=s,e)){if(y.bra=y.cursor,1==e){if(!y.eq_s_b(1,"u"))return;y.slice_del()}return 1}}())&&(y.cursor=y.limit,y.cursor>=c)&&(t=y.limit_backward,y.limit_backward=c,y.ket=y.cursor,s=y.find_among_b(v,96),y.limit_backward=t,s))switch(y.bra=y.cursor,s){case 1:r=y.limit-y.cursor,y.eq_s_b(1,"u")&&(n=y.limit-y.cursor,y.eq_s_b(1,"g"))?y.cursor=y.limit-n:y.cursor=y.limit-r,y.bra=y.cursor;case 2:y.slice_del()}if(y.cursor=y.limit,y.ket=y.cursor,o=y.find_among_b(g,8))switch(y.bra=y.cursor,o){case 1:F()&&y.slice_del();break;case 2:F()&&(y.slice_del(),y.ket=y.cursor,y.eq_s_b(1,"u"))&&(y.bra=y.cursor,i=y.limit-y.cursor,y.eq_s_b(1,"g"))&&(y.cursor=y.limit-i,F())&&y.slice_del()}for(y.cursor=y.limit_backward;;){if(y.bra=y.cursor,a=y.find_among(m,6))switch(y.ket=y.cursor,a){case 1:y.slice_from("a");continue;case 2:y.slice_from("e");continue;case 3:y.slice_from("i");continue;case 4:y.slice_from("o");continue;case 5:y.slice_from("u");continue;case 6:if(!(y.cursor>=y.limit)){y.cursor++;continue}}break}return!0}},function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}),s.Pipeline.registerFunction(s.es.stemmer,"stemmer-es"),s.es.stopWordFilter=function(e){if(-1===s.es.stopWordFilter.stopWords.indexOf(e))return e},s.es.stopWordFilter.stopWords=new s.SortedSet,s.es.stopWordFilter.stopWords.length=309,s.es.stopWordFilter.stopWords.elements=" a al algo algunas algunos ante antes como con contra cual cuando de del desde donde durante e el ella ellas ellos en entre era erais eran eras eres es esa esas ese eso esos esta estaba estabais estaban estabas estad estada estadas estado estados estamos estando estar estaremos estará estarán estarás estaré estaréis estaría estaríais estaríamos estarían estarías estas este estemos esto estos estoy estuve estuviera estuvierais estuvieran estuvieras estuvieron estuviese estuvieseis estuviesen estuvieses estuvimos estuviste estuvisteis estuviéramos estuviésemos estuvo está estábamos estáis están estás esté estéis estén estés fue fuera fuerais fueran fueras fueron fuese fueseis fuesen fueses fui fuimos fuiste fuisteis fuéramos fuésemos ha habida habidas habido habidos habiendo habremos habrá habrán habrás habré habréis habría habríais habríamos habrían habrías habéis había habíais habíamos habían habías han has hasta hay haya hayamos hayan hayas hayáis he hemos hube hubiera hubierais hubieran hubieras hubieron hubiese hubieseis hubiesen hubieses hubimos hubiste hubisteis hubiéramos hubiésemos hubo la las le les lo los me mi mis mucho muchos muy más mí mía mías mío míos nada ni no nos nosotras nosotros nuestra nuestras nuestro nuestros o os otra otras otro otros para pero poco por porque que quien quienes qué se sea seamos sean seas seremos será serán serás seré seréis sería seríais seríamos serían serías seáis sido siendo sin sobre sois somos son soy su sus suya suyas suyo suyos sí también tanto te tendremos tendrá tendrán tendrás tendré tendréis tendría tendríais tendríamos tendrían tendrías tened tenemos tenga tengamos tengan tengas tengo tengáis tenida tenidas tenido tenidos teniendo tenéis tenía teníais teníamos tenían tenías ti tiene tienen tienes todo todos tu tus tuve tuviera tuvierais tuvieran tuvieras tuvieron tuviese tuvieseis tuviesen tuvieses tuvimos tuviste tuvisteis tuviéramos tuviésemos tuvo tuya tuyas tuyo tuyos tú un una uno unos vosotras vosotros vuestra vuestras vuestro vuestros y ya yo él éramos".split(" "),s.Pipeline.registerFunction(s.es.stopWordFilter,"stopWordFilter-es")}}); diff --git a/static/js/lunr/lunr.fi.js b/static/js/lunr/lunr.fi.js new file mode 100644 index 0000000..8f78b5d --- /dev/null +++ b/static/js/lunr/lunr.fi.js @@ -0,0 +1,536 @@ +/*! + * Lunr languages, `Finnish` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.fi = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.fi.trimmer, + lunr.fi.stopWordFilter, + lunr.fi.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.fi.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.fi.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.fi.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.fi.trimmer, 'trimmer-fi'); + + /* lunr stemmer function */ + lunr.fi.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function FinnishStemmer() { + var a_0 = [new Among("pa", -1, 1), new Among("sti", -1, 2), + new Among("kaan", -1, 1), new Among("han", -1, 1), + new Among("kin", -1, 1), new Among("h\u00E4n", -1, 1), + new Among("k\u00E4\u00E4n", -1, 1), new Among("ko", -1, 1), + new Among("p\u00E4", -1, 1), new Among("k\u00F6", -1, 1) + ], + a_1 = [ + new Among("lla", -1, -1), new Among("na", -1, -1), + new Among("ssa", -1, -1), new Among("ta", -1, -1), + new Among("lta", 3, -1), new Among("sta", 3, -1) + ], + a_2 = [ + new Among("ll\u00E4", -1, -1), new Among("n\u00E4", -1, -1), + new Among("ss\u00E4", -1, -1), new Among("t\u00E4", -1, -1), + new Among("lt\u00E4", 3, -1), new Among("st\u00E4", 3, -1) + ], + a_3 = [ + new Among("lle", -1, -1), new Among("ine", -1, -1) + ], + a_4 = [ + new Among("nsa", -1, 3), new Among("mme", -1, 3), + new Among("nne", -1, 3), new Among("ni", -1, 2), + new Among("si", -1, 1), new Among("an", -1, 4), + new Among("en", -1, 6), new Among("\u00E4n", -1, 5), + new Among("ns\u00E4", -1, 3) + ], + a_5 = [new Among("aa", -1, -1), + new Among("ee", -1, -1), new Among("ii", -1, -1), + new Among("oo", -1, -1), new Among("uu", -1, -1), + new Among("\u00E4\u00E4", -1, -1), + new Among("\u00F6\u00F6", -1, -1) + ], + a_6 = [new Among("a", -1, 8), + new Among("lla", 0, -1), new Among("na", 0, -1), + new Among("ssa", 0, -1), new Among("ta", 0, -1), + new Among("lta", 4, -1), new Among("sta", 4, -1), + new Among("tta", 4, 9), new Among("lle", -1, -1), + new Among("ine", -1, -1), new Among("ksi", -1, -1), + new Among("n", -1, 7), new Among("han", 11, 1), + new Among("den", 11, -1, r_VI), new Among("seen", 11, -1, r_LONG), + new Among("hen", 11, 2), new Among("tten", 11, -1, r_VI), + new Among("hin", 11, 3), new Among("siin", 11, -1, r_VI), + new Among("hon", 11, 4), new Among("h\u00E4n", 11, 5), + new Among("h\u00F6n", 11, 6), new Among("\u00E4", -1, 8), + new Among("ll\u00E4", 22, -1), new Among("n\u00E4", 22, -1), + new Among("ss\u00E4", 22, -1), new Among("t\u00E4", 22, -1), + new Among("lt\u00E4", 26, -1), new Among("st\u00E4", 26, -1), + new Among("tt\u00E4", 26, 9) + ], + a_7 = [new Among("eja", -1, -1), + new Among("mma", -1, 1), new Among("imma", 1, -1), + new Among("mpa", -1, 1), new Among("impa", 3, -1), + new Among("mmi", -1, 1), new Among("immi", 5, -1), + new Among("mpi", -1, 1), new Among("impi", 7, -1), + new Among("ej\u00E4", -1, -1), new Among("mm\u00E4", -1, 1), + new Among("imm\u00E4", 10, -1), new Among("mp\u00E4", -1, 1), + new Among("imp\u00E4", 12, -1) + ], + a_8 = [new Among("i", -1, -1), + new Among("j", -1, -1) + ], + a_9 = [new Among("mma", -1, 1), + new Among("imma", 0, -1) + ], + g_AEI = [17, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 8 + ], + g_V1 = [17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 8, 0, 32 + ], + g_V2 = [17, 65, 16, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 8, 0, 32 + ], + g_particle_end = [17, 97, 24, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 32 + ], + B_ending_removed, S_x, I_p2, I_p1, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function r_mark_regions() { + I_p1 = sbp.limit; + I_p2 = I_p1; + if (!habr1()) { + I_p1 = sbp.cursor; + if (!habr1()) + I_p2 = sbp.cursor; + } + } + + function habr1() { + var v_1; + while (true) { + v_1 = sbp.cursor; + if (sbp.in_grouping(g_V1, 97, 246)) + break; + sbp.cursor = v_1; + if (v_1 >= sbp.limit) + return true; + sbp.cursor++; + } + sbp.cursor = v_1; + while (!sbp.out_grouping(g_V1, 97, 246)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + return false; + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function r_particle_etc() { + var among_var, v_1; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_0, 10); + if (among_var) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_1; + switch (among_var) { + case 1: + if (!sbp.in_grouping_b(g_particle_end, 97, 246)) + return; + break; + case 2: + if (!r_R2()) + return; + break; + } + sbp.slice_del(); + } else + sbp.limit_backward = v_1; + } + } + + function r_possessive() { + var among_var, v_1, v_2; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_4, 9); + if (among_var) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_1; + switch (among_var) { + case 1: + v_2 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "k")) { + sbp.cursor = sbp.limit - v_2; + sbp.slice_del(); + } + break; + case 2: + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(3, "kse")) { + sbp.bra = sbp.cursor; + sbp.slice_from("ksi"); + } + break; + case 3: + sbp.slice_del(); + break; + case 4: + if (sbp.find_among_b(a_1, 6)) + sbp.slice_del(); + break; + case 5: + if (sbp.find_among_b(a_2, 6)) + sbp.slice_del(); + break; + case 6: + if (sbp.find_among_b(a_3, 2)) + sbp.slice_del(); + break; + } + } else + sbp.limit_backward = v_1; + } + } + + function r_LONG() { + return sbp.find_among_b(a_5, 7); + } + + function r_VI() { + return sbp.eq_s_b(1, "i") && sbp.in_grouping_b(g_V2, 97, 246); + } + + function r_case_ending() { + var among_var, v_1, v_2; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_6, 30); + if (among_var) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_1; + switch (among_var) { + case 1: + if (!sbp.eq_s_b(1, "a")) + return; + break; + case 2: + case 9: + if (!sbp.eq_s_b(1, "e")) + return; + break; + case 3: + if (!sbp.eq_s_b(1, "i")) + return; + break; + case 4: + if (!sbp.eq_s_b(1, "o")) + return; + break; + case 5: + if (!sbp.eq_s_b(1, "\u00E4")) + return; + break; + case 6: + if (!sbp.eq_s_b(1, "\u00F6")) + return; + break; + case 7: + v_2 = sbp.limit - sbp.cursor; + if (!r_LONG()) { + sbp.cursor = sbp.limit - v_2; + if (!sbp.eq_s_b(2, "ie")) { + sbp.cursor = sbp.limit - v_2; + break; + } + } + sbp.cursor = sbp.limit - v_2; + if (sbp.cursor <= sbp.limit_backward) { + sbp.cursor = sbp.limit - v_2; + break; + } + sbp.cursor--; + sbp.bra = sbp.cursor; + break; + case 8: + if (!sbp.in_grouping_b(g_V1, 97, 246) || !sbp.out_grouping_b(g_V1, 97, 246)) + return; + break; + } + sbp.slice_del(); + B_ending_removed = true; + } else + sbp.limit_backward = v_1; + } + } + + function r_other_endings() { + var among_var, v_1, v_2; + if (sbp.cursor >= I_p2) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p2; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_7, 14); + if (among_var) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_1; + if (among_var == 1) { + v_2 = sbp.limit - sbp.cursor; + if (sbp.eq_s_b(2, "po")) + return; + sbp.cursor = sbp.limit - v_2; + } + sbp.slice_del(); + } else + sbp.limit_backward = v_1; + } + } + + function r_i_plural() { + var v_1; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + if (sbp.find_among_b(a_8, 2)) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_1; + sbp.slice_del(); + } else + sbp.limit_backward = v_1; + } + } + + function r_t_plural() { + var among_var, v_1, v_2, v_3, v_4, v_5; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "t")) { + sbp.bra = sbp.cursor; + v_2 = sbp.limit - sbp.cursor; + if (sbp.in_grouping_b(g_V1, 97, 246)) { + sbp.cursor = sbp.limit - v_2; + sbp.slice_del(); + sbp.limit_backward = v_1; + v_3 = sbp.limit - sbp.cursor; + if (sbp.cursor >= I_p2) { + sbp.cursor = I_p2; + v_4 = sbp.limit_backward; + sbp.limit_backward = sbp.cursor; + sbp.cursor = sbp.limit - v_3; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_9, 2); + if (among_var) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_4; + if (among_var == 1) { + v_5 = sbp.limit - sbp.cursor; + if (sbp.eq_s_b(2, "po")) + return; + sbp.cursor = sbp.limit - v_5; + } + sbp.slice_del(); + return; + } + } + } + } + sbp.limit_backward = v_1; + } + } + + function r_tidy() { + var v_1, v_2, v_3, v_4; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + v_2 = sbp.limit - sbp.cursor; + if (r_LONG()) { + sbp.cursor = sbp.limit - v_2; + sbp.ket = sbp.cursor; + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + sbp.bra = sbp.cursor; + sbp.slice_del(); + } + } + sbp.cursor = sbp.limit - v_2; + sbp.ket = sbp.cursor; + if (sbp.in_grouping_b(g_AEI, 97, 228)) { + sbp.bra = sbp.cursor; + if (sbp.out_grouping_b(g_V1, 97, 246)) + sbp.slice_del(); + } + sbp.cursor = sbp.limit - v_2; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "j")) { + sbp.bra = sbp.cursor; + v_3 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "o")) { + sbp.cursor = sbp.limit - v_3; + if (sbp.eq_s_b(1, "u")) + sbp.slice_del(); + } else + sbp.slice_del(); + } + sbp.cursor = sbp.limit - v_2; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "o")) { + sbp.bra = sbp.cursor; + if (sbp.eq_s_b(1, "j")) + sbp.slice_del(); + } + sbp.cursor = sbp.limit - v_2; + sbp.limit_backward = v_1; + while (true) { + v_4 = sbp.limit - sbp.cursor; + if (sbp.out_grouping_b(g_V1, 97, 246)) { + sbp.cursor = sbp.limit - v_4; + break; + } + sbp.cursor = sbp.limit - v_4; + if (sbp.cursor <= sbp.limit_backward) + return; + sbp.cursor--; + } + sbp.ket = sbp.cursor; + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + sbp.bra = sbp.cursor; + S_x = sbp.slice_to(); + if (sbp.eq_v_b(S_x)) + sbp.slice_del(); + } + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_mark_regions(); + B_ending_removed = false; + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_particle_etc(); + sbp.cursor = sbp.limit; + r_possessive(); + sbp.cursor = sbp.limit; + r_case_ending(); + sbp.cursor = sbp.limit; + r_other_endings(); + sbp.cursor = sbp.limit; + if (B_ending_removed) { + r_i_plural(); + sbp.cursor = sbp.limit; + } else { + sbp.cursor = sbp.limit; + r_t_plural(); + sbp.cursor = sbp.limit; + } + r_tidy(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.fi.stemmer, 'stemmer-fi'); + + /* stop word filter function */ + lunr.fi.stopWordFilter = function(token) { + if (lunr.fi.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.fi.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.fi.stopWordFilter.stopWords.length = 236; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.fi.stopWordFilter.stopWords.elements = ' ei eivät emme en et ette että he heidän heidät heihin heille heillä heiltä heissä heistä heitä hän häneen hänelle hänellä häneltä hänen hänessä hänestä hänet häntä itse ja johon joiden joihin joiksi joilla joille joilta joina joissa joista joita joka joksi jolla jolle jolta jona jonka jos jossa josta jota jotka kanssa keiden keihin keiksi keille keillä keiltä keinä keissä keistä keitä keneen keneksi kenelle kenellä keneltä kenen kenenä kenessä kenestä kenet ketkä ketkä ketä koska kuin kuka kun me meidän meidät meihin meille meillä meiltä meissä meistä meitä mihin miksi mikä mille millä miltä minkä minkä minua minulla minulle minulta minun minussa minusta minut minuun minä minä missä mistä mitkä mitä mukaan mutta ne niiden niihin niiksi niille niillä niiltä niin niin niinä niissä niistä niitä noiden noihin noiksi noilla noille noilta noin noina noissa noista noita nuo nyt näiden näihin näiksi näille näillä näiltä näinä näissä näistä näitä nämä ole olemme olen olet olette oli olimme olin olisi olisimme olisin olisit olisitte olisivat olit olitte olivat olla olleet ollut on ovat poikki se sekä sen siihen siinä siitä siksi sille sillä sillä siltä sinua sinulla sinulle sinulta sinun sinussa sinusta sinut sinuun sinä sinä sitä tai te teidän teidät teihin teille teillä teiltä teissä teistä teitä tuo tuohon tuoksi tuolla tuolle tuolta tuon tuona tuossa tuosta tuota tähän täksi tälle tällä tältä tämä tämän tänä tässä tästä tätä vaan vai vaikka yli'.split(' '); + + lunr.Pipeline.registerFunction(lunr.fi.stopWordFilter, 'stopWordFilter-fi'); + }; +})) diff --git a/static/js/lunr/lunr.fi.min.js b/static/js/lunr/lunr.fi.min.js new file mode 100644 index 0000000..a99beca --- /dev/null +++ b/static/js/lunr/lunr.fi.min.js @@ -0,0 +1 @@ +!function(i,e){"function"==typeof define&&define.amd?define(e):"object"==typeof exports?module.exports=e():e()(i.lunr)}(this,function(){return function(e){if(void 0===e)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===e.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var q,v,r;e.fi=function(){this.pipeline.reset(),this.pipeline.add(e.fi.trimmer,e.fi.stopWordFilter,e.fi.stemmer)},e.fi.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",e.fi.trimmer=e.trimmerSupport.generateTrimmer(e.fi.wordCharacters),e.Pipeline.registerFunction(e.fi.trimmer,"trimmer-fi"),e.fi.stemmer=(q=e.stemmerSupport.Among,v=e.stemmerSupport.SnowballProgram,r=new function(){var n,t,s,o,l=[new q("pa",-1,1),new q("sti",-1,2),new q("kaan",-1,1),new q("han",-1,1),new q("kin",-1,1),new q("hän",-1,1),new q("kään",-1,1),new q("ko",-1,1),new q("pä",-1,1),new q("kö",-1,1)],a=[new q("lla",-1,-1),new q("na",-1,-1),new q("ssa",-1,-1),new q("ta",-1,-1),new q("lta",3,-1),new q("sta",3,-1)],u=[new q("llä",-1,-1),new q("nä",-1,-1),new q("ssä",-1,-1),new q("tä",-1,-1),new q("ltä",3,-1),new q("stä",3,-1)],c=[new q("lle",-1,-1),new q("ine",-1,-1)],m=[new q("nsa",-1,3),new q("mme",-1,3),new q("nne",-1,3),new q("ni",-1,2),new q("si",-1,1),new q("an",-1,4),new q("en",-1,6),new q("än",-1,5),new q("nsä",-1,3)],i=[new q("aa",-1,-1),new q("ee",-1,-1),new q("ii",-1,-1),new q("oo",-1,-1),new q("uu",-1,-1),new q("ää",-1,-1),new q("öö",-1,-1)],w=[new q("a",-1,8),new q("lla",0,-1),new q("na",0,-1),new q("ssa",0,-1),new q("ta",0,-1),new q("lta",4,-1),new q("sta",4,-1),new q("tta",4,9),new q("lle",-1,-1),new q("ine",-1,-1),new q("ksi",-1,-1),new q("n",-1,7),new q("han",11,1),new q("den",11,-1,r),new q("seen",11,-1,j),new q("hen",11,2),new q("tten",11,-1,r),new q("hin",11,3),new q("siin",11,-1,r),new q("hon",11,4),new q("hän",11,5),new q("hön",11,6),new q("ä",-1,8),new q("llä",22,-1),new q("nä",22,-1),new q("ssä",22,-1),new q("tä",22,-1),new q("ltä",26,-1),new q("stä",26,-1),new q("ttä",26,9)],_=[new q("eja",-1,-1),new q("mma",-1,1),new q("imma",1,-1),new q("mpa",-1,1),new q("impa",3,-1),new q("mmi",-1,1),new q("immi",5,-1),new q("mpi",-1,1),new q("impi",7,-1),new q("ejä",-1,-1),new q("mmä",-1,1),new q("immä",10,-1),new q("mpä",-1,1),new q("impä",12,-1)],k=[new q("i",-1,-1),new q("j",-1,-1)],b=[new q("mma",-1,1),new q("imma",0,-1)],d=[17,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8],f=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],e=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],p=[17,97,24,1,0,0,0,0,0,0,0,0,0,0,0,0,8,0,32],h=new v;function g(){for(var i;i=h.cursor,!h.in_grouping(f,97,246);){if((h.cursor=i)>=h.limit)return 1;h.cursor++}for(h.cursor=i;!h.out_grouping(f,97,246);){if(h.cursor>=h.limit)return 1;h.cursor++}}function j(){return h.find_among_b(i,7)}function r(){return h.eq_s_b(1,"i")&&h.in_grouping_b(e,97,246)}this.setCurrent=function(i){h.setCurrent(i)},this.getCurrent=function(){return h.getCurrent()},this.stem=function(){var i,e,r=h.cursor;if(o=h.limit,s=o,g()||(o=h.cursor,g())||(s=h.cursor),n=!1,h.limit_backward=r,h.cursor=h.limit,function(){var i,e;if(h.cursor>=o)if(e=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,i=h.find_among_b(l,10)){switch(h.bra=h.cursor,h.limit_backward=e,i){case 1:if(h.in_grouping_b(p,97,246))break;return;case 2:if(s<=h.cursor)break;return}h.slice_del()}else h.limit_backward=e}(),h.cursor=h.limit,h.cursor>=o)if(r=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,e=h.find_among_b(m,9))switch(h.bra=h.cursor,h.limit_backward=r,e){case 1:i=h.limit-h.cursor,h.eq_s_b(1,"k")||(h.cursor=h.limit-i,h.slice_del());break;case 2:h.slice_del(),h.ket=h.cursor,h.eq_s_b(3,"kse")&&(h.bra=h.cursor,h.slice_from("ksi"));break;case 3:h.slice_del();break;case 4:h.find_among_b(a,6)&&h.slice_del();break;case 5:h.find_among_b(u,6)&&h.slice_del();break;case 6:h.find_among_b(c,2)&&h.slice_del()}else h.limit_backward=r;return h.cursor=h.limit,function(){var i,e,r;if(h.cursor>=o)if(e=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,i=h.find_among_b(w,30)){switch(h.bra=h.cursor,h.limit_backward=e,i){case 1:if(h.eq_s_b(1,"a"))break;return;case 2:case 9:if(h.eq_s_b(1,"e"))break;return;case 3:if(h.eq_s_b(1,"i"))break;return;case 4:if(h.eq_s_b(1,"o"))break;return;case 5:if(h.eq_s_b(1,"ä"))break;return;case 6:if(h.eq_s_b(1,"ö"))break;return;case 7:r=h.limit-h.cursor,!j()&&(h.cursor=h.limit-r,!h.eq_s_b(2,"ie"))||(h.cursor=h.limit-r,h.cursor<=h.limit_backward)?h.cursor=h.limit-r:(h.cursor--,h.bra=h.cursor);break;case 8:if(h.in_grouping_b(f,97,246)&&h.out_grouping_b(f,97,246))break;return}h.slice_del(),n=!0}else h.limit_backward=e}(),h.cursor=h.limit,function(){var i,e;if(h.cursor>=s)if(i=h.limit_backward,h.limit_backward=s,h.ket=h.cursor,e=h.find_among_b(_,14)){if(h.bra=h.cursor,h.limit_backward=i,1==e){if(e=h.limit-h.cursor,h.eq_s_b(2,"po"))return;h.cursor=h.limit-e}h.slice_del()}else h.limit_backward=i}(),h.cursor=h.limit,n?h.cursor>=o&&(e=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,h.find_among_b(k,2)?(h.bra=h.cursor,h.limit_backward=e,h.slice_del()):h.limit_backward=e):(h.cursor=h.limit,function(){var i,e,r,n;if(h.cursor>=o)if(e=h.limit_backward,h.limit_backward=o,h.ket=h.cursor,h.eq_s_b(1,"t")&&(h.bra=h.cursor,n=h.limit-h.cursor,h.in_grouping_b(f,97,246))&&(h.cursor=h.limit-n,h.slice_del(),h.limit_backward=e,n=h.limit-h.cursor,h.cursor>=s)&&(h.cursor=s,r=h.limit_backward,h.limit_backward=h.cursor,h.cursor=h.limit-n,h.ket=h.cursor,i=h.find_among_b(b,2))){if(h.bra=h.cursor,h.limit_backward=r,1==i){if(n=h.limit-h.cursor,h.eq_s_b(2,"po"))return;h.cursor=h.limit-n}h.slice_del()}else h.limit_backward=e}()),h.cursor=h.limit,function(){var i,e,r,n;if(h.cursor>=o){for(i=h.limit_backward,h.limit_backward=o,e=h.limit-h.cursor,j()&&(h.cursor=h.limit-e,h.ket=h.cursor,h.cursor>h.limit_backward)&&(h.cursor--,h.bra=h.cursor,h.slice_del()),h.cursor=h.limit-e,h.ket=h.cursor,h.in_grouping_b(d,97,228)&&(h.bra=h.cursor,h.out_grouping_b(f,97,246))&&h.slice_del(),h.cursor=h.limit-e,h.ket=h.cursor,h.eq_s_b(1,"j")&&(h.bra=h.cursor,r=h.limit-h.cursor,h.eq_s_b(1,"o")||(h.cursor=h.limit-r,h.eq_s_b(1,"u")))&&h.slice_del(),h.cursor=h.limit-e,h.ket=h.cursor,h.eq_s_b(1,"o")&&(h.bra=h.cursor,h.eq_s_b(1,"j"))&&h.slice_del(),h.cursor=h.limit-e,h.limit_backward=i;;){if(n=h.limit-h.cursor,h.out_grouping_b(f,97,246)){h.cursor=h.limit-n;break}if(h.cursor=h.limit-n,h.cursor<=h.limit_backward)return;h.cursor--}h.ket=h.cursor,h.cursor>h.limit_backward&&(h.cursor--,h.bra=h.cursor,t=h.slice_to(),h.eq_v_b(t))&&h.slice_del()}}(),!0}},function(i){return r.setCurrent(i),r.stem(),r.getCurrent()}),e.Pipeline.registerFunction(e.fi.stemmer,"stemmer-fi"),e.fi.stopWordFilter=function(i){if(-1===e.fi.stopWordFilter.stopWords.indexOf(i))return i},e.fi.stopWordFilter.stopWords=new e.SortedSet,e.fi.stopWordFilter.stopWords.length=236,e.fi.stopWordFilter.stopWords.elements=" ei eivät emme en et ette että he heidän heidät heihin heille heillä heiltä heissä heistä heitä hän häneen hänelle hänellä häneltä hänen hänessä hänestä hänet häntä itse ja johon joiden joihin joiksi joilla joille joilta joina joissa joista joita joka joksi jolla jolle jolta jona jonka jos jossa josta jota jotka kanssa keiden keihin keiksi keille keillä keiltä keinä keissä keistä keitä keneen keneksi kenelle kenellä keneltä kenen kenenä kenessä kenestä kenet ketkä ketkä ketä koska kuin kuka kun me meidän meidät meihin meille meillä meiltä meissä meistä meitä mihin miksi mikä mille millä miltä minkä minkä minua minulla minulle minulta minun minussa minusta minut minuun minä minä missä mistä mitkä mitä mukaan mutta ne niiden niihin niiksi niille niillä niiltä niin niin niinä niissä niistä niitä noiden noihin noiksi noilla noille noilta noin noina noissa noista noita nuo nyt näiden näihin näiksi näille näillä näiltä näinä näissä näistä näitä nämä ole olemme olen olet olette oli olimme olin olisi olisimme olisin olisit olisitte olisivat olit olitte olivat olla olleet ollut on ovat poikki se sekä sen siihen siinä siitä siksi sille sillä sillä siltä sinua sinulla sinulle sinulta sinun sinussa sinusta sinut sinuun sinä sinä sitä tai te teidän teidät teihin teille teillä teiltä teissä teistä teitä tuo tuohon tuoksi tuolla tuolle tuolta tuon tuona tuossa tuosta tuota tähän täksi tälle tällä tältä tämä tämän tänä tässä tästä tätä vaan vai vaikka yli".split(" "),e.Pipeline.registerFunction(e.fi.stopWordFilter,"stopWordFilter-fi")}}); diff --git a/static/js/lunr/lunr.fr.js b/static/js/lunr/lunr.fr.js new file mode 100644 index 0000000..13c2420 --- /dev/null +++ b/static/js/lunr/lunr.fr.js @@ -0,0 +1,698 @@ +/*! + * Lunr languages, `French` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.fr = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.fr.trimmer, + lunr.fr.stopWordFilter, + lunr.fr.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.fr.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.fr.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.fr.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.fr.trimmer, 'trimmer-fr'); + + /* lunr stemmer function */ + lunr.fr.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function FrenchStemmer() { + var a_0 = [new Among("col", -1, -1), new Among("par", -1, -1), + new Among("tap", -1, -1) + ], + a_1 = [new Among("", -1, 4), + new Among("I", 0, 1), new Among("U", 0, 2), new Among("Y", 0, 3) + ], + a_2 = [ + new Among("iqU", -1, 3), new Among("abl", -1, 3), + new Among("I\u00E8r", -1, 4), new Among("i\u00E8r", -1, 4), + new Among("eus", -1, 2), new Among("iv", -1, 1) + ], + a_3 = [ + new Among("ic", -1, 2), new Among("abil", -1, 1), + new Among("iv", -1, 3) + ], + a_4 = [new Among("iqUe", -1, 1), + new Among("atrice", -1, 2), new Among("ance", -1, 1), + new Among("ence", -1, 5), new Among("logie", -1, 3), + new Among("able", -1, 1), new Among("isme", -1, 1), + new Among("euse", -1, 11), new Among("iste", -1, 1), + new Among("ive", -1, 8), new Among("if", -1, 8), + new Among("usion", -1, 4), new Among("ation", -1, 2), + new Among("ution", -1, 4), new Among("ateur", -1, 2), + new Among("iqUes", -1, 1), new Among("atrices", -1, 2), + new Among("ances", -1, 1), new Among("ences", -1, 5), + new Among("logies", -1, 3), new Among("ables", -1, 1), + new Among("ismes", -1, 1), new Among("euses", -1, 11), + new Among("istes", -1, 1), new Among("ives", -1, 8), + new Among("ifs", -1, 8), new Among("usions", -1, 4), + new Among("ations", -1, 2), new Among("utions", -1, 4), + new Among("ateurs", -1, 2), new Among("ments", -1, 15), + new Among("ements", 30, 6), new Among("issements", 31, 12), + new Among("it\u00E9s", -1, 7), new Among("ment", -1, 15), + new Among("ement", 34, 6), new Among("issement", 35, 12), + new Among("amment", 34, 13), new Among("emment", 34, 14), + new Among("aux", -1, 10), new Among("eaux", 39, 9), + new Among("eux", -1, 1), new Among("it\u00E9", -1, 7) + ], + a_5 = [ + new Among("ira", -1, 1), new Among("ie", -1, 1), + new Among("isse", -1, 1), new Among("issante", -1, 1), + new Among("i", -1, 1), new Among("irai", 4, 1), + new Among("ir", -1, 1), new Among("iras", -1, 1), + new Among("ies", -1, 1), new Among("\u00EEmes", -1, 1), + new Among("isses", -1, 1), new Among("issantes", -1, 1), + new Among("\u00EEtes", -1, 1), new Among("is", -1, 1), + new Among("irais", 13, 1), new Among("issais", 13, 1), + new Among("irions", -1, 1), new Among("issions", -1, 1), + new Among("irons", -1, 1), new Among("issons", -1, 1), + new Among("issants", -1, 1), new Among("it", -1, 1), + new Among("irait", 21, 1), new Among("issait", 21, 1), + new Among("issant", -1, 1), new Among("iraIent", -1, 1), + new Among("issaIent", -1, 1), new Among("irent", -1, 1), + new Among("issent", -1, 1), new Among("iront", -1, 1), + new Among("\u00EEt", -1, 1), new Among("iriez", -1, 1), + new Among("issiez", -1, 1), new Among("irez", -1, 1), + new Among("issez", -1, 1) + ], + a_6 = [new Among("a", -1, 3), + new Among("era", 0, 2), new Among("asse", -1, 3), + new Among("ante", -1, 3), new Among("\u00E9e", -1, 2), + new Among("ai", -1, 3), new Among("erai", 5, 2), + new Among("er", -1, 2), new Among("as", -1, 3), + new Among("eras", 8, 2), new Among("\u00E2mes", -1, 3), + new Among("asses", -1, 3), new Among("antes", -1, 3), + new Among("\u00E2tes", -1, 3), new Among("\u00E9es", -1, 2), + new Among("ais", -1, 3), new Among("erais", 15, 2), + new Among("ions", -1, 1), new Among("erions", 17, 2), + new Among("assions", 17, 3), new Among("erons", -1, 2), + new Among("ants", -1, 3), new Among("\u00E9s", -1, 2), + new Among("ait", -1, 3), new Among("erait", 23, 2), + new Among("ant", -1, 3), new Among("aIent", -1, 3), + new Among("eraIent", 26, 2), new Among("\u00E8rent", -1, 2), + new Among("assent", -1, 3), new Among("eront", -1, 2), + new Among("\u00E2t", -1, 3), new Among("ez", -1, 2), + new Among("iez", 32, 2), new Among("eriez", 33, 2), + new Among("assiez", 33, 3), new Among("erez", 32, 2), + new Among("\u00E9", -1, 2) + ], + a_7 = [new Among("e", -1, 3), + new Among("I\u00E8re", 0, 2), new Among("i\u00E8re", 0, 2), + new Among("ion", -1, 1), new Among("Ier", -1, 2), + new Among("ier", -1, 2), new Among("\u00EB", -1, 4) + ], + a_8 = [ + new Among("ell", -1, -1), new Among("eill", -1, -1), + new Among("enn", -1, -1), new Among("onn", -1, -1), + new Among("ett", -1, -1) + ], + g_v = [17, 65, 16, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 128, 130, 103, 8, 5 + ], + g_keep_with_s = [1, 65, 20, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128 + ], + I_p2, I_p1, I_pV, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function habr1(c1, c2, v_1) { + if (sbp.eq_s(1, c1)) { + sbp.ket = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 251)) { + sbp.slice_from(c2); + sbp.cursor = v_1; + return true; + } + } + return false; + } + + function habr2(c1, c2, v_1) { + if (sbp.eq_s(1, c1)) { + sbp.ket = sbp.cursor; + sbp.slice_from(c2); + sbp.cursor = v_1; + return true; + } + return false; + } + + function r_prelude() { + var v_1, v_2; + while (true) { + v_1 = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 251)) { + sbp.bra = sbp.cursor; + v_2 = sbp.cursor; + if (habr1("u", "U", v_1)) + continue; + sbp.cursor = v_2; + if (habr1("i", "I", v_1)) + continue; + sbp.cursor = v_2; + if (habr2("y", "Y", v_1)) + continue; + } + sbp.cursor = v_1; + sbp.bra = v_1; + if (!habr1("y", "Y", v_1)) { + sbp.cursor = v_1; + if (sbp.eq_s(1, "q")) { + sbp.bra = sbp.cursor; + if (habr2("u", "U", v_1)) + continue; + } + sbp.cursor = v_1; + if (v_1 >= sbp.limit) + return; + sbp.cursor++; + } + } + } + + function habr3() { + while (!sbp.in_grouping(g_v, 97, 251)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 251)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + return false; + } + + function r_mark_regions() { + var v_1 = sbp.cursor; + I_pV = sbp.limit; + I_p1 = I_pV; + I_p2 = I_pV; + if (sbp.in_grouping(g_v, 97, 251) && sbp.in_grouping(g_v, 97, 251) && sbp.cursor < sbp.limit) + sbp.cursor++; + else { + sbp.cursor = v_1; + if (!sbp.find_among(a_0, 3)) { + sbp.cursor = v_1; + do { + if (sbp.cursor >= sbp.limit) { + sbp.cursor = I_pV; + break; + } + sbp.cursor++; + } while (!sbp.in_grouping(g_v, 97, 251)); + } + } + I_pV = sbp.cursor; + sbp.cursor = v_1; + if (!habr3()) { + I_p1 = sbp.cursor; + if (!habr3()) + I_p2 = sbp.cursor; + } + } + + function r_postlude() { + var among_var, v_1; + while (true) { + v_1 = sbp.cursor; + sbp.bra = v_1; + among_var = sbp.find_among(a_1, 4); + if (!among_var) + break; + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("i"); + break; + case 2: + sbp.slice_from("u"); + break; + case 3: + sbp.slice_from("y"); + break; + case 4: + if (sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + break; + } + } + } + + function r_RV() { + return I_pV <= sbp.cursor; + } + + function r_R1() { + return I_p1 <= sbp.cursor; + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function r_standard_suffix() { + var among_var, v_1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_4, 43); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (!r_R2()) + return false; + sbp.slice_del(); + break; + case 2: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "ic")) { + sbp.bra = sbp.cursor; + if (!r_R2()) + sbp.slice_from("iqU"); + else + sbp.slice_del(); + } + break; + case 3: + if (!r_R2()) + return false; + sbp.slice_from("log"); + break; + case 4: + if (!r_R2()) + return false; + sbp.slice_from("u"); + break; + case 5: + if (!r_R2()) + return false; + sbp.slice_from("ent"); + break; + case 6: + if (!r_RV()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_2, 6); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (r_R2()) { + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "at")) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + } + } + break; + case 2: + if (r_R2()) + sbp.slice_del(); + else if (r_R1()) + sbp.slice_from("eux"); + break; + case 3: + if (r_R2()) + sbp.slice_del(); + break; + case 4: + if (r_RV()) + sbp.slice_from("i"); + break; + } + } + break; + case 7: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_3, 3); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (r_R2()) + sbp.slice_del(); + else + sbp.slice_from("abl"); + break; + case 2: + if (r_R2()) + sbp.slice_del(); + else + sbp.slice_from("iqU"); + break; + case 3: + if (r_R2()) + sbp.slice_del(); + break; + } + } + break; + case 8: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "at")) { + sbp.bra = sbp.cursor; + if (r_R2()) { + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "ic")) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + else + sbp.slice_from("iqU"); + break; + } + } + } + break; + case 9: + sbp.slice_from("eau"); + break; + case 10: + if (!r_R1()) + return false; + sbp.slice_from("al"); + break; + case 11: + if (r_R2()) + sbp.slice_del(); + else if (!r_R1()) + return false; + else + sbp.slice_from("eux"); + break; + case 12: + if (!r_R1() || !sbp.out_grouping_b(g_v, 97, 251)) + return false; + sbp.slice_del(); + break; + case 13: + if (r_RV()) + sbp.slice_from("ant"); + return false; + case 14: + if (r_RV()) + sbp.slice_from("ent"); + return false; + case 15: + v_1 = sbp.limit - sbp.cursor; + if (sbp.in_grouping_b(g_v, 97, 251) && r_RV()) { + sbp.cursor = sbp.limit - v_1; + sbp.slice_del(); + } + return false; + } + return true; + } + return false; + } + + function r_i_verb_suffix() { + var among_var, v_1; + if (sbp.cursor < I_pV) + return false; + v_1 = sbp.limit_backward; + sbp.limit_backward = I_pV; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_5, 35); + if (!among_var) { + sbp.limit_backward = v_1; + return false; + } + sbp.bra = sbp.cursor; + if (among_var == 1) { + if (!sbp.out_grouping_b(g_v, 97, 251)) { + sbp.limit_backward = v_1; + return false; + } + sbp.slice_del(); + } + sbp.limit_backward = v_1; + return true; + } + + function r_verb_suffix() { + var among_var, v_2, v_3; + if (sbp.cursor < I_pV) + return false; + v_2 = sbp.limit_backward; + sbp.limit_backward = I_pV; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_6, 38); + if (!among_var) { + sbp.limit_backward = v_2; + return false; + } + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (!r_R2()) { + sbp.limit_backward = v_2; + return false; + } + sbp.slice_del(); + break; + case 2: + sbp.slice_del(); + break; + case 3: + sbp.slice_del(); + v_3 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "e")) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + } else + sbp.cursor = sbp.limit - v_3; + break; + } + sbp.limit_backward = v_2; + return true; + } + + function r_residual_suffix() { + var among_var, v_1 = sbp.limit - sbp.cursor, + v_2, v_4, v_5; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "s")) { + sbp.bra = sbp.cursor; + v_2 = sbp.limit - sbp.cursor; + if (sbp.out_grouping_b(g_keep_with_s, 97, 232)) { + sbp.cursor = sbp.limit - v_2; + sbp.slice_del(); + } else + sbp.cursor = sbp.limit - v_1; + } else + sbp.cursor = sbp.limit - v_1; + if (sbp.cursor >= I_pV) { + v_4 = sbp.limit_backward; + sbp.limit_backward = I_pV; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_7, 7); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (r_R2()) { + v_5 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "s")) { + sbp.cursor = sbp.limit - v_5; + if (!sbp.eq_s_b(1, "t")) + break; + } + sbp.slice_del(); + } + break; + case 2: + sbp.slice_from("i"); + break; + case 3: + sbp.slice_del(); + break; + case 4: + if (sbp.eq_s_b(2, "gu")) + sbp.slice_del(); + break; + } + } + sbp.limit_backward = v_4; + } + } + + function r_un_double() { + var v_1 = sbp.limit - sbp.cursor; + if (sbp.find_among_b(a_8, 5)) { + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + sbp.bra = sbp.cursor; + sbp.slice_del(); + } + } + } + + function r_un_accent() { + var v_1, v_2 = 1; + while (sbp.out_grouping_b(g_v, 97, 251)) + v_2--; + if (v_2 <= 0) { + sbp.ket = sbp.cursor; + v_1 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "\u00E9")) { + sbp.cursor = sbp.limit - v_1; + if (!sbp.eq_s_b(1, "\u00E8")) + return; + } + sbp.bra = sbp.cursor; + sbp.slice_from("e"); + } + } + + function habr5() { + if (!r_standard_suffix()) { + sbp.cursor = sbp.limit; + if (!r_i_verb_suffix()) { + sbp.cursor = sbp.limit; + if (!r_verb_suffix()) { + sbp.cursor = sbp.limit; + r_residual_suffix(); + return; + } + } + } + sbp.cursor = sbp.limit; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "Y")) { + sbp.bra = sbp.cursor; + sbp.slice_from("i"); + } else { + sbp.cursor = sbp.limit; + if (sbp.eq_s_b(1, "\u00E7")) { + sbp.bra = sbp.cursor; + sbp.slice_from("c"); + } + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_prelude(); + sbp.cursor = v_1; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + habr5(); + sbp.cursor = sbp.limit; + r_un_double(); + sbp.cursor = sbp.limit; + r_un_accent(); + sbp.cursor = sbp.limit_backward; + r_postlude(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.fr.stemmer, 'stemmer-fr'); + + /* stop word filter function */ + lunr.fr.stopWordFilter = function(token) { + if (lunr.fr.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.fr.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.fr.stopWordFilter.stopWords.length = 164; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.fr.stopWordFilter.stopWords.elements = ' ai aie aient aies ait as au aura aurai auraient aurais aurait auras aurez auriez aurions aurons auront aux avaient avais avait avec avez aviez avions avons ayant ayez ayons c ce ceci celà ces cet cette d dans de des du elle en es est et eu eue eues eurent eus eusse eussent eusses eussiez eussions eut eux eûmes eût eûtes furent fus fusse fussent fusses fussiez fussions fut fûmes fût fûtes ici il ils j je l la le les leur leurs lui m ma mais me mes moi mon même n ne nos notre nous on ont ou par pas pour qu que quel quelle quelles quels qui s sa sans se sera serai seraient serais serait seras serez seriez serions serons seront ses soi soient sois soit sommes son sont soyez soyons suis sur t ta te tes toi ton tu un une vos votre vous y à étaient étais était étant étiez étions été étée étées étés êtes'.split(' '); + + lunr.Pipeline.registerFunction(lunr.fr.stopWordFilter, 'stopWordFilter-fr'); + }; +})) diff --git a/static/js/lunr/lunr.fr.min.js b/static/js/lunr/lunr.fr.min.js new file mode 100644 index 0000000..4382cb7 --- /dev/null +++ b/static/js/lunr/lunr.fr.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,s,i;r.fr=function(){this.pipeline.reset(),this.pipeline.add(r.fr.trimmer,r.fr.stopWordFilter,r.fr.stemmer)},r.fr.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.fr.trimmer=r.trimmerSupport.generateTrimmer(r.fr.wordCharacters),r.Pipeline.registerFunction(r.fr.trimmer,"trimmer-fr"),r.fr.stemmer=(e=r.stemmerSupport.Among,s=r.stemmerSupport.SnowballProgram,i=new function(){var o,u,c,a=[new e("col",-1,-1),new e("par",-1,-1),new e("tap",-1,-1)],l=[new e("",-1,4),new e("I",0,1),new e("U",0,2),new e("Y",0,3)],w=[new e("iqU",-1,3),new e("abl",-1,3),new e("Ièr",-1,4),new e("ièr",-1,4),new e("eus",-1,2),new e("iv",-1,1)],f=[new e("ic",-1,2),new e("abil",-1,1),new e("iv",-1,3)],m=[new e("iqUe",-1,1),new e("atrice",-1,2),new e("ance",-1,1),new e("ence",-1,5),new e("logie",-1,3),new e("able",-1,1),new e("isme",-1,1),new e("euse",-1,11),new e("iste",-1,1),new e("ive",-1,8),new e("if",-1,8),new e("usion",-1,4),new e("ation",-1,2),new e("ution",-1,4),new e("ateur",-1,2),new e("iqUes",-1,1),new e("atrices",-1,2),new e("ances",-1,1),new e("ences",-1,5),new e("logies",-1,3),new e("ables",-1,1),new e("ismes",-1,1),new e("euses",-1,11),new e("istes",-1,1),new e("ives",-1,8),new e("ifs",-1,8),new e("usions",-1,4),new e("ations",-1,2),new e("utions",-1,4),new e("ateurs",-1,2),new e("ments",-1,15),new e("ements",30,6),new e("issements",31,12),new e("ités",-1,7),new e("ment",-1,15),new e("ement",34,6),new e("issement",35,12),new e("amment",34,13),new e("emment",34,14),new e("aux",-1,10),new e("eaux",39,9),new e("eux",-1,1),new e("ité",-1,7)],_=[new e("ira",-1,1),new e("ie",-1,1),new e("isse",-1,1),new e("issante",-1,1),new e("i",-1,1),new e("irai",4,1),new e("ir",-1,1),new e("iras",-1,1),new e("ies",-1,1),new e("îmes",-1,1),new e("isses",-1,1),new e("issantes",-1,1),new e("îtes",-1,1),new e("is",-1,1),new e("irais",13,1),new e("issais",13,1),new e("irions",-1,1),new e("issions",-1,1),new e("irons",-1,1),new e("issons",-1,1),new e("issants",-1,1),new e("it",-1,1),new e("irait",21,1),new e("issait",21,1),new e("issant",-1,1),new e("iraIent",-1,1),new e("issaIent",-1,1),new e("irent",-1,1),new e("issent",-1,1),new e("iront",-1,1),new e("ît",-1,1),new e("iriez",-1,1),new e("issiez",-1,1),new e("irez",-1,1),new e("issez",-1,1)],b=[new e("a",-1,3),new e("era",0,2),new e("asse",-1,3),new e("ante",-1,3),new e("ée",-1,2),new e("ai",-1,3),new e("erai",5,2),new e("er",-1,2),new e("as",-1,3),new e("eras",8,2),new e("âmes",-1,3),new e("asses",-1,3),new e("antes",-1,3),new e("âtes",-1,3),new e("ées",-1,2),new e("ais",-1,3),new e("erais",15,2),new e("ions",-1,1),new e("erions",17,2),new e("assions",17,3),new e("erons",-1,2),new e("ants",-1,3),new e("és",-1,2),new e("ait",-1,3),new e("erait",23,2),new e("ant",-1,3),new e("aIent",-1,3),new e("eraIent",26,2),new e("èrent",-1,2),new e("assent",-1,3),new e("eront",-1,2),new e("ât",-1,3),new e("ez",-1,2),new e("iez",32,2),new e("eriez",33,2),new e("assiez",33,3),new e("erez",32,2),new e("é",-1,2)],d=[new e("e",-1,3),new e("Ière",0,2),new e("ière",0,2),new e("ion",-1,1),new e("Ier",-1,2),new e("ier",-1,2),new e("ë",-1,4)],k=[new e("ell",-1,-1),new e("eill",-1,-1),new e("enn",-1,-1),new e("onn",-1,-1),new e("ett",-1,-1)],p=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,128,130,103,8,5],g=[1,65,20,0,0,0,0,0,0,0,0,0,0,0,0,0,128],q=new s;function v(e,r,s){return q.eq_s(1,e)&&(q.ket=q.cursor,q.in_grouping(p,97,251))&&(q.slice_from(r),q.cursor=s,1)}function z(e,r,s){return q.eq_s(1,e)&&(q.ket=q.cursor,q.slice_from(r),q.cursor=s,1)}function h(){for(;!q.in_grouping(p,97,251);){if(q.cursor>=q.limit)return 1;q.cursor++}for(;!q.out_grouping(p,97,251);){if(q.cursor>=q.limit)return 1;q.cursor++}}function W(){return c<=q.cursor}function y(){return u<=q.cursor}function F(){return o<=q.cursor}this.setCurrent=function(e){q.setCurrent(e)},this.getCurrent=function(){return q.getCurrent()},this.stem=function(){var e=q.cursor,r=(function(){for(var e,r;;){if(e=q.cursor,q.in_grouping(p,97,251)){if(q.bra=q.cursor,r=q.cursor,v("u","U",e))continue;if(q.cursor=r,v("i","I",e))continue;if(q.cursor=r,z("y","Y",e))continue}if(q.cursor=e,q.bra=e,!v("y","Y",e)&&(q.cursor=e,!q.eq_s(1,"q")||(q.bra=q.cursor,!z("u","U",e)))){if((q.cursor=e)>=q.limit)return;q.cursor++}}}(),q.cursor=e,q.cursor);if(c=q.limit,o=u=c,q.in_grouping(p,97,251)&&q.in_grouping(p,97,251)&&q.cursor=q.limit){q.cursor=c;break}}while(q.cursor++,!q.in_grouping(p,97,251))}if(c=q.cursor,q.cursor=r,h()||(u=q.cursor,h())||(o=q.cursor),q.limit_backward=e,q.cursor=q.limit,function(){var e,r;if(q.ket=q.cursor,e=q.find_among_b(m,43)){switch(q.bra=q.cursor,e){case 1:if(!F())return;q.slice_del();break;case 2:if(!F())return;q.slice_del(),q.ket=q.cursor,q.eq_s_b(2,"ic")&&(q.bra=q.cursor,F()?q.slice_del():q.slice_from("iqU"));break;case 3:if(!F())return;q.slice_from("log");break;case 4:if(!F())return;q.slice_from("u");break;case 5:if(!F())return;q.slice_from("ent");break;case 6:if(!W())return;if(q.slice_del(),q.ket=q.cursor,e=q.find_among_b(w,6))switch(q.bra=q.cursor,e){case 1:F()&&(q.slice_del(),q.ket=q.cursor,q.eq_s_b(2,"at"))&&(q.bra=q.cursor,F())&&q.slice_del();break;case 2:F()?q.slice_del():y()&&q.slice_from("eux");break;case 3:F()&&q.slice_del();break;case 4:W()&&q.slice_from("i")}break;case 7:if(!F())return;if(q.slice_del(),q.ket=q.cursor,e=q.find_among_b(f,3))switch(q.bra=q.cursor,e){case 1:F()?q.slice_del():q.slice_from("abl");break;case 2:F()?q.slice_del():q.slice_from("iqU");break;case 3:F()&&q.slice_del()}break;case 8:if(!F())return;q.slice_del(),q.ket=q.cursor,q.eq_s_b(2,"at")&&(q.bra=q.cursor,F())&&(q.slice_del(),q.ket=q.cursor,q.eq_s_b(2,"ic"))&&(q.bra=q.cursor,F()?q.slice_del():q.slice_from("iqU"));break;case 9:q.slice_from("eau");break;case 10:if(!y())return;q.slice_from("al");break;case 11:if(F())q.slice_del();else{if(!y())return;q.slice_from("eux")}break;case 12:if(!y()||!q.out_grouping_b(p,97,251))return;q.slice_del();break;case 13:return W()&&q.slice_from("ant"),0;case 14:return W()&&q.slice_from("ent"),0;case 15:return r=q.limit-q.cursor,q.in_grouping_b(p,97,251)&&W()&&(q.cursor=q.limit-r,q.slice_del()),0}return 1}}()||(q.cursor=q.limit,function(){var e,r;if(!(q.cursor=c){if(s=q.limit_backward,q.limit_backward=c,q.ket=q.cursor,n=q.find_among_b(d,7))switch(q.bra=q.cursor,n){case 1:if(F()){if(i=q.limit-q.cursor,!q.eq_s_b(1,"s")&&(q.cursor=q.limit-i,!q.eq_s_b(1,"t")))break;q.slice_del()}break;case 2:q.slice_from("i");break;case 3:q.slice_del();break;case 4:q.eq_s_b(2,"gu")&&q.slice_del()}q.limit_backward=s}}q.cursor=q.limit,r=q.limit-q.cursor,q.find_among_b(k,5)&&(q.cursor=q.limit-r,q.ket=q.cursor,q.cursor>q.limit_backward)&&(q.cursor--,q.bra=q.cursor,q.slice_del()),q.cursor=q.limit;for(var t=1;q.out_grouping_b(p,97,251);)t--;return t<=0&&(q.ket=q.cursor,e=q.limit-q.cursor,q.eq_s_b(1,"é")||(q.cursor=q.limit-e,q.eq_s_b(1,"è")))&&(q.bra=q.cursor,q.slice_from("e")),q.cursor=q.limit_backward,function(){for(var e;e=q.cursor,q.bra=e,e=q.find_among(l,4);)switch(q.ket=q.cursor,e){case 1:q.slice_from("i");break;case 2:q.slice_from("u");break;case 3:q.slice_from("y");break;case 4:if(q.cursor>=q.limit)return;q.cursor++}}(),!0}},function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}),r.Pipeline.registerFunction(r.fr.stemmer,"stemmer-fr"),r.fr.stopWordFilter=function(e){if(-1===r.fr.stopWordFilter.stopWords.indexOf(e))return e},r.fr.stopWordFilter.stopWords=new r.SortedSet,r.fr.stopWordFilter.stopWords.length=164,r.fr.stopWordFilter.stopWords.elements=" ai aie aient aies ait as au aura aurai auraient aurais aurait auras aurez auriez aurions aurons auront aux avaient avais avait avec avez aviez avions avons ayant ayez ayons c ce ceci celà ces cet cette d dans de des du elle en es est et eu eue eues eurent eus eusse eussent eusses eussiez eussions eut eux eûmes eût eûtes furent fus fusse fussent fusses fussiez fussions fut fûmes fût fûtes ici il ils j je l la le les leur leurs lui m ma mais me mes moi mon même n ne nos notre nous on ont ou par pas pour qu que quel quelle quelles quels qui s sa sans se sera serai seraient serais serait seras serez seriez serions serons seront ses soi soient sois soit sommes son sont soyez soyons suis sur t ta te tes toi ton tu un une vos votre vous y à étaient étais était étant étiez étions été étée étées étés êtes".split(" "),r.Pipeline.registerFunction(r.fr.stopWordFilter,"stopWordFilter-fr")}}); diff --git a/static/js/lunr/lunr.hu.js b/static/js/lunr/lunr.hu.js new file mode 100644 index 0000000..986ddb0 --- /dev/null +++ b/static/js/lunr/lunr.hu.js @@ -0,0 +1,561 @@ +/*! + * Lunr languages, `Hungarian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.hu = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.hu.trimmer, + lunr.hu.stopWordFilter, + lunr.hu.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.hu.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.hu.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.hu.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.hu.trimmer, 'trimmer-hu'); + + /* lunr stemmer function */ + lunr.hu.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function HungarianStemmer() { + var a_0 = [new Among("cs", -1, -1), new Among("dzs", -1, -1), + new Among("gy", -1, -1), new Among("ly", -1, -1), + new Among("ny", -1, -1), new Among("sz", -1, -1), + new Among("ty", -1, -1), new Among("zs", -1, -1) + ], + a_1 = [ + new Among("\u00E1", -1, 1), new Among("\u00E9", -1, 2) + ], + a_2 = [ + new Among("bb", -1, -1), new Among("cc", -1, -1), + new Among("dd", -1, -1), new Among("ff", -1, -1), + new Among("gg", -1, -1), new Among("jj", -1, -1), + new Among("kk", -1, -1), new Among("ll", -1, -1), + new Among("mm", -1, -1), new Among("nn", -1, -1), + new Among("pp", -1, -1), new Among("rr", -1, -1), + new Among("ccs", -1, -1), new Among("ss", -1, -1), + new Among("zzs", -1, -1), new Among("tt", -1, -1), + new Among("vv", -1, -1), new Among("ggy", -1, -1), + new Among("lly", -1, -1), new Among("nny", -1, -1), + new Among("tty", -1, -1), new Among("ssz", -1, -1), + new Among("zz", -1, -1) + ], + a_3 = [new Among("al", -1, 1), + new Among("el", -1, 2) + ], + a_4 = [new Among("ba", -1, -1), + new Among("ra", -1, -1), new Among("be", -1, -1), + new Among("re", -1, -1), new Among("ig", -1, -1), + new Among("nak", -1, -1), new Among("nek", -1, -1), + new Among("val", -1, -1), new Among("vel", -1, -1), + new Among("ul", -1, -1), new Among("n\u00E1l", -1, -1), + new Among("n\u00E9l", -1, -1), new Among("b\u00F3l", -1, -1), + new Among("r\u00F3l", -1, -1), new Among("t\u00F3l", -1, -1), + new Among("b\u00F5l", -1, -1), new Among("r\u00F5l", -1, -1), + new Among("t\u00F5l", -1, -1), new Among("\u00FCl", -1, -1), + new Among("n", -1, -1), new Among("an", 19, -1), + new Among("ban", 20, -1), new Among("en", 19, -1), + new Among("ben", 22, -1), new Among("k\u00E9ppen", 22, -1), + new Among("on", 19, -1), new Among("\u00F6n", 19, -1), + new Among("k\u00E9pp", -1, -1), new Among("kor", -1, -1), + new Among("t", -1, -1), new Among("at", 29, -1), + new Among("et", 29, -1), new Among("k\u00E9nt", 29, -1), + new Among("ank\u00E9nt", 32, -1), new Among("enk\u00E9nt", 32, -1), + new Among("onk\u00E9nt", 32, -1), new Among("ot", 29, -1), + new Among("\u00E9rt", 29, -1), new Among("\u00F6t", 29, -1), + new Among("hez", -1, -1), new Among("hoz", -1, -1), + new Among("h\u00F6z", -1, -1), new Among("v\u00E1", -1, -1), + new Among("v\u00E9", -1, -1) + ], + a_5 = [new Among("\u00E1n", -1, 2), + new Among("\u00E9n", -1, 1), new Among("\u00E1nk\u00E9nt", -1, 3) + ], + a_6 = [ + new Among("stul", -1, 2), new Among("astul", 0, 1), + new Among("\u00E1stul", 0, 3), new Among("st\u00FCl", -1, 2), + new Among("est\u00FCl", 3, 1), new Among("\u00E9st\u00FCl", 3, 4) + ], + a_7 = [ + new Among("\u00E1", -1, 1), new Among("\u00E9", -1, 2) + ], + a_8 = [ + new Among("k", -1, 7), new Among("ak", 0, 4), + new Among("ek", 0, 6), new Among("ok", 0, 5), + new Among("\u00E1k", 0, 1), new Among("\u00E9k", 0, 2), + new Among("\u00F6k", 0, 3) + ], + a_9 = [new Among("\u00E9i", -1, 7), + new Among("\u00E1\u00E9i", 0, 6), new Among("\u00E9\u00E9i", 0, 5), + new Among("\u00E9", -1, 9), new Among("k\u00E9", 3, 4), + new Among("ak\u00E9", 4, 1), new Among("ek\u00E9", 4, 1), + new Among("ok\u00E9", 4, 1), new Among("\u00E1k\u00E9", 4, 3), + new Among("\u00E9k\u00E9", 4, 2), new Among("\u00F6k\u00E9", 4, 1), + new Among("\u00E9\u00E9", 3, 8) + ], + a_10 = [new Among("a", -1, 18), + new Among("ja", 0, 17), new Among("d", -1, 16), + new Among("ad", 2, 13), new Among("ed", 2, 13), + new Among("od", 2, 13), new Among("\u00E1d", 2, 14), + new Among("\u00E9d", 2, 15), new Among("\u00F6d", 2, 13), + new Among("e", -1, 18), new Among("je", 9, 17), + new Among("nk", -1, 4), new Among("unk", 11, 1), + new Among("\u00E1nk", 11, 2), new Among("\u00E9nk", 11, 3), + new Among("\u00FCnk", 11, 1), new Among("uk", -1, 8), + new Among("juk", 16, 7), new Among("\u00E1juk", 17, 5), + new Among("\u00FCk", -1, 8), new Among("j\u00FCk", 19, 7), + new Among("\u00E9j\u00FCk", 20, 6), new Among("m", -1, 12), + new Among("am", 22, 9), new Among("em", 22, 9), + new Among("om", 22, 9), new Among("\u00E1m", 22, 10), + new Among("\u00E9m", 22, 11), new Among("o", -1, 18), + new Among("\u00E1", -1, 19), new Among("\u00E9", -1, 20) + ], + a_11 = [ + new Among("id", -1, 10), new Among("aid", 0, 9), + new Among("jaid", 1, 6), new Among("eid", 0, 9), + new Among("jeid", 3, 6), new Among("\u00E1id", 0, 7), + new Among("\u00E9id", 0, 8), new Among("i", -1, 15), + new Among("ai", 7, 14), new Among("jai", 8, 11), + new Among("ei", 7, 14), new Among("jei", 10, 11), + new Among("\u00E1i", 7, 12), new Among("\u00E9i", 7, 13), + new Among("itek", -1, 24), new Among("eitek", 14, 21), + new Among("jeitek", 15, 20), new Among("\u00E9itek", 14, 23), + new Among("ik", -1, 29), new Among("aik", 18, 26), + new Among("jaik", 19, 25), new Among("eik", 18, 26), + new Among("jeik", 21, 25), new Among("\u00E1ik", 18, 27), + new Among("\u00E9ik", 18, 28), new Among("ink", -1, 20), + new Among("aink", 25, 17), new Among("jaink", 26, 16), + new Among("eink", 25, 17), new Among("jeink", 28, 16), + new Among("\u00E1ink", 25, 18), new Among("\u00E9ink", 25, 19), + new Among("aitok", -1, 21), new Among("jaitok", 32, 20), + new Among("\u00E1itok", -1, 22), new Among("im", -1, 5), + new Among("aim", 35, 4), new Among("jaim", 36, 1), + new Among("eim", 35, 4), new Among("jeim", 38, 1), + new Among("\u00E1im", 35, 2), new Among("\u00E9im", 35, 3) + ], + g_v = [ + 17, 65, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 17, 52, 14 + ], + I_p1, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function r_mark_regions() { + var v_1 = sbp.cursor, + v_2; + I_p1 = sbp.limit; + if (sbp.in_grouping(g_v, 97, 252)) { + while (true) { + v_2 = sbp.cursor; + if (sbp.out_grouping(g_v, 97, 252)) { + sbp.cursor = v_2; + if (!sbp.find_among(a_0, 8)) { + sbp.cursor = v_2; + if (v_2 < sbp.limit) + sbp.cursor++; + } + I_p1 = sbp.cursor; + return; + } + sbp.cursor = v_2; + if (v_2 >= sbp.limit) { + I_p1 = v_2; + return; + } + sbp.cursor++; + } + } + sbp.cursor = v_1; + if (sbp.out_grouping(g_v, 97, 252)) { + while (!sbp.in_grouping(g_v, 97, 252)) { + if (sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + } + I_p1 = sbp.cursor; + } + } + + function r_R1() { + return I_p1 <= sbp.cursor; + } + + function r_v_ending() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_1, 2); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + sbp.slice_from("a"); + break; + case 2: + sbp.slice_from("e"); + break; + } + } + } + } + + function r_double() { + var v_1 = sbp.limit - sbp.cursor; + if (!sbp.find_among_b(a_2, 23)) + return false; + sbp.cursor = sbp.limit - v_1; + return true; + } + + function r_undouble() { + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + sbp.ket = sbp.cursor; + var c = sbp.cursor - 1; + if (sbp.limit_backward <= c && c <= sbp.limit) { + sbp.cursor = c; + sbp.bra = c; + sbp.slice_del(); + } + } + } + + function r_instrum() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_3, 2); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + if (among_var == 1 || among_var == 2) + if (!r_double()) + return; + sbp.slice_del(); + r_undouble(); + } + } + } + + function r_case() { + sbp.ket = sbp.cursor; + if (sbp.find_among_b(a_4, 44)) { + sbp.bra = sbp.cursor; + if (r_R1()) { + sbp.slice_del(); + r_v_ending(); + } + } + } + + function r_case_special() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_5, 3); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + sbp.slice_from("e"); + break; + case 2: + case 3: + sbp.slice_from("a"); + break; + } + } + } + } + + function r_case_other() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_6, 6); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + case 2: + sbp.slice_del(); + break; + case 3: + sbp.slice_from("a"); + break; + case 4: + sbp.slice_from("e"); + break; + } + } + } + } + + function r_factive() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_7, 2); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + if (among_var == 1 || among_var == 2) + if (!r_double()) + return; + sbp.slice_del(); + r_undouble() + } + } + } + + function r_plural() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_8, 7); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + sbp.slice_from("a"); + break; + case 2: + sbp.slice_from("e"); + break; + case 3: + case 4: + case 5: + case 6: + case 7: + sbp.slice_del(); + break; + } + } + } + } + + function r_owned() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_9, 12); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + case 4: + case 7: + case 9: + sbp.slice_del(); + break; + case 2: + case 5: + case 8: + sbp.slice_from("e"); + break; + case 3: + case 6: + sbp.slice_from("a"); + break; + } + } + } + } + + function r_sing_owner() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_10, 31); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + case 4: + case 7: + case 8: + case 9: + case 12: + case 13: + case 16: + case 17: + case 18: + sbp.slice_del(); + break; + case 2: + case 5: + case 10: + case 14: + case 19: + sbp.slice_from("a"); + break; + case 3: + case 6: + case 11: + case 15: + case 20: + sbp.slice_from("e"); + break; + } + } + } + } + + function r_plur_owner() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_11, 42); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + case 4: + case 5: + case 6: + case 9: + case 10: + case 11: + case 14: + case 15: + case 16: + case 17: + case 20: + case 21: + case 24: + case 25: + case 26: + case 29: + sbp.slice_del(); + break; + case 2: + case 7: + case 12: + case 18: + case 22: + case 27: + sbp.slice_from("a"); + break; + case 3: + case 8: + case 13: + case 19: + case 23: + case 28: + sbp.slice_from("e"); + break; + } + } + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_instrum(); + sbp.cursor = sbp.limit; + r_case(); + sbp.cursor = sbp.limit; + r_case_special(); + sbp.cursor = sbp.limit; + r_case_other(); + sbp.cursor = sbp.limit; + r_factive(); + sbp.cursor = sbp.limit; + r_owned(); + sbp.cursor = sbp.limit; + r_sing_owner(); + sbp.cursor = sbp.limit; + r_plur_owner(); + sbp.cursor = sbp.limit; + r_plural(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.hu.stemmer, 'stemmer-hu'); + + /* stop word filter function */ + lunr.hu.stopWordFilter = function(token) { + if (lunr.hu.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.hu.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.hu.stopWordFilter.stopWords.length = 200; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.hu.stopWordFilter.stopWords.elements = ' a abban ahhoz ahogy ahol aki akik akkor alatt amely amelyek amelyekben amelyeket amelyet amelynek ami amikor amit amolyan amíg annak arra arról az azok azon azonban azt aztán azután azzal azért be belül benne bár cikk cikkek cikkeket csak de e ebben eddig egy egyes egyetlen egyik egyre egyéb egész ehhez ekkor el ellen elsõ elég elõ elõször elõtt emilyen ennek erre ez ezek ezen ezt ezzel ezért fel felé hanem hiszen hogy hogyan igen ill ill. illetve ilyen ilyenkor ismét ison itt jobban jó jól kell kellett keressünk keresztül ki kívül között közül legalább legyen lehet lehetett lenne lenni lesz lett maga magát majd majd meg mellett mely melyek mert mi mikor milyen minden mindenki mindent mindig mint mintha mit mivel miért most már más másik még míg nagy nagyobb nagyon ne nekem neki nem nincs néha néhány nélkül olyan ott pedig persze rá s saját sem semmi sok sokat sokkal szemben szerint szinte számára talán tehát teljes tovább továbbá több ugyanis utolsó után utána vagy vagyis vagyok valaki valami valamint való van vannak vele vissza viszont volna volt voltak voltam voltunk által általában át én éppen és így õ õk õket össze úgy új újabb újra'.split(' '); + + lunr.Pipeline.registerFunction(lunr.hu.stopWordFilter, 'stopWordFilter-hu'); + }; +})) diff --git a/static/js/lunr/lunr.hu.min.js b/static/js/lunr/lunr.hu.min.js new file mode 100644 index 0000000..1825c26 --- /dev/null +++ b/static/js/lunr/lunr.hu.min.js @@ -0,0 +1 @@ +!function(e,n){"function"==typeof define&&define.amd?define(n):"object"==typeof exports?module.exports=n():n()(e.lunr)}(this,function(){return function(n){if(void 0===n)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===n.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,p,r;n.hu=function(){this.pipeline.reset(),this.pipeline.add(n.hu.trimmer,n.hu.stopWordFilter,n.hu.stemmer)},n.hu.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",n.hu.trimmer=n.trimmerSupport.generateTrimmer(n.hu.wordCharacters),n.Pipeline.registerFunction(n.hu.trimmer,"trimmer-hu"),n.hu.stemmer=(e=n.stemmerSupport.Among,p=n.stemmerSupport.SnowballProgram,r=new function(){var r,i=[new e("cs",-1,-1),new e("dzs",-1,-1),new e("gy",-1,-1),new e("ly",-1,-1),new e("ny",-1,-1),new e("sz",-1,-1),new e("ty",-1,-1),new e("zs",-1,-1)],s=[new e("á",-1,1),new e("é",-1,2)],n=[new e("bb",-1,-1),new e("cc",-1,-1),new e("dd",-1,-1),new e("ff",-1,-1),new e("gg",-1,-1),new e("jj",-1,-1),new e("kk",-1,-1),new e("ll",-1,-1),new e("mm",-1,-1),new e("nn",-1,-1),new e("pp",-1,-1),new e("rr",-1,-1),new e("ccs",-1,-1),new e("ss",-1,-1),new e("zzs",-1,-1),new e("tt",-1,-1),new e("vv",-1,-1),new e("ggy",-1,-1),new e("lly",-1,-1),new e("nny",-1,-1),new e("tty",-1,-1),new e("ssz",-1,-1),new e("zz",-1,-1)],a=[new e("al",-1,1),new e("el",-1,2)],t=[new e("ba",-1,-1),new e("ra",-1,-1),new e("be",-1,-1),new e("re",-1,-1),new e("ig",-1,-1),new e("nak",-1,-1),new e("nek",-1,-1),new e("val",-1,-1),new e("vel",-1,-1),new e("ul",-1,-1),new e("nál",-1,-1),new e("nél",-1,-1),new e("ból",-1,-1),new e("ról",-1,-1),new e("tól",-1,-1),new e("bõl",-1,-1),new e("rõl",-1,-1),new e("tõl",-1,-1),new e("ül",-1,-1),new e("n",-1,-1),new e("an",19,-1),new e("ban",20,-1),new e("en",19,-1),new e("ben",22,-1),new e("képpen",22,-1),new e("on",19,-1),new e("ön",19,-1),new e("képp",-1,-1),new e("kor",-1,-1),new e("t",-1,-1),new e("at",29,-1),new e("et",29,-1),new e("ként",29,-1),new e("anként",32,-1),new e("enként",32,-1),new e("onként",32,-1),new e("ot",29,-1),new e("ért",29,-1),new e("öt",29,-1),new e("hez",-1,-1),new e("hoz",-1,-1),new e("höz",-1,-1),new e("vá",-1,-1),new e("vé",-1,-1)],w=[new e("án",-1,2),new e("én",-1,1),new e("ánként",-1,3)],o=[new e("stul",-1,2),new e("astul",0,1),new e("ástul",0,3),new e("stül",-1,2),new e("estül",3,1),new e("éstül",3,4)],c=[new e("á",-1,1),new e("é",-1,2)],l=[new e("k",-1,7),new e("ak",0,4),new e("ek",0,6),new e("ok",0,5),new e("ák",0,1),new e("ék",0,2),new e("ök",0,3)],m=[new e("éi",-1,7),new e("áéi",0,6),new e("ééi",0,5),new e("é",-1,9),new e("ké",3,4),new e("aké",4,1),new e("eké",4,1),new e("oké",4,1),new e("áké",4,3),new e("éké",4,2),new e("öké",4,1),new e("éé",3,8)],u=[new e("a",-1,18),new e("ja",0,17),new e("d",-1,16),new e("ad",2,13),new e("ed",2,13),new e("od",2,13),new e("ád",2,14),new e("éd",2,15),new e("öd",2,13),new e("e",-1,18),new e("je",9,17),new e("nk",-1,4),new e("unk",11,1),new e("ánk",11,2),new e("énk",11,3),new e("ünk",11,1),new e("uk",-1,8),new e("juk",16,7),new e("ájuk",17,5),new e("ük",-1,8),new e("jük",19,7),new e("éjük",20,6),new e("m",-1,12),new e("am",22,9),new e("em",22,9),new e("om",22,9),new e("ám",22,10),new e("ém",22,11),new e("o",-1,18),new e("á",-1,19),new e("é",-1,20)],k=[new e("id",-1,10),new e("aid",0,9),new e("jaid",1,6),new e("eid",0,9),new e("jeid",3,6),new e("áid",0,7),new e("éid",0,8),new e("i",-1,15),new e("ai",7,14),new e("jai",8,11),new e("ei",7,14),new e("jei",10,11),new e("ái",7,12),new e("éi",7,13),new e("itek",-1,24),new e("eitek",14,21),new e("jeitek",15,20),new e("éitek",14,23),new e("ik",-1,29),new e("aik",18,26),new e("jaik",19,25),new e("eik",18,26),new e("jeik",21,25),new e("áik",18,27),new e("éik",18,28),new e("ink",-1,20),new e("aink",25,17),new e("jaink",26,16),new e("eink",25,17),new e("jeink",28,16),new e("áink",25,18),new e("éink",25,19),new e("aitok",-1,21),new e("jaitok",32,20),new e("áitok",-1,22),new e("im",-1,5),new e("aim",35,4),new e("jaim",36,1),new e("eim",35,4),new e("jeim",38,1),new e("áim",35,2),new e("éim",35,3)],d=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,1,17,52,14],b=new p;function f(){return r<=b.cursor}function g(){var e=b.limit-b.cursor;return b.find_among_b(n,23)&&(b.cursor=b.limit-e,1)}function h(){var e;b.cursor>b.limit_backward&&(b.cursor--,b.ket=b.cursor,e=b.cursor-1,b.limit_backward<=e)&&e<=b.limit&&(b.cursor=e,b.bra=e,b.slice_del())}this.setCurrent=function(e){b.setCurrent(e)},this.getCurrent=function(){return b.getCurrent()},this.stem=function(){var e,n=b.cursor;if(function(){var e,n=b.cursor;if(r=b.limit,b.in_grouping(d,97,252))for(;;){if(e=b.cursor,b.out_grouping(d,97,252))return b.cursor=e,b.find_among(i,8)||(b.cursor=e)=b.limit)return r=e;b.cursor++}if(b.cursor=n,b.out_grouping(d,97,252)){for(;!b.in_grouping(d,97,252);){if(b.cursor>=b.limit)return;b.cursor++}r=b.cursor}}(),b.limit_backward=n,b.cursor=b.limit,b.ket=b.cursor,(n=b.find_among_b(a,2))&&(b.bra=b.cursor,f())&&(1!=n&&2!=n||g())&&(b.slice_del(),h()),b.cursor=b.limit,b.ket=b.cursor,b.find_among_b(t,44)&&(b.bra=b.cursor,f())&&(b.slice_del(),b.ket=b.cursor,e=b.find_among_b(s,2))&&(b.bra=b.cursor,f()))switch(e){case 1:b.slice_from("a");break;case 2:b.slice_from("e")}if(b.cursor=b.limit,b.ket=b.cursor,(n=b.find_among_b(w,3))&&(b.bra=b.cursor,f()))switch(n){case 1:b.slice_from("e");break;case 2:case 3:b.slice_from("a")}if(b.cursor=b.limit,b.ket=b.cursor,(n=b.find_among_b(o,6))&&(b.bra=b.cursor,f()))switch(n){case 1:case 2:b.slice_del();break;case 3:b.slice_from("a");break;case 4:b.slice_from("e")}if(b.cursor=b.limit,b.ket=b.cursor,(n=b.find_among_b(c,2))&&(b.bra=b.cursor,f())&&(1!=n&&2!=n||g())&&(b.slice_del(),h()),b.cursor=b.limit,b.ket=b.cursor,(n=b.find_among_b(m,12))&&(b.bra=b.cursor,f()))switch(n){case 1:case 4:case 7:case 9:b.slice_del();break;case 2:case 5:case 8:b.slice_from("e");break;case 3:case 6:b.slice_from("a")}if(b.cursor=b.limit,b.ket=b.cursor,(n=b.find_among_b(u,31))&&(b.bra=b.cursor,f()))switch(n){case 1:case 4:case 7:case 8:case 9:case 12:case 13:case 16:case 17:case 18:b.slice_del();break;case 2:case 5:case 10:case 14:case 19:b.slice_from("a");break;case 3:case 6:case 11:case 15:case 20:b.slice_from("e")}if(b.cursor=b.limit,b.ket=b.cursor,(n=b.find_among_b(k,42))&&(b.bra=b.cursor,f()))switch(n){case 1:case 4:case 5:case 6:case 9:case 10:case 11:case 14:case 15:case 16:case 17:case 20:case 21:case 24:case 25:case 26:case 29:b.slice_del();break;case 2:case 7:case 12:case 18:case 22:case 27:b.slice_from("a");break;case 3:case 8:case 13:case 19:case 23:case 28:b.slice_from("e")}if(b.cursor=b.limit,b.ket=b.cursor,(n=b.find_among_b(l,7))&&(b.bra=b.cursor,f()))switch(n){case 1:b.slice_from("a");break;case 2:b.slice_from("e");break;case 3:case 4:case 5:case 6:case 7:b.slice_del()}return!0}},function(e){return r.setCurrent(e),r.stem(),r.getCurrent()}),n.Pipeline.registerFunction(n.hu.stemmer,"stemmer-hu"),n.hu.stopWordFilter=function(e){if(-1===n.hu.stopWordFilter.stopWords.indexOf(e))return e},n.hu.stopWordFilter.stopWords=new n.SortedSet,n.hu.stopWordFilter.stopWords.length=200,n.hu.stopWordFilter.stopWords.elements=" a abban ahhoz ahogy ahol aki akik akkor alatt amely amelyek amelyekben amelyeket amelyet amelynek ami amikor amit amolyan amíg annak arra arról az azok azon azonban azt aztán azután azzal azért be belül benne bár cikk cikkek cikkeket csak de e ebben eddig egy egyes egyetlen egyik egyre egyéb egész ehhez ekkor el ellen elsõ elég elõ elõször elõtt emilyen ennek erre ez ezek ezen ezt ezzel ezért fel felé hanem hiszen hogy hogyan igen ill ill. illetve ilyen ilyenkor ismét ison itt jobban jó jól kell kellett keressünk keresztül ki kívül között közül legalább legyen lehet lehetett lenne lenni lesz lett maga magát majd majd meg mellett mely melyek mert mi mikor milyen minden mindenki mindent mindig mint mintha mit mivel miért most már más másik még míg nagy nagyobb nagyon ne nekem neki nem nincs néha néhány nélkül olyan ott pedig persze rá s saját sem semmi sok sokat sokkal szemben szerint szinte számára talán tehát teljes tovább továbbá több ugyanis utolsó után utána vagy vagyis vagyok valaki valami valamint való van vannak vele vissza viszont volna volt voltak voltam voltunk által általában át én éppen és így õ õk õket össze úgy új újabb újra".split(" "),n.Pipeline.registerFunction(n.hu.stopWordFilter,"stopWordFilter-hu")}}); diff --git a/static/js/lunr/lunr.it.js b/static/js/lunr/lunr.it.js new file mode 100644 index 0000000..90014d7 --- /dev/null +++ b/static/js/lunr/lunr.it.js @@ -0,0 +1,612 @@ +/*! + * Lunr languages, `Italian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.it = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.it.trimmer, + lunr.it.stopWordFilter, + lunr.it.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.it.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.it.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.it.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.it.trimmer, 'trimmer-it'); + + /* lunr stemmer function */ + lunr.it.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function ItalianStemmer() { + var a_0 = [new Among("", -1, 7), new Among("qu", 0, 6), + new Among("\u00E1", 0, 1), new Among("\u00E9", 0, 2), + new Among("\u00ED", 0, 3), new Among("\u00F3", 0, 4), + new Among("\u00FA", 0, 5) + ], + a_1 = [new Among("", -1, 3), + new Among("I", 0, 1), new Among("U", 0, 2) + ], + a_2 = [ + new Among("la", -1, -1), new Among("cela", 0, -1), + new Among("gliela", 0, -1), new Among("mela", 0, -1), + new Among("tela", 0, -1), new Among("vela", 0, -1), + new Among("le", -1, -1), new Among("cele", 6, -1), + new Among("gliele", 6, -1), new Among("mele", 6, -1), + new Among("tele", 6, -1), new Among("vele", 6, -1), + new Among("ne", -1, -1), new Among("cene", 12, -1), + new Among("gliene", 12, -1), new Among("mene", 12, -1), + new Among("sene", 12, -1), new Among("tene", 12, -1), + new Among("vene", 12, -1), new Among("ci", -1, -1), + new Among("li", -1, -1), new Among("celi", 20, -1), + new Among("glieli", 20, -1), new Among("meli", 20, -1), + new Among("teli", 20, -1), new Among("veli", 20, -1), + new Among("gli", 20, -1), new Among("mi", -1, -1), + new Among("si", -1, -1), new Among("ti", -1, -1), + new Among("vi", -1, -1), new Among("lo", -1, -1), + new Among("celo", 31, -1), new Among("glielo", 31, -1), + new Among("melo", 31, -1), new Among("telo", 31, -1), + new Among("velo", 31, -1) + ], + a_3 = [new Among("ando", -1, 1), + new Among("endo", -1, 1), new Among("ar", -1, 2), + new Among("er", -1, 2), new Among("ir", -1, 2) + ], + a_4 = [ + new Among("ic", -1, -1), new Among("abil", -1, -1), + new Among("os", -1, -1), new Among("iv", -1, 1) + ], + a_5 = [ + new Among("ic", -1, 1), new Among("abil", -1, 1), + new Among("iv", -1, 1) + ], + a_6 = [new Among("ica", -1, 1), + new Among("logia", -1, 3), new Among("osa", -1, 1), + new Among("ista", -1, 1), new Among("iva", -1, 9), + new Among("anza", -1, 1), new Among("enza", -1, 5), + new Among("ice", -1, 1), new Among("atrice", 7, 1), + new Among("iche", -1, 1), new Among("logie", -1, 3), + new Among("abile", -1, 1), new Among("ibile", -1, 1), + new Among("usione", -1, 4), new Among("azione", -1, 2), + new Among("uzione", -1, 4), new Among("atore", -1, 2), + new Among("ose", -1, 1), new Among("ante", -1, 1), + new Among("mente", -1, 1), new Among("amente", 19, 7), + new Among("iste", -1, 1), new Among("ive", -1, 9), + new Among("anze", -1, 1), new Among("enze", -1, 5), + new Among("ici", -1, 1), new Among("atrici", 25, 1), + new Among("ichi", -1, 1), new Among("abili", -1, 1), + new Among("ibili", -1, 1), new Among("ismi", -1, 1), + new Among("usioni", -1, 4), new Among("azioni", -1, 2), + new Among("uzioni", -1, 4), new Among("atori", -1, 2), + new Among("osi", -1, 1), new Among("anti", -1, 1), + new Among("amenti", -1, 6), new Among("imenti", -1, 6), + new Among("isti", -1, 1), new Among("ivi", -1, 9), + new Among("ico", -1, 1), new Among("ismo", -1, 1), + new Among("oso", -1, 1), new Among("amento", -1, 6), + new Among("imento", -1, 6), new Among("ivo", -1, 9), + new Among("it\u00E0", -1, 8), new Among("ist\u00E0", -1, 1), + new Among("ist\u00E8", -1, 1), new Among("ist\u00EC", -1, 1) + ], + a_7 = [ + new Among("isca", -1, 1), new Among("enda", -1, 1), + new Among("ata", -1, 1), new Among("ita", -1, 1), + new Among("uta", -1, 1), new Among("ava", -1, 1), + new Among("eva", -1, 1), new Among("iva", -1, 1), + new Among("erebbe", -1, 1), new Among("irebbe", -1, 1), + new Among("isce", -1, 1), new Among("ende", -1, 1), + new Among("are", -1, 1), new Among("ere", -1, 1), + new Among("ire", -1, 1), new Among("asse", -1, 1), + new Among("ate", -1, 1), new Among("avate", 16, 1), + new Among("evate", 16, 1), new Among("ivate", 16, 1), + new Among("ete", -1, 1), new Among("erete", 20, 1), + new Among("irete", 20, 1), new Among("ite", -1, 1), + new Among("ereste", -1, 1), new Among("ireste", -1, 1), + new Among("ute", -1, 1), new Among("erai", -1, 1), + new Among("irai", -1, 1), new Among("isci", -1, 1), + new Among("endi", -1, 1), new Among("erei", -1, 1), + new Among("irei", -1, 1), new Among("assi", -1, 1), + new Among("ati", -1, 1), new Among("iti", -1, 1), + new Among("eresti", -1, 1), new Among("iresti", -1, 1), + new Among("uti", -1, 1), new Among("avi", -1, 1), + new Among("evi", -1, 1), new Among("ivi", -1, 1), + new Among("isco", -1, 1), new Among("ando", -1, 1), + new Among("endo", -1, 1), new Among("Yamo", -1, 1), + new Among("iamo", -1, 1), new Among("avamo", -1, 1), + new Among("evamo", -1, 1), new Among("ivamo", -1, 1), + new Among("eremo", -1, 1), new Among("iremo", -1, 1), + new Among("assimo", -1, 1), new Among("ammo", -1, 1), + new Among("emmo", -1, 1), new Among("eremmo", 54, 1), + new Among("iremmo", 54, 1), new Among("immo", -1, 1), + new Among("ano", -1, 1), new Among("iscano", 58, 1), + new Among("avano", 58, 1), new Among("evano", 58, 1), + new Among("ivano", 58, 1), new Among("eranno", -1, 1), + new Among("iranno", -1, 1), new Among("ono", -1, 1), + new Among("iscono", 65, 1), new Among("arono", 65, 1), + new Among("erono", 65, 1), new Among("irono", 65, 1), + new Among("erebbero", -1, 1), new Among("irebbero", -1, 1), + new Among("assero", -1, 1), new Among("essero", -1, 1), + new Among("issero", -1, 1), new Among("ato", -1, 1), + new Among("ito", -1, 1), new Among("uto", -1, 1), + new Among("avo", -1, 1), new Among("evo", -1, 1), + new Among("ivo", -1, 1), new Among("ar", -1, 1), + new Among("ir", -1, 1), new Among("er\u00E0", -1, 1), + new Among("ir\u00E0", -1, 1), new Among("er\u00F2", -1, 1), + new Among("ir\u00F2", -1, 1) + ], + g_v = [17, 65, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 128, 128, 8, 2, 1 + ], + g_AEIO = [17, 65, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 128, 8, 2 + ], + g_CG = [17], + I_p2, I_p1, I_pV, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function habr1(c1, c2, v_1) { + if (sbp.eq_s(1, c1)) { + sbp.ket = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 249)) { + sbp.slice_from(c2); + sbp.cursor = v_1; + return true; + } + } + return false; + } + + function r_prelude() { + var among_var, v_1 = sbp.cursor, + v_2, v_3, v_4; + while (true) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among(a_0, 7); + if (among_var) { + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("\u00E0"); + continue; + case 2: + sbp.slice_from("\u00E8"); + continue; + case 3: + sbp.slice_from("\u00EC"); + continue; + case 4: + sbp.slice_from("\u00F2"); + continue; + case 5: + sbp.slice_from("\u00F9"); + continue; + case 6: + sbp.slice_from("qU"); + continue; + case 7: + if (sbp.cursor >= sbp.limit) + break; + sbp.cursor++; + continue; + } + } + break; + } + sbp.cursor = v_1; + while (true) { + v_2 = sbp.cursor; + while (true) { + v_3 = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 249)) { + sbp.bra = sbp.cursor; + v_4 = sbp.cursor; + if (habr1("u", "U", v_3)) + break; + sbp.cursor = v_4; + if (habr1("i", "I", v_3)) + break; + } + sbp.cursor = v_3; + if (sbp.cursor >= sbp.limit) { + sbp.cursor = v_2; + return; + } + sbp.cursor++; + } + } + } + + function habr2(v_1) { + sbp.cursor = v_1; + if (!sbp.in_grouping(g_v, 97, 249)) + return false; + while (!sbp.out_grouping(g_v, 97, 249)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + return true; + } + + function habr3() { + if (sbp.in_grouping(g_v, 97, 249)) { + var v_1 = sbp.cursor; + if (sbp.out_grouping(g_v, 97, 249)) { + while (!sbp.in_grouping(g_v, 97, 249)) { + if (sbp.cursor >= sbp.limit) + return habr2(v_1); + sbp.cursor++; + } + return true; + } + return habr2(v_1); + } + return false; + } + + function habr4() { + var v_1 = sbp.cursor, + v_2; + if (!habr3()) { + sbp.cursor = v_1; + if (!sbp.out_grouping(g_v, 97, 249)) + return; + v_2 = sbp.cursor; + if (sbp.out_grouping(g_v, 97, 249)) { + while (!sbp.in_grouping(g_v, 97, 249)) { + if (sbp.cursor >= sbp.limit) { + sbp.cursor = v_2; + if (sbp.in_grouping(g_v, 97, 249) && sbp.cursor < sbp.limit) + sbp.cursor++; + return; + } + sbp.cursor++; + } + I_pV = sbp.cursor; + return; + } + sbp.cursor = v_2; + if (!sbp.in_grouping(g_v, 97, 249) || sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + } + I_pV = sbp.cursor; + } + + function habr5() { + while (!sbp.in_grouping(g_v, 97, 249)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 249)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + return true; + } + + function r_mark_regions() { + var v_1 = sbp.cursor; + I_pV = sbp.limit; + I_p1 = I_pV; + I_p2 = I_pV; + habr4(); + sbp.cursor = v_1; + if (habr5()) { + I_p1 = sbp.cursor; + if (habr5()) + I_p2 = sbp.cursor; + } + } + + function r_postlude() { + var among_var; + while (true) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among(a_1, 3); + if (!among_var) + break; + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("i"); + break; + case 2: + sbp.slice_from("u"); + break; + case 3: + if (sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + break; + } + } + } + + function r_RV() { + return I_pV <= sbp.cursor; + } + + function r_R1() { + return I_p1 <= sbp.cursor; + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function r_attached_pronoun() { + var among_var; + sbp.ket = sbp.cursor; + if (sbp.find_among_b(a_2, 37)) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among_b(a_3, 5); + if (among_var && r_RV()) { + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + sbp.slice_from("e"); + break; + } + } + } + } + + function r_standard_suffix() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_6, 51); + if (!among_var) + return false; + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (!r_R2()) + return false; + sbp.slice_del(); + break; + case 2: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "ic")) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + } + break; + case 3: + if (!r_R2()) + return false; + sbp.slice_from("log"); + break; + case 4: + if (!r_R2()) + return false; + sbp.slice_from("u"); + break; + case 5: + if (!r_R2()) + return false; + sbp.slice_from("ente"); + break; + case 6: + if (!r_RV()) + return false; + sbp.slice_del(); + break; + case 7: + if (!r_R1()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_4, 4); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R2()) { + sbp.slice_del(); + if (among_var == 1) { + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "at")) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + } + } + } + } + break; + case 8: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_5, 3); + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1) + if (r_R2()) + sbp.slice_del(); + } + break; + case 9: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "at")) { + sbp.bra = sbp.cursor; + if (r_R2()) { + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "ic")) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + } + } + } + break; + } + return true; + } + + function r_verb_suffix() { + var among_var, v_1; + if (sbp.cursor >= I_pV) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_pV; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_7, 87); + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1) + sbp.slice_del(); + } + sbp.limit_backward = v_1; + } + } + + function habr6() { + var v_1 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (sbp.in_grouping_b(g_AEIO, 97, 242)) { + sbp.bra = sbp.cursor; + if (r_RV()) { + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "i")) { + sbp.bra = sbp.cursor; + if (r_RV()) { + sbp.slice_del(); + return; + } + } + } + } + sbp.cursor = sbp.limit - v_1; + } + + function r_vowel_suffix() { + habr6(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "h")) { + sbp.bra = sbp.cursor; + if (sbp.in_grouping_b(g_CG, 99, 103)) + if (r_RV()) + sbp.slice_del(); + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_prelude(); + sbp.cursor = v_1; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_attached_pronoun(); + sbp.cursor = sbp.limit; + if (!r_standard_suffix()) { + sbp.cursor = sbp.limit; + r_verb_suffix(); + } + sbp.cursor = sbp.limit; + r_vowel_suffix(); + sbp.cursor = sbp.limit_backward; + r_postlude(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.it.stemmer, 'stemmer-it'); + + /* stop word filter function */ + lunr.it.stopWordFilter = function(token) { + if (lunr.it.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.it.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.it.stopWordFilter.stopWords.length = 280; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.it.stopWordFilter.stopWords.elements = ' a abbia abbiamo abbiano abbiate ad agl agli ai al all alla alle allo anche avemmo avendo avesse avessero avessi avessimo aveste avesti avete aveva avevamo avevano avevate avevi avevo avrai avranno avrebbe avrebbero avrei avremmo avremo avreste avresti avrete avrà avrò avuta avute avuti avuto c che chi ci coi col come con contro cui da dagl dagli dai dal dall dalla dalle dallo degl degli dei del dell della delle dello di dov dove e ebbe ebbero ebbi ed era erano eravamo eravate eri ero essendo faccia facciamo facciano facciate faccio facemmo facendo facesse facessero facessi facessimo faceste facesti faceva facevamo facevano facevate facevi facevo fai fanno farai faranno farebbe farebbero farei faremmo faremo fareste faresti farete farà farò fece fecero feci fosse fossero fossi fossimo foste fosti fu fui fummo furono gli ha hai hanno ho i il in io l la le lei li lo loro lui ma mi mia mie miei mio ne negl negli nei nel nell nella nelle nello noi non nostra nostre nostri nostro o per perché più quale quanta quante quanti quanto quella quelle quelli quello questa queste questi questo sarai saranno sarebbe sarebbero sarei saremmo saremo sareste saresti sarete sarà sarò se sei si sia siamo siano siate siete sono sta stai stando stanno starai staranno starebbe starebbero starei staremmo staremo stareste staresti starete starà starò stava stavamo stavano stavate stavi stavo stemmo stesse stessero stessi stessimo steste stesti stette stettero stetti stia stiamo stiano stiate sto su sua sue sugl sugli sui sul sull sulla sulle sullo suo suoi ti tra tu tua tue tuo tuoi tutti tutto un una uno vi voi vostra vostre vostri vostro è'.split(' '); + + lunr.Pipeline.registerFunction(lunr.it.stopWordFilter, 'stopWordFilter-it'); + }; +})) diff --git a/static/js/lunr/lunr.it.min.js b/static/js/lunr/lunr.it.min.js new file mode 100644 index 0000000..36b30b5 --- /dev/null +++ b/static/js/lunr/lunr.it.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,i,n;r.it=function(){this.pipeline.reset(),this.pipeline.add(r.it.trimmer,r.it.stopWordFilter,r.it.stemmer)},r.it.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.it.trimmer=r.trimmerSupport.generateTrimmer(r.it.wordCharacters),r.Pipeline.registerFunction(r.it.trimmer,"trimmer-it"),r.it.stemmer=(e=r.stemmerSupport.Among,i=r.stemmerSupport.SnowballProgram,n=new function(){var n,o,s,t=[new e("",-1,7),new e("qu",0,6),new e("á",0,1),new e("é",0,2),new e("í",0,3),new e("ó",0,4),new e("ú",0,5)],a=[new e("",-1,3),new e("I",0,1),new e("U",0,2)],u=[new e("la",-1,-1),new e("cela",0,-1),new e("gliela",0,-1),new e("mela",0,-1),new e("tela",0,-1),new e("vela",0,-1),new e("le",-1,-1),new e("cele",6,-1),new e("gliele",6,-1),new e("mele",6,-1),new e("tele",6,-1),new e("vele",6,-1),new e("ne",-1,-1),new e("cene",12,-1),new e("gliene",12,-1),new e("mene",12,-1),new e("sene",12,-1),new e("tene",12,-1),new e("vene",12,-1),new e("ci",-1,-1),new e("li",-1,-1),new e("celi",20,-1),new e("glieli",20,-1),new e("meli",20,-1),new e("teli",20,-1),new e("veli",20,-1),new e("gli",20,-1),new e("mi",-1,-1),new e("si",-1,-1),new e("ti",-1,-1),new e("vi",-1,-1),new e("lo",-1,-1),new e("celo",31,-1),new e("glielo",31,-1),new e("melo",31,-1),new e("telo",31,-1),new e("velo",31,-1)],c=[new e("ando",-1,1),new e("endo",-1,1),new e("ar",-1,2),new e("er",-1,2),new e("ir",-1,2)],w=[new e("ic",-1,-1),new e("abil",-1,-1),new e("os",-1,-1),new e("iv",-1,1)],l=[new e("ic",-1,1),new e("abil",-1,1),new e("iv",-1,1)],m=[new e("ica",-1,1),new e("logia",-1,3),new e("osa",-1,1),new e("ista",-1,1),new e("iva",-1,9),new e("anza",-1,1),new e("enza",-1,5),new e("ice",-1,1),new e("atrice",7,1),new e("iche",-1,1),new e("logie",-1,3),new e("abile",-1,1),new e("ibile",-1,1),new e("usione",-1,4),new e("azione",-1,2),new e("uzione",-1,4),new e("atore",-1,2),new e("ose",-1,1),new e("ante",-1,1),new e("mente",-1,1),new e("amente",19,7),new e("iste",-1,1),new e("ive",-1,9),new e("anze",-1,1),new e("enze",-1,5),new e("ici",-1,1),new e("atrici",25,1),new e("ichi",-1,1),new e("abili",-1,1),new e("ibili",-1,1),new e("ismi",-1,1),new e("usioni",-1,4),new e("azioni",-1,2),new e("uzioni",-1,4),new e("atori",-1,2),new e("osi",-1,1),new e("anti",-1,1),new e("amenti",-1,6),new e("imenti",-1,6),new e("isti",-1,1),new e("ivi",-1,9),new e("ico",-1,1),new e("ismo",-1,1),new e("oso",-1,1),new e("amento",-1,6),new e("imento",-1,6),new e("ivo",-1,9),new e("ità",-1,8),new e("istà",-1,1),new e("istè",-1,1),new e("istì",-1,1)],f=[new e("isca",-1,1),new e("enda",-1,1),new e("ata",-1,1),new e("ita",-1,1),new e("uta",-1,1),new e("ava",-1,1),new e("eva",-1,1),new e("iva",-1,1),new e("erebbe",-1,1),new e("irebbe",-1,1),new e("isce",-1,1),new e("ende",-1,1),new e("are",-1,1),new e("ere",-1,1),new e("ire",-1,1),new e("asse",-1,1),new e("ate",-1,1),new e("avate",16,1),new e("evate",16,1),new e("ivate",16,1),new e("ete",-1,1),new e("erete",20,1),new e("irete",20,1),new e("ite",-1,1),new e("ereste",-1,1),new e("ireste",-1,1),new e("ute",-1,1),new e("erai",-1,1),new e("irai",-1,1),new e("isci",-1,1),new e("endi",-1,1),new e("erei",-1,1),new e("irei",-1,1),new e("assi",-1,1),new e("ati",-1,1),new e("iti",-1,1),new e("eresti",-1,1),new e("iresti",-1,1),new e("uti",-1,1),new e("avi",-1,1),new e("evi",-1,1),new e("ivi",-1,1),new e("isco",-1,1),new e("ando",-1,1),new e("endo",-1,1),new e("Yamo",-1,1),new e("iamo",-1,1),new e("avamo",-1,1),new e("evamo",-1,1),new e("ivamo",-1,1),new e("eremo",-1,1),new e("iremo",-1,1),new e("assimo",-1,1),new e("ammo",-1,1),new e("emmo",-1,1),new e("eremmo",54,1),new e("iremmo",54,1),new e("immo",-1,1),new e("ano",-1,1),new e("iscano",58,1),new e("avano",58,1),new e("evano",58,1),new e("ivano",58,1),new e("eranno",-1,1),new e("iranno",-1,1),new e("ono",-1,1),new e("iscono",65,1),new e("arono",65,1),new e("erono",65,1),new e("irono",65,1),new e("erebbero",-1,1),new e("irebbero",-1,1),new e("assero",-1,1),new e("essero",-1,1),new e("issero",-1,1),new e("ato",-1,1),new e("ito",-1,1),new e("uto",-1,1),new e("avo",-1,1),new e("evo",-1,1),new e("ivo",-1,1),new e("ar",-1,1),new e("ir",-1,1),new e("erà",-1,1),new e("irà",-1,1),new e("erò",-1,1),new e("irò",-1,1)],v=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,128,128,8,2,1],b=[17,65,0,0,0,0,0,0,0,0,0,0,0,0,0,128,128,8,2],d=[17],_=new i;function g(e,r,i){return _.eq_s(1,e)&&(_.ket=_.cursor,_.in_grouping(v,97,249))&&(_.slice_from(r),_.cursor=i,1)}function p(e){if(_.cursor=e,!_.in_grouping(v,97,249))return!1;for(;!_.out_grouping(v,97,249);){if(_.cursor>=_.limit)return!1;_.cursor++}return!0}function k(){for(;!_.in_grouping(v,97,249);){if(_.cursor>=_.limit)return;_.cursor++}for(;!_.out_grouping(v,97,249);){if(_.cursor>=_.limit)return;_.cursor++}return 1}function h(){return s<=_.cursor}function q(){return n<=_.cursor}this.setCurrent=function(e){_.setCurrent(e)},this.getCurrent=function(){return _.getCurrent()},this.stem=function(){var e,r,i=_.cursor;if(function(){for(var e,r,i,n,o=_.cursor;;){if(_.bra=_.cursor,e=_.find_among(t,7))switch(_.ket=_.cursor,e){case 1:_.slice_from("à");continue;case 2:_.slice_from("è");continue;case 3:_.slice_from("ì");continue;case 4:_.slice_from("ò");continue;case 5:_.slice_from("ù");continue;case 6:_.slice_from("qU");continue;case 7:if(!(_.cursor>=_.limit)){_.cursor++;continue}}break}for(_.cursor=o;;)for(r=_.cursor;;){if(i=_.cursor,_.in_grouping(v,97,249)){if(_.bra=_.cursor,n=_.cursor,g("u","U",i))break;if(_.cursor=n,g("i","I",i))break}if(_.cursor=i,_.cursor>=_.limit)return _.cursor=r;_.cursor++}}(),_.cursor=i,e=_.cursor,s=_.limit,n=o=s,function(){var e,r=_.cursor;if(!function(){if(_.in_grouping(v,97,249)){var e=_.cursor;if(_.out_grouping(v,97,249)){for(;!_.in_grouping(v,97,249);){if(_.cursor>=_.limit)return p(e);_.cursor++}return 1}return p(e)}}()){if(_.cursor=r,!_.out_grouping(v,97,249))return;if(e=_.cursor,_.out_grouping(v,97,249)){for(;!_.in_grouping(v,97,249);){if(_.cursor>=_.limit)return _.cursor=e,_.in_grouping(v,97,249)&&_.cursor<_.limit&&_.cursor++;_.cursor++}return s=_.cursor}if(_.cursor=e,!_.in_grouping(v,97,249)||_.cursor>=_.limit)return;_.cursor++}s=_.cursor}(),_.cursor=e,k()&&(o=_.cursor,k())&&(n=_.cursor),_.limit_backward=i,_.cursor=_.limit,_.ket=_.cursor,_.find_among_b(u,37)&&(_.bra=_.cursor,r=_.find_among_b(c,5))&&h())switch(r){case 1:_.slice_del();break;case 2:_.slice_from("e")}return _.cursor=_.limit,function(){var e;if(_.ket=_.cursor,e=_.find_among_b(m,51)){switch(_.bra=_.cursor,e){case 1:if(!q())return;_.slice_del();break;case 2:if(!q())return;_.slice_del(),_.ket=_.cursor,_.eq_s_b(2,"ic")&&(_.bra=_.cursor,q())&&_.slice_del();break;case 3:if(!q())return;_.slice_from("log");break;case 4:if(!q())return;_.slice_from("u");break;case 5:if(!q())return;_.slice_from("ente");break;case 6:if(!h())return;_.slice_del();break;case 7:if(!(o<=_.cursor))return;_.slice_del(),_.ket=_.cursor,(e=_.find_among_b(w,4))&&(_.bra=_.cursor,q())&&(_.slice_del(),1==e)&&(_.ket=_.cursor,_.eq_s_b(2,"at"))&&(_.bra=_.cursor,q())&&_.slice_del();break;case 8:if(!q())return;_.slice_del(),_.ket=_.cursor,(e=_.find_among_b(l,3))&&(_.bra=_.cursor,1==e)&&q()&&_.slice_del();break;case 9:if(!q())return;_.slice_del(),_.ket=_.cursor,_.eq_s_b(2,"at")&&(_.bra=_.cursor,q())&&(_.slice_del(),_.ket=_.cursor,_.eq_s_b(2,"ic"))&&(_.bra=_.cursor,q())&&_.slice_del()}return 1}}()||(_.cursor=_.limit,_.cursor>=s&&(e=_.limit_backward,_.limit_backward=s,_.ket=_.cursor,(i=_.find_among_b(f,87))&&(_.bra=_.cursor,1==i)&&_.slice_del(),_.limit_backward=e)),_.cursor=_.limit,r=_.limit-_.cursor,_.ket=_.cursor,_.in_grouping_b(b,97,242)&&(_.bra=_.cursor,h())&&(_.slice_del(),_.ket=_.cursor,_.eq_s_b(1,"i"))&&(_.bra=_.cursor,h())?_.slice_del():_.cursor=_.limit-r,_.ket=_.cursor,_.eq_s_b(1,"h")&&(_.bra=_.cursor,_.in_grouping_b(d,99,103))&&h()&&_.slice_del(),_.cursor=_.limit_backward,function(){for(var e;_.bra=_.cursor,e=_.find_among(a,3);)switch(_.ket=_.cursor,e){case 1:_.slice_from("i");break;case 2:_.slice_from("u");break;case 3:if(_.cursor>=_.limit)return;_.cursor++}}(),!0}},function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}),r.Pipeline.registerFunction(r.it.stemmer,"stemmer-it"),r.it.stopWordFilter=function(e){if(-1===r.it.stopWordFilter.stopWords.indexOf(e))return e},r.it.stopWordFilter.stopWords=new r.SortedSet,r.it.stopWordFilter.stopWords.length=280,r.it.stopWordFilter.stopWords.elements=" a abbia abbiamo abbiano abbiate ad agl agli ai al all alla alle allo anche avemmo avendo avesse avessero avessi avessimo aveste avesti avete aveva avevamo avevano avevate avevi avevo avrai avranno avrebbe avrebbero avrei avremmo avremo avreste avresti avrete avrà avrò avuta avute avuti avuto c che chi ci coi col come con contro cui da dagl dagli dai dal dall dalla dalle dallo degl degli dei del dell della delle dello di dov dove e ebbe ebbero ebbi ed era erano eravamo eravate eri ero essendo faccia facciamo facciano facciate faccio facemmo facendo facesse facessero facessi facessimo faceste facesti faceva facevamo facevano facevate facevi facevo fai fanno farai faranno farebbe farebbero farei faremmo faremo fareste faresti farete farà farò fece fecero feci fosse fossero fossi fossimo foste fosti fu fui fummo furono gli ha hai hanno ho i il in io l la le lei li lo loro lui ma mi mia mie miei mio ne negl negli nei nel nell nella nelle nello noi non nostra nostre nostri nostro o per perché più quale quanta quante quanti quanto quella quelle quelli quello questa queste questi questo sarai saranno sarebbe sarebbero sarei saremmo saremo sareste saresti sarete sarà sarò se sei si sia siamo siano siate siete sono sta stai stando stanno starai staranno starebbe starebbero starei staremmo staremo stareste staresti starete starà starò stava stavamo stavano stavate stavi stavo stemmo stesse stessero stessi stessimo steste stesti stette stettero stetti stia stiamo stiano stiate sto su sua sue sugl sugli sui sul sull sulla sulle sullo suo suoi ti tra tu tua tue tuo tuoi tutti tutto un una uno vi voi vostra vostre vostri vostro è".split(" "),r.Pipeline.registerFunction(r.it.stopWordFilter,"stopWordFilter-it")}}); diff --git a/static/js/lunr/lunr.jp.js b/static/js/lunr/lunr.jp.js new file mode 100644 index 0000000..90a7629 --- /dev/null +++ b/static/js/lunr/lunr.jp.js @@ -0,0 +1,120 @@ +/*! + * Lunr languages, `Japanese` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Chad Liu + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.jp = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.jp.stopWordFilter, + lunr.jp.stemmer + ); + // change the tokenizer for japanese one + lunr.tokenizer = lunr.jp.tokenizer; + }; + var segmenter = new TinySegmenter(); // インスタンス生成 + + lunr.jp.tokenizer = function (obj) { + if (!arguments.length || obj == null || obj == undefined) return []; + if (Array.isArray(obj)) + return obj.map(function (t) { + return t.toLowerCase(); + }); + + var str = obj.toString().replace(/^\s+/, ''); + + for (var i = str.length - 1; i >= 0; i--) { + if (/\S/.test(str.charAt(i))) { + str = str.substring(0, i + 1); + break; + } + } + + var segs = segmenter.segment(str); // 単語の配列が返る + return segs + .filter(function (token) { + return !!token; + }) + .map(function (token) { + return token; + }); + }; + + /* lunr stemmer function */ + lunr.jp.stemmer = (function () { + /* TODO japanese stemmer */ + return function (word) { + return word; + }; + })(); + + lunr.Pipeline.registerFunction(lunr.jp.stemmer, 'stemmer-jp'); + + /* stop word filter function */ + lunr.jp.stopWordFilter = function(token) { + if (lunr.jp.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.jp.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.jp.stopWordFilter.stopWords.length = 45; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + // stopword for japanese is from http://www.ranks.nl/stopwords/japanese + lunr.jp.stopWordFilter.stopWords.elements = ' これ それ あれ この その あの ここ そこ あそこ こちら どこ だれ なに なん 何 私 貴方 貴方方 我々 私達 あの人 あのかた 彼女 彼 です あります おります います は が の に を で え から まで より も どの と し それで しかし'.split(' '); + lunr.Pipeline.registerFunction(lunr.jp.stopWordFilter, 'stopWordFilter-jp'); + }; +})) diff --git a/static/js/lunr/lunr.jp.min.js b/static/js/lunr/lunr.jp.min.js new file mode 100644 index 0000000..a978f34 --- /dev/null +++ b/static/js/lunr/lunr.jp.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");r.jp=function(){this.pipeline.reset(),this.pipeline.add(r.jp.stopWordFilter,r.jp.stemmer),r.tokenizer=r.jp.tokenizer};var n=new TinySegmenter;r.jp.tokenizer=function(e){if(!arguments.length||null==e)return[];if(Array.isArray(e))return e.map(function(e){return e.toLowerCase()});for(var r=e.toString().replace(/^\s+/,""),t=r.length-1;0<=t;t--)if(/\S/.test(r.charAt(t))){r=r.substring(0,t+1);break}return n.segment(r).filter(function(e){return!!e}).map(function(e){return e})},r.jp.stemmer=function(e){return e},r.Pipeline.registerFunction(r.jp.stemmer,"stemmer-jp"),r.jp.stopWordFilter=function(e){if(-1===r.jp.stopWordFilter.stopWords.indexOf(e))return e},r.jp.stopWordFilter.stopWords=new r.SortedSet,r.jp.stopWordFilter.stopWords.length=45,r.jp.stopWordFilter.stopWords.elements=" これ それ あれ この その あの ここ そこ あそこ こちら どこ だれ なに なん 何 私 貴方 貴方方 我々 私達 あの人 あのかた 彼女 彼 です あります おります います は が の に を で え から まで より も どの と し それで しかし".split(" "),r.Pipeline.registerFunction(r.jp.stopWordFilter,"stopWordFilter-jp")}}); diff --git a/static/js/lunr/lunr.no.js b/static/js/lunr/lunr.no.js new file mode 100644 index 0000000..5917006 --- /dev/null +++ b/static/js/lunr/lunr.no.js @@ -0,0 +1,253 @@ +/*! + * Lunr languages, `Norwegian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.no = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.no.trimmer, + lunr.no.stopWordFilter, + lunr.no.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.no.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.no.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.no.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.no.trimmer, 'trimmer-no'); + + /* lunr stemmer function */ + lunr.no.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function NorwegianStemmer() { + var a_0 = [new Among("a", -1, 1), new Among("e", -1, 1), + new Among("ede", 1, 1), new Among("ande", 1, 1), + new Among("ende", 1, 1), new Among("ane", 1, 1), + new Among("ene", 1, 1), new Among("hetene", 6, 1), + new Among("erte", 1, 3), new Among("en", -1, 1), + new Among("heten", 9, 1), new Among("ar", -1, 1), + new Among("er", -1, 1), new Among("heter", 12, 1), + new Among("s", -1, 2), new Among("as", 14, 1), + new Among("es", 14, 1), new Among("edes", 16, 1), + new Among("endes", 16, 1), new Among("enes", 16, 1), + new Among("hetenes", 19, 1), new Among("ens", 14, 1), + new Among("hetens", 21, 1), new Among("ers", 14, 1), + new Among("ets", 14, 1), new Among("et", -1, 1), + new Among("het", 25, 1), new Among("ert", -1, 3), + new Among("ast", -1, 1) + ], + a_1 = [new Among("dt", -1, -1), + new Among("vt", -1, -1) + ], + a_2 = [new Among("leg", -1, 1), + new Among("eleg", 0, 1), new Among("ig", -1, 1), + new Among("eig", 2, 1), new Among("lig", 2, 1), + new Among("elig", 4, 1), new Among("els", -1, 1), + new Among("lov", -1, 1), new Among("elov", 7, 1), + new Among("slov", 7, 1), new Among("hetslov", 9, 1) + ], + g_v = [17, + 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48, 0, 128 + ], + g_s_ending = [ + 119, 125, 149, 1 + ], + I_x, I_p1, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function r_mark_regions() { + var v_1, c = sbp.cursor + 3; + I_p1 = sbp.limit; + if (0 <= c || c <= sbp.limit) { + I_x = c; + while (true) { + v_1 = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 248)) { + sbp.cursor = v_1; + break; + } + if (v_1 >= sbp.limit) + return; + sbp.cursor = v_1 + 1; + } + while (!sbp.out_grouping(g_v, 97, 248)) { + if (sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + } + I_p1 = sbp.cursor; + if (I_p1 < I_x) + I_p1 = I_x; + } + } + + function r_main_suffix() { + var among_var, v_1, v_2; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_0, 29); + sbp.limit_backward = v_1; + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + v_2 = sbp.limit - sbp.cursor; + if (sbp.in_grouping_b(g_s_ending, 98, 122)) + sbp.slice_del(); + else { + sbp.cursor = sbp.limit - v_2; + if (sbp.eq_s_b(1, "k") && sbp.out_grouping_b(g_v, 97, 248)) + sbp.slice_del(); + } + break; + case 3: + sbp.slice_from("er"); + break; + } + } + } + } + + function r_consonant_pair() { + var v_1 = sbp.limit - sbp.cursor, + v_2; + if (sbp.cursor >= I_p1) { + v_2 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + if (sbp.find_among_b(a_1, 2)) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_2; + sbp.cursor = sbp.limit - v_1; + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + sbp.bra = sbp.cursor; + sbp.slice_del(); + } + } else + sbp.limit_backward = v_2; + } + } + + function r_other_suffix() { + var among_var, v_1; + if (sbp.cursor >= I_p1) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_2, 11); + if (among_var) { + sbp.bra = sbp.cursor; + sbp.limit_backward = v_1; + if (among_var == 1) + sbp.slice_del(); + } else + sbp.limit_backward = v_1; + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_main_suffix(); + sbp.cursor = sbp.limit; + r_consonant_pair(); + sbp.cursor = sbp.limit; + r_other_suffix(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.no.stemmer, 'stemmer-no'); + + /* stop word filter function */ + lunr.no.stopWordFilter = function(token) { + if (lunr.no.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.no.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.no.stopWordFilter.stopWords.length = 177; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.no.stopWordFilter.stopWords.elements = ' alle at av bare begge ble blei bli blir blitt både båe da de deg dei deim deira deires dem den denne der dere deres det dette di din disse ditt du dykk dykkar då eg ein eit eitt eller elles en enn er et ett etter for fordi fra før ha hadde han hans har hennar henne hennes her hjå ho hoe honom hoss hossen hun hva hvem hver hvilke hvilken hvis hvor hvordan hvorfor i ikke ikkje ikkje ingen ingi inkje inn inni ja jeg kan kom korleis korso kun kunne kva kvar kvarhelst kven kvi kvifor man mange me med medan meg meget mellom men mi min mine mitt mot mykje ned no noe noen noka noko nokon nokor nokre nå når og også om opp oss over på samme seg selv si si sia sidan siden sin sine sitt sjøl skal skulle slik so som som somme somt så sånn til um upp ut uten var vart varte ved vere verte vi vil ville vore vors vort vår være være vært å'.split(' '); + + lunr.Pipeline.registerFunction(lunr.no.stopWordFilter, 'stopWordFilter-no'); + }; +})) diff --git a/static/js/lunr/lunr.no.min.js b/static/js/lunr/lunr.no.min.js new file mode 100644 index 0000000..f809a60 --- /dev/null +++ b/static/js/lunr/lunr.no.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,n,i;r.no=function(){this.pipeline.reset(),this.pipeline.add(r.no.trimmer,r.no.stopWordFilter,r.no.stemmer)},r.no.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.no.trimmer=r.trimmerSupport.generateTrimmer(r.no.wordCharacters),r.Pipeline.registerFunction(r.no.trimmer,"trimmer-no"),r.no.stemmer=(e=r.stemmerSupport.Among,n=r.stemmerSupport.SnowballProgram,i=new function(){var i,t,o=[new e("a",-1,1),new e("e",-1,1),new e("ede",1,1),new e("ande",1,1),new e("ende",1,1),new e("ane",1,1),new e("ene",1,1),new e("hetene",6,1),new e("erte",1,3),new e("en",-1,1),new e("heten",9,1),new e("ar",-1,1),new e("er",-1,1),new e("heter",12,1),new e("s",-1,2),new e("as",14,1),new e("es",14,1),new e("edes",16,1),new e("endes",16,1),new e("enes",16,1),new e("hetenes",19,1),new e("ens",14,1),new e("hetens",21,1),new e("ers",14,1),new e("ets",14,1),new e("et",-1,1),new e("het",25,1),new e("ert",-1,3),new e("ast",-1,1)],s=[new e("dt",-1,-1),new e("vt",-1,-1)],m=[new e("leg",-1,1),new e("eleg",0,1),new e("ig",-1,1),new e("eig",2,1),new e("lig",2,1),new e("elig",4,1),new e("els",-1,1),new e("lov",-1,1),new e("elov",7,1),new e("slov",7,1),new e("hetslov",9,1)],a=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,48,0,128],l=[119,125,149,1],d=new n;this.setCurrent=function(e){d.setCurrent(e)},this.getCurrent=function(){return d.getCurrent()},this.stem=function(){var e,r,n=d.cursor;if(function(){var e,r=d.cursor+3;if(t=d.limit,0<=r||r<=d.limit){for(i=r;;){if(e=d.cursor,d.in_grouping(a,97,248)){d.cursor=e;break}if(e>=d.limit)return;d.cursor=e+1}for(;!d.out_grouping(a,97,248);){if(d.cursor>=d.limit)return;d.cursor++}(t=d.cursor)=t&&(n=d.limit_backward,d.limit_backward=t,d.ket=d.cursor,r=d.find_among_b(o,29),d.limit_backward=n,r))switch(d.bra=d.cursor,r){case 1:d.slice_del();break;case 2:e=d.limit-d.cursor,(d.in_grouping_b(l,98,122)||(d.cursor=d.limit-e,d.eq_s_b(1,"k")&&d.out_grouping_b(a,97,248)))&&d.slice_del();break;case 3:d.slice_from("er")}return d.cursor=d.limit,n=d.limit-d.cursor,d.cursor>=t&&(r=d.limit_backward,d.limit_backward=t,d.ket=d.cursor,d.find_among_b(s,2)?(d.bra=d.cursor,d.limit_backward=r,d.cursor=d.limit-n,d.cursor>d.limit_backward&&(d.cursor--,d.bra=d.cursor,d.slice_del())):d.limit_backward=r),d.cursor=d.limit,d.cursor>=t&&(n=d.limit_backward,d.limit_backward=t,d.ket=d.cursor,(r=d.find_among_b(m,11))?(d.bra=d.cursor,d.limit_backward=n,1==r&&d.slice_del()):d.limit_backward=n),!0}},function(e){return i.setCurrent(e),i.stem(),i.getCurrent()}),r.Pipeline.registerFunction(r.no.stemmer,"stemmer-no"),r.no.stopWordFilter=function(e){if(-1===r.no.stopWordFilter.stopWords.indexOf(e))return e},r.no.stopWordFilter.stopWords=new r.SortedSet,r.no.stopWordFilter.stopWords.length=177,r.no.stopWordFilter.stopWords.elements=" alle at av bare begge ble blei bli blir blitt både båe da de deg dei deim deira deires dem den denne der dere deres det dette di din disse ditt du dykk dykkar då eg ein eit eitt eller elles en enn er et ett etter for fordi fra før ha hadde han hans har hennar henne hennes her hjå ho hoe honom hoss hossen hun hva hvem hver hvilke hvilken hvis hvor hvordan hvorfor i ikke ikkje ikkje ingen ingi inkje inn inni ja jeg kan kom korleis korso kun kunne kva kvar kvarhelst kven kvi kvifor man mange me med medan meg meget mellom men mi min mine mitt mot mykje ned no noe noen noka noko nokon nokor nokre nå når og også om opp oss over på samme seg selv si si sia sidan siden sin sine sitt sjøl skal skulle slik so som som somme somt så sånn til um upp ut uten var vart varte ved vere verte vi vil ville vore vors vort vår være være vært å".split(" "),r.Pipeline.registerFunction(r.no.stopWordFilter,"stopWordFilter-no")}}); diff --git a/static/js/lunr/lunr.pt.js b/static/js/lunr/lunr.pt.js new file mode 100644 index 0000000..d960d97 --- /dev/null +++ b/static/js/lunr/lunr.pt.js @@ -0,0 +1,566 @@ +/*! + * Lunr languages, `Portuguese` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.pt = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.pt.trimmer, + lunr.pt.stopWordFilter, + lunr.pt.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.pt.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.pt.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.pt.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.pt.trimmer, 'trimmer-pt'); + + /* lunr stemmer function */ + lunr.pt.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function PortugueseStemmer() { + var a_0 = [new Among("", -1, 3), new Among("\u00E3", 0, 1), + new Among("\u00F5", 0, 2) + ], + a_1 = [new Among("", -1, 3), + new Among("a~", 0, 1), new Among("o~", 0, 2) + ], + a_2 = [ + new Among("ic", -1, -1), new Among("ad", -1, -1), + new Among("os", -1, -1), new Among("iv", -1, 1) + ], + a_3 = [ + new Among("ante", -1, 1), new Among("avel", -1, 1), + new Among("\u00EDvel", -1, 1) + ], + a_4 = [new Among("ic", -1, 1), + new Among("abil", -1, 1), new Among("iv", -1, 1) + ], + a_5 = [ + new Among("ica", -1, 1), new Among("\u00E2ncia", -1, 1), + new Among("\u00EAncia", -1, 4), new Among("ira", -1, 9), + new Among("adora", -1, 1), new Among("osa", -1, 1), + new Among("ista", -1, 1), new Among("iva", -1, 8), + new Among("eza", -1, 1), new Among("log\u00EDa", -1, 2), + new Among("idade", -1, 7), new Among("ante", -1, 1), + new Among("mente", -1, 6), new Among("amente", 12, 5), + new Among("\u00E1vel", -1, 1), new Among("\u00EDvel", -1, 1), + new Among("uci\u00F3n", -1, 3), new Among("ico", -1, 1), + new Among("ismo", -1, 1), new Among("oso", -1, 1), + new Among("amento", -1, 1), new Among("imento", -1, 1), + new Among("ivo", -1, 8), new Among("a\u00E7a~o", -1, 1), + new Among("ador", -1, 1), new Among("icas", -1, 1), + new Among("\u00EAncias", -1, 4), new Among("iras", -1, 9), + new Among("adoras", -1, 1), new Among("osas", -1, 1), + new Among("istas", -1, 1), new Among("ivas", -1, 8), + new Among("ezas", -1, 1), new Among("log\u00EDas", -1, 2), + new Among("idades", -1, 7), new Among("uciones", -1, 3), + new Among("adores", -1, 1), new Among("antes", -1, 1), + new Among("a\u00E7o~es", -1, 1), new Among("icos", -1, 1), + new Among("ismos", -1, 1), new Among("osos", -1, 1), + new Among("amentos", -1, 1), new Among("imentos", -1, 1), + new Among("ivos", -1, 8) + ], + a_6 = [new Among("ada", -1, 1), + new Among("ida", -1, 1), new Among("ia", -1, 1), + new Among("aria", 2, 1), new Among("eria", 2, 1), + new Among("iria", 2, 1), new Among("ara", -1, 1), + new Among("era", -1, 1), new Among("ira", -1, 1), + new Among("ava", -1, 1), new Among("asse", -1, 1), + new Among("esse", -1, 1), new Among("isse", -1, 1), + new Among("aste", -1, 1), new Among("este", -1, 1), + new Among("iste", -1, 1), new Among("ei", -1, 1), + new Among("arei", 16, 1), new Among("erei", 16, 1), + new Among("irei", 16, 1), new Among("am", -1, 1), + new Among("iam", 20, 1), new Among("ariam", 21, 1), + new Among("eriam", 21, 1), new Among("iriam", 21, 1), + new Among("aram", 20, 1), new Among("eram", 20, 1), + new Among("iram", 20, 1), new Among("avam", 20, 1), + new Among("em", -1, 1), new Among("arem", 29, 1), + new Among("erem", 29, 1), new Among("irem", 29, 1), + new Among("assem", 29, 1), new Among("essem", 29, 1), + new Among("issem", 29, 1), new Among("ado", -1, 1), + new Among("ido", -1, 1), new Among("ando", -1, 1), + new Among("endo", -1, 1), new Among("indo", -1, 1), + new Among("ara~o", -1, 1), new Among("era~o", -1, 1), + new Among("ira~o", -1, 1), new Among("ar", -1, 1), + new Among("er", -1, 1), new Among("ir", -1, 1), + new Among("as", -1, 1), new Among("adas", 47, 1), + new Among("idas", 47, 1), new Among("ias", 47, 1), + new Among("arias", 50, 1), new Among("erias", 50, 1), + new Among("irias", 50, 1), new Among("aras", 47, 1), + new Among("eras", 47, 1), new Among("iras", 47, 1), + new Among("avas", 47, 1), new Among("es", -1, 1), + new Among("ardes", 58, 1), new Among("erdes", 58, 1), + new Among("irdes", 58, 1), new Among("ares", 58, 1), + new Among("eres", 58, 1), new Among("ires", 58, 1), + new Among("asses", 58, 1), new Among("esses", 58, 1), + new Among("isses", 58, 1), new Among("astes", 58, 1), + new Among("estes", 58, 1), new Among("istes", 58, 1), + new Among("is", -1, 1), new Among("ais", 71, 1), + new Among("eis", 71, 1), new Among("areis", 73, 1), + new Among("ereis", 73, 1), new Among("ireis", 73, 1), + new Among("\u00E1reis", 73, 1), new Among("\u00E9reis", 73, 1), + new Among("\u00EDreis", 73, 1), new Among("\u00E1sseis", 73, 1), + new Among("\u00E9sseis", 73, 1), new Among("\u00EDsseis", 73, 1), + new Among("\u00E1veis", 73, 1), new Among("\u00EDeis", 73, 1), + new Among("ar\u00EDeis", 84, 1), new Among("er\u00EDeis", 84, 1), + new Among("ir\u00EDeis", 84, 1), new Among("ados", -1, 1), + new Among("idos", -1, 1), new Among("amos", -1, 1), + new Among("\u00E1ramos", 90, 1), new Among("\u00E9ramos", 90, 1), + new Among("\u00EDramos", 90, 1), new Among("\u00E1vamos", 90, 1), + new Among("\u00EDamos", 90, 1), new Among("ar\u00EDamos", 95, 1), + new Among("er\u00EDamos", 95, 1), new Among("ir\u00EDamos", 95, 1), + new Among("emos", -1, 1), new Among("aremos", 99, 1), + new Among("eremos", 99, 1), new Among("iremos", 99, 1), + new Among("\u00E1ssemos", 99, 1), new Among("\u00EAssemos", 99, 1), + new Among("\u00EDssemos", 99, 1), new Among("imos", -1, 1), + new Among("armos", -1, 1), new Among("ermos", -1, 1), + new Among("irmos", -1, 1), new Among("\u00E1mos", -1, 1), + new Among("ar\u00E1s", -1, 1), new Among("er\u00E1s", -1, 1), + new Among("ir\u00E1s", -1, 1), new Among("eu", -1, 1), + new Among("iu", -1, 1), new Among("ou", -1, 1), + new Among("ar\u00E1", -1, 1), new Among("er\u00E1", -1, 1), + new Among("ir\u00E1", -1, 1) + ], + a_7 = [new Among("a", -1, 1), + new Among("i", -1, 1), new Among("o", -1, 1), + new Among("os", -1, 1), new Among("\u00E1", -1, 1), + new Among("\u00ED", -1, 1), new Among("\u00F3", -1, 1) + ], + a_8 = [ + new Among("e", -1, 1), new Among("\u00E7", -1, 2), + new Among("\u00E9", -1, 1), new Among("\u00EA", -1, 1) + ], + g_v = [17, + 65, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 19, 12, 2 + ], + I_p2, I_p1, I_pV, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function r_prelude() { + var among_var; + while (true) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among(a_0, 3); + if (among_var) { + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("a~"); + continue; + case 2: + sbp.slice_from("o~"); + continue; + case 3: + if (sbp.cursor >= sbp.limit) + break; + sbp.cursor++; + continue; + } + } + break; + } + } + + function habr2() { + if (sbp.out_grouping(g_v, 97, 250)) { + while (!sbp.in_grouping(g_v, 97, 250)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + return false; + } + return true; + } + + function habr3() { + if (sbp.in_grouping(g_v, 97, 250)) { + while (!sbp.out_grouping(g_v, 97, 250)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + } + I_pV = sbp.cursor; + return true; + } + + function habr4() { + var v_1 = sbp.cursor, + v_2, v_3; + if (sbp.in_grouping(g_v, 97, 250)) { + v_2 = sbp.cursor; + if (habr2()) { + sbp.cursor = v_2; + if (habr3()) + return; + } else + I_pV = sbp.cursor; + } + sbp.cursor = v_1; + if (sbp.out_grouping(g_v, 97, 250)) { + v_3 = sbp.cursor; + if (habr2()) { + sbp.cursor = v_3; + if (!sbp.in_grouping(g_v, 97, 250) || sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + } + I_pV = sbp.cursor; + } + } + + function habr5() { + while (!sbp.in_grouping(g_v, 97, 250)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 250)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + return true; + } + + function r_mark_regions() { + var v_1 = sbp.cursor; + I_pV = sbp.limit; + I_p1 = I_pV; + I_p2 = I_pV; + habr4(); + sbp.cursor = v_1; + if (habr5()) { + I_p1 = sbp.cursor; + if (habr5()) + I_p2 = sbp.cursor; + } + } + + function r_postlude() { + var among_var; + while (true) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among(a_1, 3); + if (among_var) { + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("\u00E3"); + continue; + case 2: + sbp.slice_from("\u00F5"); + continue; + case 3: + if (sbp.cursor >= sbp.limit) + break; + sbp.cursor++; + continue; + } + } + break; + } + } + + function r_RV() { + return I_pV <= sbp.cursor; + } + + function r_R1() { + return I_p1 <= sbp.cursor; + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function r_standard_suffix() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_5, 45); + if (!among_var) + return false; + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (!r_R2()) + return false; + sbp.slice_del(); + break; + case 2: + if (!r_R2()) + return false; + sbp.slice_from("log"); + break; + case 3: + if (!r_R2()) + return false; + sbp.slice_from("u"); + break; + case 4: + if (!r_R2()) + return false; + sbp.slice_from("ente"); + break; + case 5: + if (!r_R1()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_2, 4); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R2()) { + sbp.slice_del(); + if (among_var == 1) { + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "at")) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + } + } + } + } + break; + case 6: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_3, 3); + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1) + if (r_R2()) + sbp.slice_del(); + } + break; + case 7: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_4, 3); + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1) + if (r_R2()) + sbp.slice_del(); + } + break; + case 8: + if (!r_R2()) + return false; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(2, "at")) { + sbp.bra = sbp.cursor; + if (r_R2()) + sbp.slice_del(); + } + break; + case 9: + if (!r_RV() || !sbp.eq_s_b(1, "e")) + return false; + sbp.slice_from("ir"); + break; + } + return true; + } + + function r_verb_suffix() { + var among_var, v_1; + if (sbp.cursor >= I_pV) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_pV; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_6, 120); + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1) + sbp.slice_del(); + sbp.limit_backward = v_1; + return true; + } + sbp.limit_backward = v_1; + } + return false; + } + + function r_residual_suffix() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_7, 7); + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1) + if (r_RV()) + sbp.slice_del(); + } + } + + function habr6(c1, c2) { + if (sbp.eq_s_b(1, c1)) { + sbp.bra = sbp.cursor; + var v_1 = sbp.limit - sbp.cursor; + if (sbp.eq_s_b(1, c2)) { + sbp.cursor = sbp.limit - v_1; + if (r_RV()) + sbp.slice_del(); + return false; + } + } + return true; + } + + function r_residual_form() { + var among_var, v_1, v_2, v_3; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_8, 4); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + if (r_RV()) { + sbp.slice_del(); + sbp.ket = sbp.cursor; + v_1 = sbp.limit - sbp.cursor; + if (habr6("u", "g")) + habr6("i", "c") + } + break; + case 2: + sbp.slice_from("c"); + break; + } + } + } + + function habr1() { + if (!r_standard_suffix()) { + sbp.cursor = sbp.limit; + if (!r_verb_suffix()) { + sbp.cursor = sbp.limit; + r_residual_suffix(); + return; + } + } + sbp.cursor = sbp.limit; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "i")) { + sbp.bra = sbp.cursor; + if (sbp.eq_s_b(1, "c")) { + sbp.cursor = sbp.limit; + if (r_RV()) + sbp.slice_del(); + } + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_prelude(); + sbp.cursor = v_1; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + habr1(); + sbp.cursor = sbp.limit; + r_residual_form(); + sbp.cursor = sbp.limit_backward; + r_postlude(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.pt.stemmer, 'stemmer-pt'); + + /* stop word filter function */ + lunr.pt.stopWordFilter = function(token) { + if (lunr.pt.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.pt.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.pt.stopWordFilter.stopWords.length = 204; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.pt.stopWordFilter.stopWords.elements = ' a ao aos aquela aquelas aquele aqueles aquilo as até com como da das de dela delas dele deles depois do dos e ela elas ele eles em entre era eram essa essas esse esses esta estamos estas estava estavam este esteja estejam estejamos estes esteve estive estivemos estiver estivera estiveram estiverem estivermos estivesse estivessem estivéramos estivéssemos estou está estávamos estão eu foi fomos for fora foram forem formos fosse fossem fui fôramos fôssemos haja hajam hajamos havemos hei houve houvemos houver houvera houveram houverei houverem houveremos houveria houveriam houvermos houverá houverão houveríamos houvesse houvessem houvéramos houvéssemos há hão isso isto já lhe lhes mais mas me mesmo meu meus minha minhas muito na nas nem no nos nossa nossas nosso nossos num numa não nós o os ou para pela pelas pelo pelos por qual quando que quem se seja sejam sejamos sem serei seremos seria seriam será serão seríamos seu seus somos sou sua suas são só também te tem temos tenha tenham tenhamos tenho terei teremos teria teriam terá terão teríamos teu teus teve tinha tinham tive tivemos tiver tivera tiveram tiverem tivermos tivesse tivessem tivéramos tivéssemos tu tua tuas tém tínhamos um uma você vocês vos à às éramos'.split(' '); + + lunr.Pipeline.registerFunction(lunr.pt.stopWordFilter, 'stopWordFilter-pt'); + }; +})) diff --git a/static/js/lunr/lunr.pt.min.js b/static/js/lunr/lunr.pt.min.js new file mode 100644 index 0000000..9776adc --- /dev/null +++ b/static/js/lunr/lunr.pt.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,s,n;r.pt=function(){this.pipeline.reset(),this.pipeline.add(r.pt.trimmer,r.pt.stopWordFilter,r.pt.stemmer)},r.pt.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.pt.trimmer=r.trimmerSupport.generateTrimmer(r.pt.wordCharacters),r.Pipeline.registerFunction(r.pt.trimmer,"trimmer-pt"),r.pt.stemmer=(e=r.stemmerSupport.Among,s=r.stemmerSupport.SnowballProgram,n=new function(){var o,i,t,a=[new e("",-1,3),new e("ã",0,1),new e("õ",0,2)],u=[new e("",-1,3),new e("a~",0,1),new e("o~",0,2)],w=[new e("ic",-1,-1),new e("ad",-1,-1),new e("os",-1,-1),new e("iv",-1,1)],m=[new e("ante",-1,1),new e("avel",-1,1),new e("ível",-1,1)],c=[new e("ic",-1,1),new e("abil",-1,1),new e("iv",-1,1)],l=[new e("ica",-1,1),new e("ância",-1,1),new e("ência",-1,4),new e("ira",-1,9),new e("adora",-1,1),new e("osa",-1,1),new e("ista",-1,1),new e("iva",-1,8),new e("eza",-1,1),new e("logía",-1,2),new e("idade",-1,7),new e("ante",-1,1),new e("mente",-1,6),new e("amente",12,5),new e("ável",-1,1),new e("ível",-1,1),new e("ución",-1,3),new e("ico",-1,1),new e("ismo",-1,1),new e("oso",-1,1),new e("amento",-1,1),new e("imento",-1,1),new e("ivo",-1,8),new e("aça~o",-1,1),new e("ador",-1,1),new e("icas",-1,1),new e("ências",-1,4),new e("iras",-1,9),new e("adoras",-1,1),new e("osas",-1,1),new e("istas",-1,1),new e("ivas",-1,8),new e("ezas",-1,1),new e("logías",-1,2),new e("idades",-1,7),new e("uciones",-1,3),new e("adores",-1,1),new e("antes",-1,1),new e("aço~es",-1,1),new e("icos",-1,1),new e("ismos",-1,1),new e("osos",-1,1),new e("amentos",-1,1),new e("imentos",-1,1),new e("ivos",-1,8)],f=[new e("ada",-1,1),new e("ida",-1,1),new e("ia",-1,1),new e("aria",2,1),new e("eria",2,1),new e("iria",2,1),new e("ara",-1,1),new e("era",-1,1),new e("ira",-1,1),new e("ava",-1,1),new e("asse",-1,1),new e("esse",-1,1),new e("isse",-1,1),new e("aste",-1,1),new e("este",-1,1),new e("iste",-1,1),new e("ei",-1,1),new e("arei",16,1),new e("erei",16,1),new e("irei",16,1),new e("am",-1,1),new e("iam",20,1),new e("ariam",21,1),new e("eriam",21,1),new e("iriam",21,1),new e("aram",20,1),new e("eram",20,1),new e("iram",20,1),new e("avam",20,1),new e("em",-1,1),new e("arem",29,1),new e("erem",29,1),new e("irem",29,1),new e("assem",29,1),new e("essem",29,1),new e("issem",29,1),new e("ado",-1,1),new e("ido",-1,1),new e("ando",-1,1),new e("endo",-1,1),new e("indo",-1,1),new e("ara~o",-1,1),new e("era~o",-1,1),new e("ira~o",-1,1),new e("ar",-1,1),new e("er",-1,1),new e("ir",-1,1),new e("as",-1,1),new e("adas",47,1),new e("idas",47,1),new e("ias",47,1),new e("arias",50,1),new e("erias",50,1),new e("irias",50,1),new e("aras",47,1),new e("eras",47,1),new e("iras",47,1),new e("avas",47,1),new e("es",-1,1),new e("ardes",58,1),new e("erdes",58,1),new e("irdes",58,1),new e("ares",58,1),new e("eres",58,1),new e("ires",58,1),new e("asses",58,1),new e("esses",58,1),new e("isses",58,1),new e("astes",58,1),new e("estes",58,1),new e("istes",58,1),new e("is",-1,1),new e("ais",71,1),new e("eis",71,1),new e("areis",73,1),new e("ereis",73,1),new e("ireis",73,1),new e("áreis",73,1),new e("éreis",73,1),new e("íreis",73,1),new e("ásseis",73,1),new e("ésseis",73,1),new e("ísseis",73,1),new e("áveis",73,1),new e("íeis",73,1),new e("aríeis",84,1),new e("eríeis",84,1),new e("iríeis",84,1),new e("ados",-1,1),new e("idos",-1,1),new e("amos",-1,1),new e("áramos",90,1),new e("éramos",90,1),new e("íramos",90,1),new e("ávamos",90,1),new e("íamos",90,1),new e("aríamos",95,1),new e("eríamos",95,1),new e("iríamos",95,1),new e("emos",-1,1),new e("aremos",99,1),new e("eremos",99,1),new e("iremos",99,1),new e("ássemos",99,1),new e("êssemos",99,1),new e("íssemos",99,1),new e("imos",-1,1),new e("armos",-1,1),new e("ermos",-1,1),new e("irmos",-1,1),new e("ámos",-1,1),new e("arás",-1,1),new e("erás",-1,1),new e("irás",-1,1),new e("eu",-1,1),new e("iu",-1,1),new e("ou",-1,1),new e("ará",-1,1),new e("erá",-1,1),new e("irá",-1,1)],d=[new e("a",-1,1),new e("i",-1,1),new e("o",-1,1),new e("os",-1,1),new e("á",-1,1),new e("í",-1,1),new e("ó",-1,1)],p=[new e("e",-1,1),new e("ç",-1,2),new e("é",-1,1),new e("ê",-1,1)],v=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,3,19,12,2],_=new s;function h(){if(!_.out_grouping(v,97,250))return 1;for(;!_.in_grouping(v,97,250);){if(_.cursor>=_.limit)return 1;_.cursor++}}function b(){for(;!_.in_grouping(v,97,250);){if(_.cursor>=_.limit)return;_.cursor++}for(;!_.out_grouping(v,97,250);){if(_.cursor>=_.limit)return;_.cursor++}return 1}function g(){return t<=_.cursor}function k(){return o<=_.cursor}function q(e,r){return!_.eq_s_b(1,e)||(_.bra=_.cursor,e=_.limit-_.cursor,!_.eq_s_b(1,r))||(_.cursor=_.limit-e,g()&&_.slice_del(),0)}this.setCurrent=function(e){_.setCurrent(e)},this.getCurrent=function(){return _.getCurrent()},this.stem=function(){for(var e,r,s,n=_.cursor;;){if(_.bra=_.cursor,e=_.find_among(a,3))switch(_.ket=_.cursor,e){case 1:_.slice_from("a~");continue;case 2:_.slice_from("o~");continue;case 3:if(!(_.cursor>=_.limit)){_.cursor++;continue}}break}if(_.cursor=n,r=_.cursor,t=_.limit,o=i=t,function(){var e,r=_.cursor;if(_.in_grouping(v,97,250))if(e=_.cursor,h()){if(_.cursor=e,function(){if(_.in_grouping(v,97,250))for(;!_.out_grouping(v,97,250);){if(_.cursor>=_.limit)return;_.cursor++}return t=_.cursor,1}())return}else t=_.cursor;if(_.cursor=r,_.out_grouping(v,97,250)){if(e=_.cursor,h()){if(_.cursor=e,!_.in_grouping(v,97,250)||_.cursor>=_.limit)return;_.cursor++}t=_.cursor}}(),_.cursor=r,b()&&(i=_.cursor,b())&&(o=_.cursor),_.limit_backward=n,_.cursor=_.limit,function(){var e;if(_.ket=_.cursor,e=_.find_among_b(l,45)){switch(_.bra=_.cursor,e){case 1:if(!k())return;_.slice_del();break;case 2:if(!k())return;_.slice_from("log");break;case 3:if(!k())return;_.slice_from("u");break;case 4:if(!k())return;_.slice_from("ente");break;case 5:if(!(i<=_.cursor))return;_.slice_del(),_.ket=_.cursor,(e=_.find_among_b(w,4))&&(_.bra=_.cursor,k())&&(_.slice_del(),1==e)&&(_.ket=_.cursor,_.eq_s_b(2,"at"))&&(_.bra=_.cursor,k())&&_.slice_del();break;case 6:if(!k())return;_.slice_del(),_.ket=_.cursor,(e=_.find_among_b(m,3))&&(_.bra=_.cursor,1==e)&&k()&&_.slice_del();break;case 7:if(!k())return;_.slice_del(),_.ket=_.cursor,(e=_.find_among_b(c,3))&&(_.bra=_.cursor,1==e)&&k()&&_.slice_del();break;case 8:if(!k())return;_.slice_del(),_.ket=_.cursor,_.eq_s_b(2,"at")&&(_.bra=_.cursor,k())&&_.slice_del();break;case 9:if(!g()||!_.eq_s_b(1,"e"))return;_.slice_from("ir")}return 1}}()||(_.cursor=_.limit,function(){var e,r;if(_.cursor>=t){if(r=_.limit_backward,_.limit_backward=t,_.ket=_.cursor,e=_.find_among_b(f,120))return _.bra=_.cursor,1==e&&_.slice_del(),_.limit_backward=r,1;_.limit_backward=r}}())?(_.cursor=_.limit,_.ket=_.cursor,_.eq_s_b(1,"i")&&(_.bra=_.cursor,_.eq_s_b(1,"c"))&&(_.cursor=_.limit,g())&&_.slice_del()):(_.cursor=_.limit,_.ket=_.cursor,(n=_.find_among_b(d,7))&&(_.bra=_.cursor,1==n)&&g()&&_.slice_del()),_.cursor=_.limit,_.ket=_.cursor,r=_.find_among_b(p,4))switch(_.bra=_.cursor,r){case 1:g()&&(_.slice_del(),_.ket=_.cursor,_.limit,_.cursor,q("u","g"))&&q("i","c");break;case 2:_.slice_from("c")}for(_.cursor=_.limit_backward;;){if(_.bra=_.cursor,s=_.find_among(u,3))switch(_.ket=_.cursor,s){case 1:_.slice_from("ã");continue;case 2:_.slice_from("õ");continue;case 3:if(!(_.cursor>=_.limit)){_.cursor++;continue}}break}return!0}},function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}),r.Pipeline.registerFunction(r.pt.stemmer,"stemmer-pt"),r.pt.stopWordFilter=function(e){if(-1===r.pt.stopWordFilter.stopWords.indexOf(e))return e},r.pt.stopWordFilter.stopWords=new r.SortedSet,r.pt.stopWordFilter.stopWords.length=204,r.pt.stopWordFilter.stopWords.elements=" a ao aos aquela aquelas aquele aqueles aquilo as até com como da das de dela delas dele deles depois do dos e ela elas ele eles em entre era eram essa essas esse esses esta estamos estas estava estavam este esteja estejam estejamos estes esteve estive estivemos estiver estivera estiveram estiverem estivermos estivesse estivessem estivéramos estivéssemos estou está estávamos estão eu foi fomos for fora foram forem formos fosse fossem fui fôramos fôssemos haja hajam hajamos havemos hei houve houvemos houver houvera houveram houverei houverem houveremos houveria houveriam houvermos houverá houverão houveríamos houvesse houvessem houvéramos houvéssemos há hão isso isto já lhe lhes mais mas me mesmo meu meus minha minhas muito na nas nem no nos nossa nossas nosso nossos num numa não nós o os ou para pela pelas pelo pelos por qual quando que quem se seja sejam sejamos sem serei seremos seria seriam será serão seríamos seu seus somos sou sua suas são só também te tem temos tenha tenham tenhamos tenho terei teremos teria teriam terá terão teríamos teu teus teve tinha tinham tive tivemos tiver tivera tiveram tiverem tivermos tivesse tivessem tivéramos tivéssemos tu tua tuas tém tínhamos um uma você vocês vos à às éramos".split(" "),r.Pipeline.registerFunction(r.pt.stopWordFilter,"stopWordFilter-pt")}}); diff --git a/static/js/lunr/lunr.ro.js b/static/js/lunr/lunr.ro.js new file mode 100644 index 0000000..9638278 --- /dev/null +++ b/static/js/lunr/lunr.ro.js @@ -0,0 +1,554 @@ +/*! + * Lunr languages, `Romanian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.ro = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.ro.trimmer, + lunr.ro.stopWordFilter, + lunr.ro.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.ro.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.ro.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.ro.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.ro.trimmer, 'trimmer-ro'); + + /* lunr stemmer function */ + lunr.ro.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function RomanianStemmer() { + var a_0 = [new Among("", -1, 3), new Among("I", 0, 1), new Among("U", 0, 2)], + a_1 = [ + new Among("ea", -1, 3), new Among("a\u0163ia", -1, 7), + new Among("aua", -1, 2), new Among("iua", -1, 4), + new Among("a\u0163ie", -1, 7), new Among("ele", -1, 3), + new Among("ile", -1, 5), new Among("iile", 6, 4), + new Among("iei", -1, 4), new Among("atei", -1, 6), + new Among("ii", -1, 4), new Among("ului", -1, 1), + new Among("ul", -1, 1), new Among("elor", -1, 3), + new Among("ilor", -1, 4), new Among("iilor", 14, 4) + ], + a_2 = [ + new Among("icala", -1, 4), new Among("iciva", -1, 4), + new Among("ativa", -1, 5), new Among("itiva", -1, 6), + new Among("icale", -1, 4), new Among("a\u0163iune", -1, 5), + new Among("i\u0163iune", -1, 6), new Among("atoare", -1, 5), + new Among("itoare", -1, 6), new Among("\u0103toare", -1, 5), + new Among("icitate", -1, 4), new Among("abilitate", -1, 1), + new Among("ibilitate", -1, 2), new Among("ivitate", -1, 3), + new Among("icive", -1, 4), new Among("ative", -1, 5), + new Among("itive", -1, 6), new Among("icali", -1, 4), + new Among("atori", -1, 5), new Among("icatori", 18, 4), + new Among("itori", -1, 6), new Among("\u0103tori", -1, 5), + new Among("icitati", -1, 4), new Among("abilitati", -1, 1), + new Among("ivitati", -1, 3), new Among("icivi", -1, 4), + new Among("ativi", -1, 5), new Among("itivi", -1, 6), + new Among("icit\u0103i", -1, 4), new Among("abilit\u0103i", -1, 1), + new Among("ivit\u0103i", -1, 3), + new Among("icit\u0103\u0163i", -1, 4), + new Among("abilit\u0103\u0163i", -1, 1), + new Among("ivit\u0103\u0163i", -1, 3), new Among("ical", -1, 4), + new Among("ator", -1, 5), new Among("icator", 35, 4), + new Among("itor", -1, 6), new Among("\u0103tor", -1, 5), + new Among("iciv", -1, 4), new Among("ativ", -1, 5), + new Among("itiv", -1, 6), new Among("ical\u0103", -1, 4), + new Among("iciv\u0103", -1, 4), new Among("ativ\u0103", -1, 5), + new Among("itiv\u0103", -1, 6) + ], + a_3 = [new Among("ica", -1, 1), + new Among("abila", -1, 1), new Among("ibila", -1, 1), + new Among("oasa", -1, 1), new Among("ata", -1, 1), + new Among("ita", -1, 1), new Among("anta", -1, 1), + new Among("ista", -1, 3), new Among("uta", -1, 1), + new Among("iva", -1, 1), new Among("ic", -1, 1), + new Among("ice", -1, 1), new Among("abile", -1, 1), + new Among("ibile", -1, 1), new Among("isme", -1, 3), + new Among("iune", -1, 2), new Among("oase", -1, 1), + new Among("ate", -1, 1), new Among("itate", 17, 1), + new Among("ite", -1, 1), new Among("ante", -1, 1), + new Among("iste", -1, 3), new Among("ute", -1, 1), + new Among("ive", -1, 1), new Among("ici", -1, 1), + new Among("abili", -1, 1), new Among("ibili", -1, 1), + new Among("iuni", -1, 2), new Among("atori", -1, 1), + new Among("osi", -1, 1), new Among("ati", -1, 1), + new Among("itati", 30, 1), new Among("iti", -1, 1), + new Among("anti", -1, 1), new Among("isti", -1, 3), + new Among("uti", -1, 1), new Among("i\u015Fti", -1, 3), + new Among("ivi", -1, 1), new Among("it\u0103i", -1, 1), + new Among("o\u015Fi", -1, 1), new Among("it\u0103\u0163i", -1, 1), + new Among("abil", -1, 1), new Among("ibil", -1, 1), + new Among("ism", -1, 3), new Among("ator", -1, 1), + new Among("os", -1, 1), new Among("at", -1, 1), + new Among("it", -1, 1), new Among("ant", -1, 1), + new Among("ist", -1, 3), new Among("ut", -1, 1), + new Among("iv", -1, 1), new Among("ic\u0103", -1, 1), + new Among("abil\u0103", -1, 1), new Among("ibil\u0103", -1, 1), + new Among("oas\u0103", -1, 1), new Among("at\u0103", -1, 1), + new Among("it\u0103", -1, 1), new Among("ant\u0103", -1, 1), + new Among("ist\u0103", -1, 3), new Among("ut\u0103", -1, 1), + new Among("iv\u0103", -1, 1) + ], + a_4 = [new Among("ea", -1, 1), + new Among("ia", -1, 1), new Among("esc", -1, 1), + new Among("\u0103sc", -1, 1), new Among("ind", -1, 1), + new Among("\u00E2nd", -1, 1), new Among("are", -1, 1), + new Among("ere", -1, 1), new Among("ire", -1, 1), + new Among("\u00E2re", -1, 1), new Among("se", -1, 2), + new Among("ase", 10, 1), new Among("sese", 10, 2), + new Among("ise", 10, 1), new Among("use", 10, 1), + new Among("\u00E2se", 10, 1), new Among("e\u015Fte", -1, 1), + new Among("\u0103\u015Fte", -1, 1), new Among("eze", -1, 1), + new Among("ai", -1, 1), new Among("eai", 19, 1), + new Among("iai", 19, 1), new Among("sei", -1, 2), + new Among("e\u015Fti", -1, 1), new Among("\u0103\u015Fti", -1, 1), + new Among("ui", -1, 1), new Among("ezi", -1, 1), + new Among("\u00E2i", -1, 1), new Among("a\u015Fi", -1, 1), + new Among("se\u015Fi", -1, 2), new Among("ase\u015Fi", 29, 1), + new Among("sese\u015Fi", 29, 2), new Among("ise\u015Fi", 29, 1), + new Among("use\u015Fi", 29, 1), + new Among("\u00E2se\u015Fi", 29, 1), new Among("i\u015Fi", -1, 1), + new Among("u\u015Fi", -1, 1), new Among("\u00E2\u015Fi", -1, 1), + new Among("a\u0163i", -1, 2), new Among("ea\u0163i", 38, 1), + new Among("ia\u0163i", 38, 1), new Among("e\u0163i", -1, 2), + new Among("i\u0163i", -1, 2), new Among("\u00E2\u0163i", -1, 2), + new Among("ar\u0103\u0163i", -1, 1), + new Among("ser\u0103\u0163i", -1, 2), + new Among("aser\u0103\u0163i", 45, 1), + new Among("seser\u0103\u0163i", 45, 2), + new Among("iser\u0103\u0163i", 45, 1), + new Among("user\u0103\u0163i", 45, 1), + new Among("\u00E2ser\u0103\u0163i", 45, 1), + new Among("ir\u0103\u0163i", -1, 1), + new Among("ur\u0103\u0163i", -1, 1), + new Among("\u00E2r\u0103\u0163i", -1, 1), new Among("am", -1, 1), + new Among("eam", 54, 1), new Among("iam", 54, 1), + new Among("em", -1, 2), new Among("asem", 57, 1), + new Among("sesem", 57, 2), new Among("isem", 57, 1), + new Among("usem", 57, 1), new Among("\u00E2sem", 57, 1), + new Among("im", -1, 2), new Among("\u00E2m", -1, 2), + new Among("\u0103m", -1, 2), new Among("ar\u0103m", 65, 1), + new Among("ser\u0103m", 65, 2), new Among("aser\u0103m", 67, 1), + new Among("seser\u0103m", 67, 2), new Among("iser\u0103m", 67, 1), + new Among("user\u0103m", 67, 1), + new Among("\u00E2ser\u0103m", 67, 1), + new Among("ir\u0103m", 65, 1), new Among("ur\u0103m", 65, 1), + new Among("\u00E2r\u0103m", 65, 1), new Among("au", -1, 1), + new Among("eau", 76, 1), new Among("iau", 76, 1), + new Among("indu", -1, 1), new Among("\u00E2ndu", -1, 1), + new Among("ez", -1, 1), new Among("easc\u0103", -1, 1), + new Among("ar\u0103", -1, 1), new Among("ser\u0103", -1, 2), + new Among("aser\u0103", 84, 1), new Among("seser\u0103", 84, 2), + new Among("iser\u0103", 84, 1), new Among("user\u0103", 84, 1), + new Among("\u00E2ser\u0103", 84, 1), new Among("ir\u0103", -1, 1), + new Among("ur\u0103", -1, 1), new Among("\u00E2r\u0103", -1, 1), + new Among("eaz\u0103", -1, 1) + ], + a_5 = [new Among("a", -1, 1), + new Among("e", -1, 1), new Among("ie", 1, 1), + new Among("i", -1, 1), new Among("\u0103", -1, 1) + ], + g_v = [17, 65, + 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 32, 0, 0, 4 + ], + B_standard_suffix_removed, I_p2, I_p1, I_pV, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function habr1(c1, c2) { + if (sbp.eq_s(1, c1)) { + sbp.ket = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 259)) + sbp.slice_from(c2); + } + } + + function r_prelude() { + var v_1, v_2; + while (true) { + v_1 = sbp.cursor; + if (sbp.in_grouping(g_v, 97, 259)) { + v_2 = sbp.cursor; + sbp.bra = v_2; + habr1("u", "U"); + sbp.cursor = v_2; + habr1("i", "I"); + } + sbp.cursor = v_1; + if (sbp.cursor >= sbp.limit) { + break; + } + sbp.cursor++; + } + } + + function habr2() { + if (sbp.out_grouping(g_v, 97, 259)) { + while (!sbp.in_grouping(g_v, 97, 259)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + return false; + } + return true; + } + + function habr3() { + if (sbp.in_grouping(g_v, 97, 259)) { + while (!sbp.out_grouping(g_v, 97, 259)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + } + return false; + } + + function habr4() { + var v_1 = sbp.cursor, + v_2, v_3; + if (sbp.in_grouping(g_v, 97, 259)) { + v_2 = sbp.cursor; + if (habr2()) { + sbp.cursor = v_2; + if (!habr3()) { + I_pV = sbp.cursor; + return; + } + } else { + I_pV = sbp.cursor; + return; + } + } + sbp.cursor = v_1; + if (sbp.out_grouping(g_v, 97, 259)) { + v_3 = sbp.cursor; + if (habr2()) { + sbp.cursor = v_3; + if (sbp.in_grouping(g_v, 97, 259) && sbp.cursor < sbp.limit) + sbp.cursor++; + } + I_pV = sbp.cursor; + } + } + + function habr5() { + while (!sbp.in_grouping(g_v, 97, 259)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 259)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + return true; + } + + function r_mark_regions() { + var v_1 = sbp.cursor; + I_pV = sbp.limit; + I_p1 = I_pV; + I_p2 = I_pV; + habr4(); + sbp.cursor = v_1; + if (habr5()) { + I_p1 = sbp.cursor; + if (habr5()) + I_p2 = sbp.cursor; + } + } + + function r_postlude() { + var among_var; + while (true) { + sbp.bra = sbp.cursor; + among_var = sbp.find_among(a_0, 3); + if (among_var) { + sbp.ket = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("i"); + continue; + case 2: + sbp.slice_from("u"); + continue; + case 3: + if (sbp.cursor >= sbp.limit) + break; + sbp.cursor++; + continue; + } + } + break; + } + } + + function r_RV() { + return I_pV <= sbp.cursor; + } + + function r_R1() { + return I_p1 <= sbp.cursor; + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function r_step_0() { + var among_var, v_1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_1, 16); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + sbp.slice_from("a"); + break; + case 3: + sbp.slice_from("e"); + break; + case 4: + sbp.slice_from("i"); + break; + case 5: + v_1 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(2, "ab")) { + sbp.cursor = sbp.limit - v_1; + sbp.slice_from("i"); + } + break; + case 6: + sbp.slice_from("at"); + break; + case 7: + sbp.slice_from("a\u0163i"); + break; + } + } + } + } + + function r_combo_suffix() { + var among_var, v_1 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_2, 46); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R1()) { + switch (among_var) { + case 1: + sbp.slice_from("abil"); + break; + case 2: + sbp.slice_from("ibil"); + break; + case 3: + sbp.slice_from("iv"); + break; + case 4: + sbp.slice_from("ic"); + break; + case 5: + sbp.slice_from("at"); + break; + case 6: + sbp.slice_from("it"); + break; + } + B_standard_suffix_removed = true; + sbp.cursor = sbp.limit - v_1; + return true; + } + } + return false; + } + + function r_standard_suffix() { + var among_var, v_1; + B_standard_suffix_removed = false; + while (true) { + v_1 = sbp.limit - sbp.cursor; + if (!r_combo_suffix()) { + sbp.cursor = sbp.limit - v_1; + break; + } + } + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_3, 62); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R2()) { + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + if (sbp.eq_s_b(1, "\u0163")) { + sbp.bra = sbp.cursor; + sbp.slice_from("t"); + } + break; + case 3: + sbp.slice_from("ist"); + break; + } + B_standard_suffix_removed = true; + } + } + } + + function r_verb_suffix() { + var among_var, v_1, v_2; + if (sbp.cursor >= I_pV) { + v_1 = sbp.limit_backward; + sbp.limit_backward = I_pV; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_4, 94); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + v_2 = sbp.limit - sbp.cursor; + if (!sbp.out_grouping_b(g_v, 97, 259)) { + sbp.cursor = sbp.limit - v_2; + if (!sbp.eq_s_b(1, "u")) + break; + } + case 2: + sbp.slice_del(); + break; + } + } + sbp.limit_backward = v_1; + } + } + + function r_vowel_suffix() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_5, 5); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_RV() && among_var == 1) + sbp.slice_del(); + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_prelude(); + sbp.cursor = v_1; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_step_0(); + sbp.cursor = sbp.limit; + r_standard_suffix(); + sbp.cursor = sbp.limit; + if (!B_standard_suffix_removed) { + sbp.cursor = sbp.limit; + r_verb_suffix(); + sbp.cursor = sbp.limit; + } + r_vowel_suffix(); + sbp.cursor = sbp.limit_backward; + r_postlude(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.ro.stemmer, 'stemmer-ro'); + + /* stop word filter function */ + lunr.ro.stopWordFilter = function(token) { + if (lunr.ro.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.ro.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.ro.stopWordFilter.stopWords.length = 282; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.ro.stopWordFilter.stopWords.elements = ' acea aceasta această aceea acei aceia acel acela acele acelea acest acesta aceste acestea aceşti aceştia acolo acord acum ai aia aibă aici al ale alea altceva altcineva am ar are asemenea asta astea astăzi asupra au avea avem aveţi azi aş aşadar aţi bine bucur bună ca care caut ce cel ceva chiar cinci cine cineva contra cu cum cumva curând curînd când cât câte câtva câţi cînd cît cîte cîtva cîţi că căci cărei căror cărui către da dacă dar datorită dată dau de deci deja deoarece departe deşi din dinaintea dintr- dintre doi doilea două drept după dă ea ei el ele eram este eu eşti face fata fi fie fiecare fii fim fiu fiţi frumos fără graţie halbă iar ieri la le li lor lui lângă lîngă mai mea mei mele mereu meu mi mie mine mult multă mulţi mulţumesc mâine mîine mă ne nevoie nici nicăieri nimeni nimeri nimic nişte noastre noastră noi noroc nostru nouă noştri nu opt ori oricare orice oricine oricum oricând oricât oricînd oricît oriunde patra patru patrulea pe pentru peste pic poate pot prea prima primul prin puţin puţina puţină până pînă rog sa sale sau se spate spre sub sunt suntem sunteţi sută sînt sîntem sînteţi să săi său ta tale te timp tine toate toată tot totuşi toţi trei treia treilea tu tăi tău un una unde undeva unei uneia unele uneori unii unor unora unu unui unuia unul vi voastre voastră voi vostru vouă voştri vreme vreo vreun vă zece zero zi zice îi îl îmi împotriva în înainte înaintea încotro încât încît între întrucât întrucît îţi ăla ălea ăsta ăstea ăştia şapte şase şi ştiu ţi ţie'.split(' '); + + lunr.Pipeline.registerFunction(lunr.ro.stopWordFilter, 'stopWordFilter-ro'); + }; +})) diff --git a/static/js/lunr/lunr.ro.min.js b/static/js/lunr/lunr.ro.min.js new file mode 100644 index 0000000..4fe0c44 --- /dev/null +++ b/static/js/lunr/lunr.ro.min.js @@ -0,0 +1 @@ +!function(e,i){"function"==typeof define&&define.amd?define(i):"object"==typeof exports?module.exports=i():i()(e.lunr)}(this,function(){return function(i){if(void 0===i)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===i.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,r,n;i.ro=function(){this.pipeline.reset(),this.pipeline.add(i.ro.trimmer,i.ro.stopWordFilter,i.ro.stemmer)},i.ro.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",i.ro.trimmer=i.trimmerSupport.generateTrimmer(i.ro.wordCharacters),i.Pipeline.registerFunction(i.ro.trimmer,"trimmer-ro"),i.ro.stemmer=(e=i.stemmerSupport.Among,r=i.stemmerSupport.SnowballProgram,n=new function(){var u,w,m,l,f=[new e("",-1,3),new e("I",0,1),new e("U",0,2)],p=[new e("ea",-1,3),new e("aţia",-1,7),new e("aua",-1,2),new e("iua",-1,4),new e("aţie",-1,7),new e("ele",-1,3),new e("ile",-1,5),new e("iile",6,4),new e("iei",-1,4),new e("atei",-1,6),new e("ii",-1,4),new e("ului",-1,1),new e("ul",-1,1),new e("elor",-1,3),new e("ilor",-1,4),new e("iilor",14,4)],d=[new e("icala",-1,4),new e("iciva",-1,4),new e("ativa",-1,5),new e("itiva",-1,6),new e("icale",-1,4),new e("aţiune",-1,5),new e("iţiune",-1,6),new e("atoare",-1,5),new e("itoare",-1,6),new e("ătoare",-1,5),new e("icitate",-1,4),new e("abilitate",-1,1),new e("ibilitate",-1,2),new e("ivitate",-1,3),new e("icive",-1,4),new e("ative",-1,5),new e("itive",-1,6),new e("icali",-1,4),new e("atori",-1,5),new e("icatori",18,4),new e("itori",-1,6),new e("ători",-1,5),new e("icitati",-1,4),new e("abilitati",-1,1),new e("ivitati",-1,3),new e("icivi",-1,4),new e("ativi",-1,5),new e("itivi",-1,6),new e("icităi",-1,4),new e("abilităi",-1,1),new e("ivităi",-1,3),new e("icităţi",-1,4),new e("abilităţi",-1,1),new e("ivităţi",-1,3),new e("ical",-1,4),new e("ator",-1,5),new e("icator",35,4),new e("itor",-1,6),new e("ător",-1,5),new e("iciv",-1,4),new e("ativ",-1,5),new e("itiv",-1,6),new e("icală",-1,4),new e("icivă",-1,4),new e("ativă",-1,5),new e("itivă",-1,6)],b=[new e("ica",-1,1),new e("abila",-1,1),new e("ibila",-1,1),new e("oasa",-1,1),new e("ata",-1,1),new e("ita",-1,1),new e("anta",-1,1),new e("ista",-1,3),new e("uta",-1,1),new e("iva",-1,1),new e("ic",-1,1),new e("ice",-1,1),new e("abile",-1,1),new e("ibile",-1,1),new e("isme",-1,3),new e("iune",-1,2),new e("oase",-1,1),new e("ate",-1,1),new e("itate",17,1),new e("ite",-1,1),new e("ante",-1,1),new e("iste",-1,3),new e("ute",-1,1),new e("ive",-1,1),new e("ici",-1,1),new e("abili",-1,1),new e("ibili",-1,1),new e("iuni",-1,2),new e("atori",-1,1),new e("osi",-1,1),new e("ati",-1,1),new e("itati",30,1),new e("iti",-1,1),new e("anti",-1,1),new e("isti",-1,3),new e("uti",-1,1),new e("işti",-1,3),new e("ivi",-1,1),new e("ităi",-1,1),new e("oşi",-1,1),new e("ităţi",-1,1),new e("abil",-1,1),new e("ibil",-1,1),new e("ism",-1,3),new e("ator",-1,1),new e("os",-1,1),new e("at",-1,1),new e("it",-1,1),new e("ant",-1,1),new e("ist",-1,3),new e("ut",-1,1),new e("iv",-1,1),new e("ică",-1,1),new e("abilă",-1,1),new e("ibilă",-1,1),new e("oasă",-1,1),new e("ată",-1,1),new e("ită",-1,1),new e("antă",-1,1),new e("istă",-1,3),new e("ută",-1,1),new e("ivă",-1,1)],_=[new e("ea",-1,1),new e("ia",-1,1),new e("esc",-1,1),new e("ăsc",-1,1),new e("ind",-1,1),new e("ând",-1,1),new e("are",-1,1),new e("ere",-1,1),new e("ire",-1,1),new e("âre",-1,1),new e("se",-1,2),new e("ase",10,1),new e("sese",10,2),new e("ise",10,1),new e("use",10,1),new e("âse",10,1),new e("eşte",-1,1),new e("ăşte",-1,1),new e("eze",-1,1),new e("ai",-1,1),new e("eai",19,1),new e("iai",19,1),new e("sei",-1,2),new e("eşti",-1,1),new e("ăşti",-1,1),new e("ui",-1,1),new e("ezi",-1,1),new e("âi",-1,1),new e("aşi",-1,1),new e("seşi",-1,2),new e("aseşi",29,1),new e("seseşi",29,2),new e("iseşi",29,1),new e("useşi",29,1),new e("âseşi",29,1),new e("işi",-1,1),new e("uşi",-1,1),new e("âşi",-1,1),new e("aţi",-1,2),new e("eaţi",38,1),new e("iaţi",38,1),new e("eţi",-1,2),new e("iţi",-1,2),new e("âţi",-1,2),new e("arăţi",-1,1),new e("serăţi",-1,2),new e("aserăţi",45,1),new e("seserăţi",45,2),new e("iserăţi",45,1),new e("userăţi",45,1),new e("âserăţi",45,1),new e("irăţi",-1,1),new e("urăţi",-1,1),new e("ârăţi",-1,1),new e("am",-1,1),new e("eam",54,1),new e("iam",54,1),new e("em",-1,2),new e("asem",57,1),new e("sesem",57,2),new e("isem",57,1),new e("usem",57,1),new e("âsem",57,1),new e("im",-1,2),new e("âm",-1,2),new e("ăm",-1,2),new e("arăm",65,1),new e("serăm",65,2),new e("aserăm",67,1),new e("seserăm",67,2),new e("iserăm",67,1),new e("userăm",67,1),new e("âserăm",67,1),new e("irăm",65,1),new e("urăm",65,1),new e("ârăm",65,1),new e("au",-1,1),new e("eau",76,1),new e("iau",76,1),new e("indu",-1,1),new e("ându",-1,1),new e("ez",-1,1),new e("ească",-1,1),new e("ară",-1,1),new e("seră",-1,2),new e("aseră",84,1),new e("seseră",84,2),new e("iseră",84,1),new e("useră",84,1),new e("âseră",84,1),new e("iră",-1,1),new e("ură",-1,1),new e("âră",-1,1),new e("ează",-1,1)],v=[new e("a",-1,1),new e("e",-1,1),new e("ie",1,1),new e("i",-1,1),new e("ă",-1,1)],g=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,2,32,0,0,4],k=new r;function h(e,i){k.eq_s(1,e)&&(k.ket=k.cursor,k.in_grouping(g,97,259))&&k.slice_from(i)}function W(){if(!k.out_grouping(g,97,259))return 1;for(;!k.in_grouping(g,97,259);){if(k.cursor>=k.limit)return 1;k.cursor++}}function z(){for(;!k.in_grouping(g,97,259);){if(k.cursor>=k.limit)return;k.cursor++}for(;!k.out_grouping(g,97,259);){if(k.cursor>=k.limit)return;k.cursor++}return 1}function F(){return m<=k.cursor}this.setCurrent=function(e){k.setCurrent(e)},this.getCurrent=function(){return k.getCurrent()},this.stem=function(){for(var e,i,r,n,t,a,o,s,c=k.cursor;e=k.cursor,k.in_grouping(g,97,259)&&(i=k.cursor,k.bra=i,h("u","U"),k.cursor=i,h("i","I")),k.cursor=e,!(k.cursor>=k.limit);)k.cursor++;if(k.cursor=c,n=k.cursor,l=k.limit,w=m=l,function(){var e,i=k.cursor;if(k.in_grouping(g,97,259)){if(e=k.cursor,!W())return l=k.cursor;if(k.cursor=e,!function(){if(k.in_grouping(g,97,259))for(;!k.out_grouping(g,97,259);){if(k.cursor>=k.limit)return 1;k.cursor++}}())return l=k.cursor}k.cursor=i,k.out_grouping(g,97,259)&&(e=k.cursor,W()&&(k.cursor=e,k.in_grouping(g,97,259))&&k.cursor=l){if(c=k.limit_backward,k.limit_backward=l,k.ket=k.cursor,n=k.find_among_b(_,94))switch(k.bra=k.cursor,n){case 1:if(t=k.limit-k.cursor,!k.out_grouping_b(g,97,259)&&(k.cursor=k.limit-t,!k.eq_s_b(1,"u")))break;case 2:k.slice_del()}k.limit_backward=c}k.cursor=k.limit}for(k.ket=k.cursor,(s=k.find_among_b(v,5))&&(k.bra=k.cursor,l<=k.cursor)&&1==s&&k.slice_del(),k.cursor=k.limit_backward;;){if(k.bra=k.cursor,a=k.find_among(f,3))switch(k.ket=k.cursor,a){case 1:k.slice_from("i");continue;case 2:k.slice_from("u");continue;case 3:if(!(k.cursor>=k.limit)){k.cursor++;continue}}break}return!0}},function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}),i.Pipeline.registerFunction(i.ro.stemmer,"stemmer-ro"),i.ro.stopWordFilter=function(e){if(-1===i.ro.stopWordFilter.stopWords.indexOf(e))return e},i.ro.stopWordFilter.stopWords=new i.SortedSet,i.ro.stopWordFilter.stopWords.length=282,i.ro.stopWordFilter.stopWords.elements=" acea aceasta această aceea acei aceia acel acela acele acelea acest acesta aceste acestea aceşti aceştia acolo acord acum ai aia aibă aici al ale alea altceva altcineva am ar are asemenea asta astea astăzi asupra au avea avem aveţi azi aş aşadar aţi bine bucur bună ca care caut ce cel ceva chiar cinci cine cineva contra cu cum cumva curând curînd când cât câte câtva câţi cînd cît cîte cîtva cîţi că căci cărei căror cărui către da dacă dar datorită dată dau de deci deja deoarece departe deşi din dinaintea dintr- dintre doi doilea două drept după dă ea ei el ele eram este eu eşti face fata fi fie fiecare fii fim fiu fiţi frumos fără graţie halbă iar ieri la le li lor lui lângă lîngă mai mea mei mele mereu meu mi mie mine mult multă mulţi mulţumesc mâine mîine mă ne nevoie nici nicăieri nimeni nimeri nimic nişte noastre noastră noi noroc nostru nouă noştri nu opt ori oricare orice oricine oricum oricând oricât oricînd oricît oriunde patra patru patrulea pe pentru peste pic poate pot prea prima primul prin puţin puţina puţină până pînă rog sa sale sau se spate spre sub sunt suntem sunteţi sută sînt sîntem sînteţi să săi său ta tale te timp tine toate toată tot totuşi toţi trei treia treilea tu tăi tău un una unde undeva unei uneia unele uneori unii unor unora unu unui unuia unul vi voastre voastră voi vostru vouă voştri vreme vreo vreun vă zece zero zi zice îi îl îmi împotriva în înainte înaintea încotro încât încît între întrucât întrucît îţi ăla ălea ăsta ăstea ăştia şapte şase şi ştiu ţi ţie".split(" "),i.Pipeline.registerFunction(i.ro.stopWordFilter,"stopWordFilter-ro")}}); diff --git a/static/js/lunr/lunr.ru.js b/static/js/lunr/lunr.ru.js new file mode 100644 index 0000000..4a0c415 --- /dev/null +++ b/static/js/lunr/lunr.ru.js @@ -0,0 +1,387 @@ +/*! + * Lunr languages, `Russian` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.ru = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.ru.trimmer, + lunr.ru.stopWordFilter, + lunr.ru.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.ru.wordCharacters = "\u0400-\u0484\u0487-\u052F\u1D2B\u1D78\u2DE0-\u2DFF\uA640-\uA69F\uFE2E\uFE2F"; + lunr.ru.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.ru.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.ru.trimmer, 'trimmer-ru'); + + /* lunr stemmer function */ + lunr.ru.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function RussianStemmer() { + var a_0 = [new Among("\u0432", -1, 1), new Among("\u0438\u0432", 0, 2), + new Among("\u044B\u0432", 0, 2), + new Among("\u0432\u0448\u0438", -1, 1), + new Among("\u0438\u0432\u0448\u0438", 3, 2), + new Among("\u044B\u0432\u0448\u0438", 3, 2), + new Among("\u0432\u0448\u0438\u0441\u044C", -1, 1), + new Among("\u0438\u0432\u0448\u0438\u0441\u044C", 6, 2), + new Among("\u044B\u0432\u0448\u0438\u0441\u044C", 6, 2) + ], + a_1 = [ + new Among("\u0435\u0435", -1, 1), new Among("\u0438\u0435", -1, 1), + new Among("\u043E\u0435", -1, 1), new Among("\u044B\u0435", -1, 1), + new Among("\u0438\u043C\u0438", -1, 1), + new Among("\u044B\u043C\u0438", -1, 1), + new Among("\u0435\u0439", -1, 1), new Among("\u0438\u0439", -1, 1), + new Among("\u043E\u0439", -1, 1), new Among("\u044B\u0439", -1, 1), + new Among("\u0435\u043C", -1, 1), new Among("\u0438\u043C", -1, 1), + new Among("\u043E\u043C", -1, 1), new Among("\u044B\u043C", -1, 1), + new Among("\u0435\u0433\u043E", -1, 1), + new Among("\u043E\u0433\u043E", -1, 1), + new Among("\u0435\u043C\u0443", -1, 1), + new Among("\u043E\u043C\u0443", -1, 1), + new Among("\u0438\u0445", -1, 1), new Among("\u044B\u0445", -1, 1), + new Among("\u0435\u044E", -1, 1), new Among("\u043E\u044E", -1, 1), + new Among("\u0443\u044E", -1, 1), new Among("\u044E\u044E", -1, 1), + new Among("\u0430\u044F", -1, 1), new Among("\u044F\u044F", -1, 1) + ], + a_2 = [ + new Among("\u0435\u043C", -1, 1), new Among("\u043D\u043D", -1, 1), + new Among("\u0432\u0448", -1, 1), + new Among("\u0438\u0432\u0448", 2, 2), + new Among("\u044B\u0432\u0448", 2, 2), new Among("\u0449", -1, 1), + new Among("\u044E\u0449", 5, 1), + new Among("\u0443\u044E\u0449", 6, 2) + ], + a_3 = [ + new Among("\u0441\u044C", -1, 1), new Among("\u0441\u044F", -1, 1) + ], + a_4 = [ + new Among("\u043B\u0430", -1, 1), + new Among("\u0438\u043B\u0430", 0, 2), + new Among("\u044B\u043B\u0430", 0, 2), + new Among("\u043D\u0430", -1, 1), + new Among("\u0435\u043D\u0430", 3, 2), + new Among("\u0435\u0442\u0435", -1, 1), + new Among("\u0438\u0442\u0435", -1, 2), + new Among("\u0439\u0442\u0435", -1, 1), + new Among("\u0435\u0439\u0442\u0435", 7, 2), + new Among("\u0443\u0439\u0442\u0435", 7, 2), + new Among("\u043B\u0438", -1, 1), + new Among("\u0438\u043B\u0438", 10, 2), + new Among("\u044B\u043B\u0438", 10, 2), new Among("\u0439", -1, 1), + new Among("\u0435\u0439", 13, 2), new Among("\u0443\u0439", 13, 2), + new Among("\u043B", -1, 1), new Among("\u0438\u043B", 16, 2), + new Among("\u044B\u043B", 16, 2), new Among("\u0435\u043C", -1, 1), + new Among("\u0438\u043C", -1, 2), new Among("\u044B\u043C", -1, 2), + new Among("\u043D", -1, 1), new Among("\u0435\u043D", 22, 2), + new Among("\u043B\u043E", -1, 1), + new Among("\u0438\u043B\u043E", 24, 2), + new Among("\u044B\u043B\u043E", 24, 2), + new Among("\u043D\u043E", -1, 1), + new Among("\u0435\u043D\u043E", 27, 2), + new Among("\u043D\u043D\u043E", 27, 1), + new Among("\u0435\u0442", -1, 1), + new Among("\u0443\u0435\u0442", 30, 2), + new Among("\u0438\u0442", -1, 2), new Among("\u044B\u0442", -1, 2), + new Among("\u044E\u0442", -1, 1), + new Among("\u0443\u044E\u0442", 34, 2), + new Among("\u044F\u0442", -1, 2), new Among("\u043D\u044B", -1, 1), + new Among("\u0435\u043D\u044B", 37, 2), + new Among("\u0442\u044C", -1, 1), + new Among("\u0438\u0442\u044C", 39, 2), + new Among("\u044B\u0442\u044C", 39, 2), + new Among("\u0435\u0448\u044C", -1, 1), + new Among("\u0438\u0448\u044C", -1, 2), new Among("\u044E", -1, 2), + new Among("\u0443\u044E", 44, 2) + ], + a_5 = [ + new Among("\u0430", -1, 1), new Among("\u0435\u0432", -1, 1), + new Among("\u043E\u0432", -1, 1), new Among("\u0435", -1, 1), + new Among("\u0438\u0435", 3, 1), new Among("\u044C\u0435", 3, 1), + new Among("\u0438", -1, 1), new Among("\u0435\u0438", 6, 1), + new Among("\u0438\u0438", 6, 1), + new Among("\u0430\u043C\u0438", 6, 1), + new Among("\u044F\u043C\u0438", 6, 1), + new Among("\u0438\u044F\u043C\u0438", 10, 1), + new Among("\u0439", -1, 1), new Among("\u0435\u0439", 12, 1), + new Among("\u0438\u0435\u0439", 13, 1), + new Among("\u0438\u0439", 12, 1), new Among("\u043E\u0439", 12, 1), + new Among("\u0430\u043C", -1, 1), new Among("\u0435\u043C", -1, 1), + new Among("\u0438\u0435\u043C", 18, 1), + new Among("\u043E\u043C", -1, 1), new Among("\u044F\u043C", -1, 1), + new Among("\u0438\u044F\u043C", 21, 1), new Among("\u043E", -1, 1), + new Among("\u0443", -1, 1), new Among("\u0430\u0445", -1, 1), + new Among("\u044F\u0445", -1, 1), + new Among("\u0438\u044F\u0445", 26, 1), new Among("\u044B", -1, 1), + new Among("\u044C", -1, 1), new Among("\u044E", -1, 1), + new Among("\u0438\u044E", 30, 1), new Among("\u044C\u044E", 30, 1), + new Among("\u044F", -1, 1), new Among("\u0438\u044F", 33, 1), + new Among("\u044C\u044F", 33, 1) + ], + a_6 = [ + new Among("\u043E\u0441\u0442", -1, 1), + new Among("\u043E\u0441\u0442\u044C", -1, 1) + ], + a_7 = [ + new Among("\u0435\u0439\u0448\u0435", -1, 1), + new Among("\u043D", -1, 2), new Among("\u0435\u0439\u0448", -1, 1), + new Among("\u044C", -1, 3) + ], + g_v = [33, 65, 8, 232], + I_p2, I_pV, sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function habr3() { + while (!sbp.in_grouping(g_v, 1072, 1103)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + return true; + } + + function habr4() { + while (!sbp.out_grouping(g_v, 1072, 1103)) { + if (sbp.cursor >= sbp.limit) + return false; + sbp.cursor++; + } + return true; + } + + function r_mark_regions() { + I_pV = sbp.limit; + I_p2 = I_pV; + if (habr3()) { + I_pV = sbp.cursor; + if (habr4()) + if (habr3()) + if (habr4()) + I_p2 = sbp.cursor; + } + } + + function r_R2() { + return I_p2 <= sbp.cursor; + } + + function habr2(a, n) { + var among_var, v_1; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a, n); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + v_1 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "\u0430")) { + sbp.cursor = sbp.limit - v_1; + if (!sbp.eq_s_b(1, "\u044F")) + return false; + } + case 2: + sbp.slice_del(); + break; + } + return true; + } + return false; + } + + function r_perfective_gerund() { + return habr2(a_0, 9); + } + + function habr1(a, n) { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a, n); + if (among_var) { + sbp.bra = sbp.cursor; + if (among_var == 1) + sbp.slice_del(); + return true; + } + return false; + } + + function r_adjective() { + return habr1(a_1, 26); + } + + function r_adjectival() { + var among_var; + if (r_adjective()) { + habr2(a_2, 8); + return true; + } + return false; + } + + function r_reflexive() { + return habr1(a_3, 2); + } + + function r_verb() { + return habr2(a_4, 46); + } + + function r_noun() { + habr1(a_5, 36); + } + + function r_derivational() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_6, 2); + if (among_var) { + sbp.bra = sbp.cursor; + if (r_R2() && among_var == 1) + sbp.slice_del(); + } + } + + function r_tidy_up() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_7, 4); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (!sbp.eq_s_b(1, "\u043D")) + break; + sbp.bra = sbp.cursor; + case 2: + if (!sbp.eq_s_b(1, "\u043D")) + break; + case 3: + sbp.slice_del(); + break; + } + } + } + this.stem = function() { + r_mark_regions(); + sbp.cursor = sbp.limit; + if (sbp.cursor < I_pV) + return false; + sbp.limit_backward = I_pV; + if (!r_perfective_gerund()) { + sbp.cursor = sbp.limit; + if (!r_reflexive()) + sbp.cursor = sbp.limit; + if (!r_adjectival()) { + sbp.cursor = sbp.limit; + if (!r_verb()) { + sbp.cursor = sbp.limit; + r_noun(); + } + } + } + sbp.cursor = sbp.limit; + sbp.ket = sbp.cursor; + if (sbp.eq_s_b(1, "\u0438")) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + } else + sbp.cursor = sbp.limit; + r_derivational(); + sbp.cursor = sbp.limit; + r_tidy_up(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.ru.stemmer, 'stemmer-ru'); + + /* stop word filter function */ + lunr.ru.stopWordFilter = function(token) { + if (lunr.ru.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.ru.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.ru.stopWordFilter.stopWords.length = 422; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.ru.stopWordFilter.stopWords.elements = ' алло без близко более больше будем будет будете будешь будто буду будут будь бы бывает бывь был была были было быть в важная важное важные важный вам вами вас ваш ваша ваше ваши вверх вдали вдруг ведь везде весь вниз внизу во вокруг вон восемнадцатый восемнадцать восемь восьмой вот впрочем времени время все всегда всего всем всеми всему всех всею всю всюду вся всё второй вы г где говорил говорит год года году да давно даже далеко дальше даром два двадцатый двадцать две двенадцатый двенадцать двух девятнадцатый девятнадцать девятый девять действительно дел день десятый десять для до довольно долго должно другая другие других друго другое другой е его ее ей ему если есть еще ещё ею её ж же жизнь за занят занята занято заняты затем зато зачем здесь значит и из или им именно иметь ими имя иногда их к каждая каждое каждые каждый кажется как какая какой кем когда кого ком кому конечно которая которого которой которые который которых кроме кругом кто куда лет ли лишь лучше люди м мало между меля менее меньше меня миллионов мимо мира мне много многочисленная многочисленное многочисленные многочисленный мной мною мог могут мож может можно можхо мои мой мор мочь моя моё мы на наверху над надо назад наиболее наконец нам нами нас начала наш наша наше наши не него недавно недалеко нее ней нельзя нем немного нему непрерывно нередко несколько нет нею неё ни нибудь ниже низко никогда никуда ними них ничего но ну нужно нх о об оба обычно один одиннадцатый одиннадцать однажды однако одного одной около он она они оно опять особенно от отовсюду отсюда очень первый перед по под пожалуйста позже пока пор пора после посреди потом потому почему почти прекрасно при про просто против процентов пятнадцатый пятнадцать пятый пять раз разве рано раньше рядом с сам сама сами самим самими самих само самого самой самом самому саму свое своего своей свои своих свою сеаой себе себя сегодня седьмой сейчас семнадцатый семнадцать семь сих сказал сказала сказать сколько слишком сначала снова со собой собою совсем спасибо стал суть т та так такая также такие такое такой там твой твоя твоё те тебе тебя тем теми теперь тех то тобой тобою тогда того тоже только том тому тот тою третий три тринадцатый тринадцать ту туда тут ты тысяч у уж уже уметь хорошо хотеть хоть хотя хочешь часто чаще чего человек чем чему через четвертый четыре четырнадцатый четырнадцать что чтоб чтобы чуть шестнадцатый шестнадцать шестой шесть эта эти этим этими этих это этого этой этом этому этот эту я а'.split(' '); + + lunr.Pipeline.registerFunction(lunr.ru.stopWordFilter, 'stopWordFilter-ru'); + }; +})) diff --git a/static/js/lunr/lunr.ru.min.js b/static/js/lunr/lunr.ru.min.js new file mode 100644 index 0000000..f254753 --- /dev/null +++ b/static/js/lunr/lunr.ru.min.js @@ -0,0 +1 @@ +!function(e,n){"function"==typeof define&&define.amd?define(n):"object"==typeof exports?module.exports=n():n()(e.lunr)}(this,function(){return function(n){if(void 0===n)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===n.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var _,b,r;n.ru=function(){this.pipeline.reset(),this.pipeline.add(n.ru.trimmer,n.ru.stopWordFilter,n.ru.stemmer)},n.ru.wordCharacters="Ѐ-҄҇-ԯᴫᵸⷠ-ⷿꙀ-ꚟ︮︯",n.ru.trimmer=n.trimmerSupport.generateTrimmer(n.ru.wordCharacters),n.Pipeline.registerFunction(n.ru.trimmer,"trimmer-ru"),n.ru.stemmer=(_=n.stemmerSupport.Among,b=n.stemmerSupport.SnowballProgram,r=new function(){var n,r,w=[new _("в",-1,1),new _("ив",0,2),new _("ыв",0,2),new _("вши",-1,1),new _("ивши",3,2),new _("ывши",3,2),new _("вшись",-1,1),new _("ившись",6,2),new _("ывшись",6,2)],t=[new _("ее",-1,1),new _("ие",-1,1),new _("ое",-1,1),new _("ые",-1,1),new _("ими",-1,1),new _("ыми",-1,1),new _("ей",-1,1),new _("ий",-1,1),new _("ой",-1,1),new _("ый",-1,1),new _("ем",-1,1),new _("им",-1,1),new _("ом",-1,1),new _("ым",-1,1),new _("его",-1,1),new _("ого",-1,1),new _("ему",-1,1),new _("ому",-1,1),new _("их",-1,1),new _("ых",-1,1),new _("ею",-1,1),new _("ою",-1,1),new _("ую",-1,1),new _("юю",-1,1),new _("ая",-1,1),new _("яя",-1,1)],i=[new _("ем",-1,1),new _("нн",-1,1),new _("вш",-1,1),new _("ивш",2,2),new _("ывш",2,2),new _("щ",-1,1),new _("ющ",5,1),new _("ующ",6,2)],o=[new _("сь",-1,1),new _("ся",-1,1)],s=[new _("ла",-1,1),new _("ила",0,2),new _("ыла",0,2),new _("на",-1,1),new _("ена",3,2),new _("ете",-1,1),new _("ите",-1,2),new _("йте",-1,1),new _("ейте",7,2),new _("уйте",7,2),new _("ли",-1,1),new _("или",10,2),new _("ыли",10,2),new _("й",-1,1),new _("ей",13,2),new _("уй",13,2),new _("л",-1,1),new _("ил",16,2),new _("ыл",16,2),new _("ем",-1,1),new _("им",-1,2),new _("ым",-1,2),new _("н",-1,1),new _("ен",22,2),new _("ло",-1,1),new _("ило",24,2),new _("ыло",24,2),new _("но",-1,1),new _("ено",27,2),new _("нно",27,1),new _("ет",-1,1),new _("ует",30,2),new _("ит",-1,2),new _("ыт",-1,2),new _("ют",-1,1),new _("уют",34,2),new _("ят",-1,2),new _("ны",-1,1),new _("ены",37,2),new _("ть",-1,1),new _("ить",39,2),new _("ыть",39,2),new _("ешь",-1,1),new _("ишь",-1,2),new _("ю",-1,2),new _("ую",44,2)],u=[new _("а",-1,1),new _("ев",-1,1),new _("ов",-1,1),new _("е",-1,1),new _("ие",3,1),new _("ье",3,1),new _("и",-1,1),new _("еи",6,1),new _("ии",6,1),new _("ами",6,1),new _("ями",6,1),new _("иями",10,1),new _("й",-1,1),new _("ей",12,1),new _("ией",13,1),new _("ий",12,1),new _("ой",12,1),new _("ам",-1,1),new _("ем",-1,1),new _("ием",18,1),new _("ом",-1,1),new _("ям",-1,1),new _("иям",21,1),new _("о",-1,1),new _("у",-1,1),new _("ах",-1,1),new _("ях",-1,1),new _("иях",26,1),new _("ы",-1,1),new _("ь",-1,1),new _("ю",-1,1),new _("ию",30,1),new _("ью",30,1),new _("я",-1,1),new _("ия",33,1),new _("ья",33,1)],c=[new _("ост",-1,1),new _("ость",-1,1)],m=[new _("ейше",-1,1),new _("н",-1,2),new _("ейш",-1,1),new _("ь",-1,3)],e=[33,65,8,232],l=new b;function f(){for(;!l.in_grouping(e,1072,1103);){if(l.cursor>=l.limit)return;l.cursor++}return 1}function p(){for(;!l.out_grouping(e,1072,1103);){if(l.cursor>=l.limit)return;l.cursor++}return 1}function d(e,n){var r;if(l.ket=l.cursor,e=l.find_among_b(e,n)){switch(l.bra=l.cursor,e){case 1:if(r=l.limit-l.cursor,!l.eq_s_b(1,"а")&&(l.cursor=l.limit-r,!l.eq_s_b(1,"я")))return;case 2:l.slice_del()}return 1}}function a(e,n){return l.ket=l.cursor,(e=l.find_among_b(e,n))&&(l.bra=l.cursor,1==e&&l.slice_del(),1)}this.setCurrent=function(e){l.setCurrent(e)},this.getCurrent=function(){return l.getCurrent()},this.stem=function(){if(r=l.limit,n=r,f()&&(r=l.cursor,p())&&f()&&p()&&(n=l.cursor),l.cursor=l.limit,l.cursor= sbp.limit) + return; + sbp.cursor++; + } + while (!sbp.out_grouping(g_v, 97, 246)) { + if (sbp.cursor >= sbp.limit) + return; + sbp.cursor++; + } + I_p1 = sbp.cursor; + if (I_p1 < I_x) + I_p1 = I_x; + } + } + + function r_main_suffix() { + var among_var, v_2 = sbp.limit_backward; + if (sbp.cursor >= I_p1) { + sbp.limit_backward = I_p1; + sbp.cursor = sbp.limit; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_0, 37); + sbp.limit_backward = v_2; + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + if (sbp.in_grouping_b(g_s_ending, 98, 121)) + sbp.slice_del(); + break; + } + } + } + } + + function r_consonant_pair() { + var v_1 = sbp.limit_backward; + if (sbp.cursor >= I_p1) { + sbp.limit_backward = I_p1; + sbp.cursor = sbp.limit; + if (sbp.find_among_b(a_1, 7)) { + sbp.cursor = sbp.limit; + sbp.ket = sbp.cursor; + if (sbp.cursor > sbp.limit_backward) { + sbp.bra = --sbp.cursor; + sbp.slice_del(); + } + } + sbp.limit_backward = v_1; + } + } + + function r_other_suffix() { + var among_var, v_2; + if (sbp.cursor >= I_p1) { + v_2 = sbp.limit_backward; + sbp.limit_backward = I_p1; + sbp.cursor = sbp.limit; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_2, 5); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_del(); + break; + case 2: + sbp.slice_from("l\u00F6s"); + break; + case 3: + sbp.slice_from("full"); + break; + } + } + sbp.limit_backward = v_2; + } + } + this.stem = function() { + var v_1 = sbp.cursor; + r_mark_regions(); + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_main_suffix(); + sbp.cursor = sbp.limit; + r_consonant_pair(); + sbp.cursor = sbp.limit; + r_other_suffix(); + return true; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.sv.stemmer, 'stemmer-sv'); + + /* stop word filter function */ + lunr.sv.stopWordFilter = function(token) { + if (lunr.sv.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.sv.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.sv.stopWordFilter.stopWords.length = 115; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.sv.stopWordFilter.stopWords.elements = ' alla allt att av blev bli blir blivit de dem den denna deras dess dessa det detta dig din dina ditt du där då efter ej eller en er era ert ett från för ha hade han hans har henne hennes hon honom hur här i icke ingen inom inte jag ju kan kunde man med mellan men mig min mina mitt mot mycket ni nu när någon något några och om oss på samma sedan sig sin sina sitta själv skulle som så sådan sådana sådant till under upp ut utan vad var vara varför varit varje vars vart vem vi vid vilka vilkas vilken vilket vår våra vårt än är åt över'.split(' '); + + lunr.Pipeline.registerFunction(lunr.sv.stopWordFilter, 'stopWordFilter-sv'); + }; +})) diff --git a/static/js/lunr/lunr.sv.min.js b/static/js/lunr/lunr.sv.min.js new file mode 100644 index 0000000..1e5c7a3 --- /dev/null +++ b/static/js/lunr/lunr.sv.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r():r()(e.lunr)}(this,function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var e,d,n;r.sv=function(){this.pipeline.reset(),this.pipeline.add(r.sv.trimmer,r.sv.stopWordFilter,r.sv.stemmer)},r.sv.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.sv.trimmer=r.trimmerSupport.generateTrimmer(r.sv.wordCharacters),r.Pipeline.registerFunction(r.sv.trimmer,"trimmer-sv"),r.sv.stemmer=(e=r.stemmerSupport.Among,d=r.stemmerSupport.SnowballProgram,n=new function(){var n,t,i=[new e("a",-1,1),new e("arna",0,1),new e("erna",0,1),new e("heterna",2,1),new e("orna",0,1),new e("ad",-1,1),new e("e",-1,1),new e("ade",6,1),new e("ande",6,1),new e("arne",6,1),new e("are",6,1),new e("aste",6,1),new e("en",-1,1),new e("anden",12,1),new e("aren",12,1),new e("heten",12,1),new e("ern",-1,1),new e("ar",-1,1),new e("er",-1,1),new e("heter",18,1),new e("or",-1,1),new e("s",-1,2),new e("as",21,1),new e("arnas",22,1),new e("ernas",22,1),new e("ornas",22,1),new e("es",21,1),new e("ades",26,1),new e("andes",26,1),new e("ens",21,1),new e("arens",29,1),new e("hetens",29,1),new e("erns",21,1),new e("at",-1,1),new e("andet",-1,1),new e("het",-1,1),new e("ast",-1,1)],s=[new e("dd",-1,-1),new e("gd",-1,-1),new e("nn",-1,-1),new e("dt",-1,-1),new e("gt",-1,-1),new e("kt",-1,-1),new e("tt",-1,-1)],a=[new e("ig",-1,1),new e("lig",0,1),new e("els",-1,1),new e("fullt",-1,3),new e("löst",-1,2)],o=[17,65,16,1,0,0,0,0,0,0,0,0,0,0,0,0,24,0,32],u=[119,127,149],l=new d;this.setCurrent=function(e){l.setCurrent(e)},this.getCurrent=function(){return l.getCurrent()},this.stem=function(){var e=l.cursor;!function(){var e,r=l.cursor+3;if(t=l.limit,0<=r||r<=l.limit){for(n=r;;){if(e=l.cursor,l.in_grouping(o,97,246)){l.cursor=e;break}if(l.cursor=e,l.cursor>=l.limit)return;l.cursor++}for(;!l.out_grouping(o,97,246);){if(l.cursor>=l.limit)return;l.cursor++}(t=l.cursor)=t&&(l.limit_backward=t,l.cursor=l.limit,l.ket=l.cursor,r=l.find_among_b(i,37),l.limit_backward=e,r))switch(l.bra=l.cursor,r){case 1:l.slice_del();break;case 2:l.in_grouping_b(u,98,121)&&l.slice_del()}if(l.cursor=l.limit,e=l.limit_backward,l.cursor>=t&&(l.limit_backward=t,l.cursor=l.limit,l.find_among_b(s,7)&&(l.cursor=l.limit,l.ket=l.cursor,l.cursor>l.limit_backward)&&(l.bra=--l.cursor,l.slice_del()),l.limit_backward=e),l.cursor=l.limit,l.cursor>=t){if(r=l.limit_backward,l.limit_backward=t,l.cursor=l.limit,l.ket=l.cursor,e=l.find_among_b(a,5))switch(l.bra=l.cursor,e){case 1:l.slice_del();break;case 2:l.slice_from("lös");break;case 3:l.slice_from("full")}l.limit_backward=r}return!0}},function(e){return n.setCurrent(e),n.stem(),n.getCurrent()}),r.Pipeline.registerFunction(r.sv.stemmer,"stemmer-sv"),r.sv.stopWordFilter=function(e){if(-1===r.sv.stopWordFilter.stopWords.indexOf(e))return e},r.sv.stopWordFilter.stopWords=new r.SortedSet,r.sv.stopWordFilter.stopWords.length=115,r.sv.stopWordFilter.stopWords.elements=" alla allt att av blev bli blir blivit de dem den denna deras dess dessa det detta dig din dina ditt du där då efter ej eller en er era ert ett från för ha hade han hans har henne hennes hon honom hur här i icke ingen inom inte jag ju kan kunde man med mellan men mig min mina mitt mot mycket ni nu när någon något några och om oss på samma sedan sig sin sina sitta själv skulle som så sådan sådana sådant till under upp ut utan vad var vara varför varit varje vars vart vem vi vid vilka vilkas vilken vilket vår våra vårt än är åt över".split(" "),r.Pipeline.registerFunction(r.sv.stopWordFilter,"stopWordFilter-sv")}}); diff --git a/static/js/lunr/lunr.tr.js b/static/js/lunr/lunr.tr.js new file mode 100644 index 0000000..ccecfad --- /dev/null +++ b/static/js/lunr/lunr.tr.js @@ -0,0 +1,1070 @@ +/*! + * Lunr languages, `Turkish` language + * https://github.com/MihaiValentin/lunr-languages + * + * Copyright 2014, Mihai Valentin + * http://www.mozilla.org/MPL/ + */ +/*! + * based on + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; +(function(root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function() { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function(lunr) { + /* throw error if lunr is not yet included */ + if ('undefined' === typeof lunr) { + throw new Error('Lunr is not present. Please include / require Lunr before this script.'); + } + + /* throw error if lunr stemmer support is not yet included */ + if ('undefined' === typeof lunr.stemmerSupport) { + throw new Error('Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.'); + } + + /* register specific locale function */ + lunr.tr = function() { + this.pipeline.reset(); + this.pipeline.add( + lunr.tr.trimmer, + lunr.tr.stopWordFilter, + lunr.tr.stemmer + ); + }; + + /* lunr trimmer function */ + lunr.tr.wordCharacters = "A-Za-z\xAA\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02B8\u02E0-\u02E4\u1D00-\u1D25\u1D2C-\u1D5C\u1D62-\u1D65\u1D6B-\u1D77\u1D79-\u1DBE\u1E00-\u1EFF\u2071\u207F\u2090-\u209C\u212A\u212B\u2132\u214E\u2160-\u2188\u2C60-\u2C7F\uA722-\uA787\uA78B-\uA7AD\uA7B0-\uA7B7\uA7F7-\uA7FF\uAB30-\uAB5A\uAB5C-\uAB64\uFB00-\uFB06\uFF21-\uFF3A\uFF41-\uFF5A"; + lunr.tr.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.tr.wordCharacters); + + lunr.Pipeline.registerFunction(lunr.tr.trimmer, 'trimmer-tr'); + + /* lunr stemmer function */ + lunr.tr.stemmer = (function() { + /* create the wrapped stemmer object */ + var Among = lunr.stemmerSupport.Among, + SnowballProgram = lunr.stemmerSupport.SnowballProgram, + st = new function TurkishStemmer() { + var a_0 = [new Among("m", -1, -1), new Among("n", -1, -1), + new Among("miz", -1, -1), new Among("niz", -1, -1), + new Among("muz", -1, -1), new Among("nuz", -1, -1), + new Among("m\u00FCz", -1, -1), new Among("n\u00FCz", -1, -1), + new Among("m\u0131z", -1, -1), new Among("n\u0131z", -1, -1) + ], + a_1 = [ + new Among("leri", -1, -1), new Among("lar\u0131", -1, -1) + ], + a_2 = [ + new Among("ni", -1, -1), new Among("nu", -1, -1), + new Among("n\u00FC", -1, -1), new Among("n\u0131", -1, -1) + ], + a_3 = [ + new Among("in", -1, -1), new Among("un", -1, -1), + new Among("\u00FCn", -1, -1), new Among("\u0131n", -1, -1) + ], + a_4 = [ + new Among("a", -1, -1), new Among("e", -1, -1) + ], + a_5 = [ + new Among("na", -1, -1), new Among("ne", -1, -1) + ], + a_6 = [ + new Among("da", -1, -1), new Among("ta", -1, -1), + new Among("de", -1, -1), new Among("te", -1, -1) + ], + a_7 = [ + new Among("nda", -1, -1), new Among("nde", -1, -1) + ], + a_8 = [ + new Among("dan", -1, -1), new Among("tan", -1, -1), + new Among("den", -1, -1), new Among("ten", -1, -1) + ], + a_9 = [ + new Among("ndan", -1, -1), new Among("nden", -1, -1) + ], + a_10 = [ + new Among("la", -1, -1), new Among("le", -1, -1) + ], + a_11 = [ + new Among("ca", -1, -1), new Among("ce", -1, -1) + ], + a_12 = [ + new Among("im", -1, -1), new Among("um", -1, -1), + new Among("\u00FCm", -1, -1), new Among("\u0131m", -1, -1) + ], + a_13 = [ + new Among("sin", -1, -1), new Among("sun", -1, -1), + new Among("s\u00FCn", -1, -1), new Among("s\u0131n", -1, -1) + ], + a_14 = [ + new Among("iz", -1, -1), new Among("uz", -1, -1), + new Among("\u00FCz", -1, -1), new Among("\u0131z", -1, -1) + ], + a_15 = [ + new Among("siniz", -1, -1), new Among("sunuz", -1, -1), + new Among("s\u00FCn\u00FCz", -1, -1), + new Among("s\u0131n\u0131z", -1, -1) + ], + a_16 = [ + new Among("lar", -1, -1), new Among("ler", -1, -1) + ], + a_17 = [ + new Among("niz", -1, -1), new Among("nuz", -1, -1), + new Among("n\u00FCz", -1, -1), new Among("n\u0131z", -1, -1) + ], + a_18 = [ + new Among("dir", -1, -1), new Among("tir", -1, -1), + new Among("dur", -1, -1), new Among("tur", -1, -1), + new Among("d\u00FCr", -1, -1), new Among("t\u00FCr", -1, -1), + new Among("d\u0131r", -1, -1), new Among("t\u0131r", -1, -1) + ], + a_19 = [ + new Among("cas\u0131na", -1, -1), new Among("cesine", -1, -1) + ], + a_20 = [ + new Among("di", -1, -1), new Among("ti", -1, -1), + new Among("dik", -1, -1), new Among("tik", -1, -1), + new Among("duk", -1, -1), new Among("tuk", -1, -1), + new Among("d\u00FCk", -1, -1), new Among("t\u00FCk", -1, -1), + new Among("d\u0131k", -1, -1), new Among("t\u0131k", -1, -1), + new Among("dim", -1, -1), new Among("tim", -1, -1), + new Among("dum", -1, -1), new Among("tum", -1, -1), + new Among("d\u00FCm", -1, -1), new Among("t\u00FCm", -1, -1), + new Among("d\u0131m", -1, -1), new Among("t\u0131m", -1, -1), + new Among("din", -1, -1), new Among("tin", -1, -1), + new Among("dun", -1, -1), new Among("tun", -1, -1), + new Among("d\u00FCn", -1, -1), new Among("t\u00FCn", -1, -1), + new Among("d\u0131n", -1, -1), new Among("t\u0131n", -1, -1), + new Among("du", -1, -1), new Among("tu", -1, -1), + new Among("d\u00FC", -1, -1), new Among("t\u00FC", -1, -1), + new Among("d\u0131", -1, -1), new Among("t\u0131", -1, -1) + ], + a_21 = [ + new Among("sa", -1, -1), new Among("se", -1, -1), + new Among("sak", -1, -1), new Among("sek", -1, -1), + new Among("sam", -1, -1), new Among("sem", -1, -1), + new Among("san", -1, -1), new Among("sen", -1, -1) + ], + a_22 = [ + new Among("mi\u015F", -1, -1), new Among("mu\u015F", -1, -1), + new Among("m\u00FC\u015F", -1, -1), + new Among("m\u0131\u015F", -1, -1) + ], + a_23 = [new Among("b", -1, 1), + new Among("c", -1, 2), new Among("d", -1, 3), + new Among("\u011F", -1, 4) + ], + g_vowel = [17, 65, 16, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 32, 8, 0, 0, 0, 0, 0, 0, 1 + ], + g_U = [ + 1, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, + 0, 0, 0, 1 + ], + g_vowel1 = [1, 64, 16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 + ], + g_vowel2 = [17, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 130 + ], + g_vowel3 = [1, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1 + ], + g_vowel4 = [17], + g_vowel5 = [65], + g_vowel6 = [65], + B_c_s_n_s, I_strlen, g_habr = [ + ["a", g_vowel1, 97, 305], + ["e", g_vowel2, 101, 252], + ["\u0131", g_vowel3, 97, 305], + ["i", g_vowel4, 101, 105], + ["o", g_vowel5, 111, 117], + ["\u00F6", g_vowel6, 246, 252], + ["u", g_vowel5, 111, 117] + ], + sbp = new SnowballProgram(); + this.setCurrent = function(word) { + sbp.setCurrent(word); + }; + this.getCurrent = function() { + return sbp.getCurrent(); + }; + + function habr1(g_v, n1, n2) { + while (true) { + var v_1 = sbp.limit - sbp.cursor; + if (sbp.in_grouping_b(g_v, n1, n2)) { + sbp.cursor = sbp.limit - v_1; + break; + } + sbp.cursor = sbp.limit - v_1; + if (sbp.cursor <= sbp.limit_backward) + return false; + sbp.cursor--; + } + return true; + } + + function r_check_vowel_harmony() { + var v_1, v_2; + v_1 = sbp.limit - sbp.cursor; + habr1(g_vowel, 97, 305); + for (var i = 0; i < g_habr.length; i++) { + v_2 = sbp.limit - sbp.cursor; + var habr = g_habr[i]; + if (sbp.eq_s_b(1, habr[0]) && habr1(habr[1], habr[2], habr[3])) { + sbp.cursor = sbp.limit - v_1; + return true; + } + sbp.cursor = sbp.limit - v_2; + } + sbp.cursor = sbp.limit - v_2; + if (!sbp.eq_s_b(1, "\u00FC") || !habr1(g_vowel6, 246, 252)) + return false; + sbp.cursor = sbp.limit - v_1; + return true; + } + + function habr2(f1, f2) { + var v_1 = sbp.limit - sbp.cursor, + v_2; + if (f1()) { + sbp.cursor = sbp.limit - v_1; + if (sbp.cursor > sbp.limit_backward) { + sbp.cursor--; + v_2 = sbp.limit - sbp.cursor; + if (f2()) { + sbp.cursor = sbp.limit - v_2; + return true; + } + } + } + sbp.cursor = sbp.limit - v_1; + if (f1()) { + sbp.cursor = sbp.limit - v_1; + return false; + } + sbp.cursor = sbp.limit - v_1; + if (sbp.cursor <= sbp.limit_backward) + return false; + sbp.cursor--; + if (!f2()) + return false; + sbp.cursor = sbp.limit - v_1; + return true; + } + + function habr3(f1) { + return habr2(f1, function() { + return sbp.in_grouping_b(g_vowel, 97, 305); + }); + } + + function r_mark_suffix_with_optional_n_consonant() { + return habr3(function() { + return sbp.eq_s_b(1, "n"); + }); + } + + function r_mark_suffix_with_optional_s_consonant() { + return habr3(function() { + return sbp.eq_s_b(1, "s"); + }); + } + + function r_mark_suffix_with_optional_y_consonant() { + return habr3(function() { + return sbp.eq_s_b(1, "y"); + }); + } + + function r_mark_suffix_with_optional_U_vowel() { + return habr2(function() { + return sbp.in_grouping_b(g_U, 105, 305); + }, function() { + return sbp.out_grouping_b(g_vowel, 97, 305); + }); + } + + function r_mark_possessives() { + return sbp.find_among_b(a_0, 10) && r_mark_suffix_with_optional_U_vowel(); + } + + function r_mark_sU() { + return r_check_vowel_harmony() && sbp.in_grouping_b(g_U, 105, 305) && r_mark_suffix_with_optional_s_consonant(); + } + + function r_mark_lArI() { + return sbp.find_among_b(a_1, 2); + } + + function r_mark_yU() { + return r_check_vowel_harmony() && sbp.in_grouping_b(g_U, 105, 305) && r_mark_suffix_with_optional_y_consonant(); + } + + function r_mark_nU() { + return r_check_vowel_harmony() && sbp.find_among_b(a_2, 4); + } + + function r_mark_nUn() { + return r_check_vowel_harmony() && sbp.find_among_b(a_3, 4) && r_mark_suffix_with_optional_n_consonant(); + } + + function r_mark_yA() { + return r_check_vowel_harmony() && sbp.find_among_b(a_4, 2) && r_mark_suffix_with_optional_y_consonant(); + } + + function r_mark_nA() { + return r_check_vowel_harmony() && sbp.find_among_b(a_5, 2); + } + + function r_mark_DA() { + return r_check_vowel_harmony() && sbp.find_among_b(a_6, 4); + } + + function r_mark_ndA() { + return r_check_vowel_harmony() && sbp.find_among_b(a_7, 2); + } + + function r_mark_DAn() { + return r_check_vowel_harmony() && sbp.find_among_b(a_8, 4); + } + + function r_mark_ndAn() { + return r_check_vowel_harmony() && sbp.find_among_b(a_9, 2); + } + + function r_mark_ylA() { + return r_check_vowel_harmony() && sbp.find_among_b(a_10, 2) && r_mark_suffix_with_optional_y_consonant(); + } + + function r_mark_ki() { + return sbp.eq_s_b(2, "ki"); + } + + function r_mark_ncA() { + return r_check_vowel_harmony() && sbp.find_among_b(a_11, 2) && r_mark_suffix_with_optional_n_consonant(); + } + + function r_mark_yUm() { + return r_check_vowel_harmony() && sbp.find_among_b(a_12, 4) && r_mark_suffix_with_optional_y_consonant(); + } + + function r_mark_sUn() { + return r_check_vowel_harmony() && sbp.find_among_b(a_13, 4); + } + + function r_mark_yUz() { + return r_check_vowel_harmony() && sbp.find_among_b(a_14, 4) && r_mark_suffix_with_optional_y_consonant(); + } + + function r_mark_sUnUz() { + return sbp.find_among_b(a_15, 4); + } + + function r_mark_lAr() { + return r_check_vowel_harmony() && sbp.find_among_b(a_16, 2); + } + + function r_mark_nUz() { + return r_check_vowel_harmony() && sbp.find_among_b(a_17, 4); + } + + function r_mark_DUr() { + return r_check_vowel_harmony() && sbp.find_among_b(a_18, 8); + } + + function r_mark_cAsInA() { + return sbp.find_among_b(a_19, 2); + } + + function r_mark_yDU() { + return r_check_vowel_harmony() && sbp.find_among_b(a_20, 32) && r_mark_suffix_with_optional_y_consonant(); + } + + function r_mark_ysA() { + return sbp.find_among_b(a_21, 8) && r_mark_suffix_with_optional_y_consonant(); + } + + function r_mark_ymUs_() { + return r_check_vowel_harmony() && sbp.find_among_b(a_22, 4) && r_mark_suffix_with_optional_y_consonant(); + } + + function r_mark_yken() { + return sbp.eq_s_b(3, "ken") && r_mark_suffix_with_optional_y_consonant(); + } + + function habr4() { + var v_1 = sbp.limit - sbp.cursor; + if (!r_mark_ymUs_()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yDU()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_ysA()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yken()) + return true; + } + } + } + return false; + } + + function habr5() { + if (r_mark_cAsInA()) { + var v_1 = sbp.limit - sbp.cursor; + if (!r_mark_sUnUz()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_lAr()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yUm()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_sUn()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yUz()) + sbp.cursor = sbp.limit - v_1; + } + } + } + } + if (r_mark_ymUs_()) + return false; + } + return true; + } + + function habr6() { + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + var v_1 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (!r_mark_DUr()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yDU()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_ysA()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_ymUs_()) + sbp.cursor = sbp.limit - v_1; + } + } + } + B_c_s_n_s = false; + return false; + } + return true; + } + + function habr7() { + if (!r_mark_nUz()) + return true; + var v_1 = sbp.limit - sbp.cursor; + if (!r_mark_yDU()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_ysA()) + return true; + } + return false; + } + + function habr8() { + var v_1 = sbp.limit - sbp.cursor, + v_2; + if (!r_mark_sUnUz()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yUz()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_sUn()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yUm()) + return true; + } + } + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + v_2 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (!r_mark_ymUs_()) + sbp.cursor = sbp.limit - v_2; + return false; + } + + function r_stem_nominal_verb_suffixes() { + var v_1 = sbp.limit - sbp.cursor, + v_2; + sbp.ket = sbp.cursor; + B_c_s_n_s = true; + if (habr4()) { + sbp.cursor = sbp.limit - v_1; + if (habr5()) { + sbp.cursor = sbp.limit - v_1; + if (habr6()) { + sbp.cursor = sbp.limit - v_1; + if (habr7()) { + sbp.cursor = sbp.limit - v_1; + if (habr8()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_DUr()) + return; + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + v_2 = sbp.limit - sbp.cursor; + if (!r_mark_sUnUz()) { + sbp.cursor = sbp.limit - v_2; + if (!r_mark_lAr()) { + sbp.cursor = sbp.limit - v_2; + if (!r_mark_yUm()) { + sbp.cursor = sbp.limit - v_2; + if (!r_mark_sUn()) { + sbp.cursor = sbp.limit - v_2; + if (!r_mark_yUz()) + sbp.cursor = sbp.limit - v_2; + } + } + } + } + if (!r_mark_ymUs_()) + sbp.cursor = sbp.limit - v_2; + } + } + } + } + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + } + + function r_stem_suffix_chain_before_ki() { + var v_1, v_2, v_3, v_4; + sbp.ket = sbp.cursor; + if (r_mark_ki()) { + v_1 = sbp.limit - sbp.cursor; + if (r_mark_DA()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + v_2 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } else { + sbp.cursor = sbp.limit - v_2; + if (r_mark_possessives()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } + } + } + return true; + } + sbp.cursor = sbp.limit - v_1; + if (r_mark_nUn()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + v_3 = sbp.limit - sbp.cursor; + if (r_mark_lArI()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + } else { + sbp.cursor = sbp.limit - v_3; + sbp.ket = sbp.cursor; + if (!r_mark_possessives()) { + sbp.cursor = sbp.limit - v_3; + if (!r_mark_sU()) { + sbp.cursor = sbp.limit - v_3; + if (!r_stem_suffix_chain_before_ki()) + return true; + } + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki() + } + } + return true; + } + sbp.cursor = sbp.limit - v_1; + if (r_mark_ndA()) { + v_4 = sbp.limit - sbp.cursor; + if (r_mark_lArI()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + } else { + sbp.cursor = sbp.limit - v_4; + if (r_mark_sU()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } + } else { + sbp.cursor = sbp.limit - v_4; + if (!r_stem_suffix_chain_before_ki()) + return false; + } + } + return true; + } + } + return false; + } + + function habr9(v_1) { + sbp.ket = sbp.cursor; + if (!r_mark_ndA()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_nA()) + return false; + } + var v_2 = sbp.limit - sbp.cursor; + if (r_mark_lArI()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + } else { + sbp.cursor = sbp.limit - v_2; + if (r_mark_sU()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } + } else { + sbp.cursor = sbp.limit - v_2; + if (!r_stem_suffix_chain_before_ki()) + return false; + } + } + return true; + } + + function habr10(v_1) { + sbp.ket = sbp.cursor; + if (!r_mark_ndAn()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_nU()) + return false; + } + var v_2 = sbp.limit - sbp.cursor; + if (!r_mark_sU()) { + sbp.cursor = sbp.limit - v_2; + if (!r_mark_lArI()) + return false; + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } + return true; + } + + function habr11() { + var v_1 = sbp.limit - sbp.cursor, + v_2; + sbp.ket = sbp.cursor; + if (!r_mark_nUn()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_ylA()) + return false; + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + v_2 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + if (r_stem_suffix_chain_before_ki()) + return true; + } + sbp.cursor = sbp.limit - v_2; + sbp.ket = sbp.cursor; + if (!r_mark_possessives()) { + sbp.cursor = sbp.limit - v_2; + if (!r_mark_sU()) { + sbp.cursor = sbp.limit - v_2; + if (!r_stem_suffix_chain_before_ki()) + return true; + } + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } + return true; + } + + function habr12() { + var v_1 = sbp.limit - sbp.cursor, + v_2, v_3; + sbp.ket = sbp.cursor; + if (!r_mark_DA()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yU()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_yA()) + return false; + } + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + v_2 = sbp.limit - sbp.cursor; + if (r_mark_possessives()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + v_3 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (!r_mark_lAr()) + sbp.cursor = sbp.limit - v_3; + } else { + sbp.cursor = sbp.limit - v_2; + if (!r_mark_lAr()) + return true; + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + r_stem_suffix_chain_before_ki(); + return true; + } + + function r_stem_noun_suffixes() { + var v_1 = sbp.limit - sbp.cursor, + v_2, v_3; + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + return; + } + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + if (r_mark_ncA()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + v_2 = sbp.limit - sbp.cursor; + sbp.ket = sbp.cursor; + if (r_mark_lArI()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + } else { + sbp.cursor = sbp.limit - v_2; + sbp.ket = sbp.cursor; + if (!r_mark_possessives()) { + sbp.cursor = sbp.limit - v_2; + if (!r_mark_sU()) { + sbp.cursor = sbp.limit - v_2; + sbp.ket = sbp.cursor; + if (!r_mark_lAr()) + return; + sbp.bra = sbp.cursor; + sbp.slice_del(); + if (!r_stem_suffix_chain_before_ki()) + return; + } + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } + } + return; + } + sbp.cursor = sbp.limit - v_1; + if (habr9(v_1)) + return; + sbp.cursor = sbp.limit - v_1; + if (habr10(v_1)) + return; + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + if (r_mark_DAn()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + v_3 = sbp.limit - sbp.cursor; + if (r_mark_possessives()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } + } else { + sbp.cursor = sbp.limit - v_3; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } else { + sbp.cursor = sbp.limit - v_3; + r_stem_suffix_chain_before_ki(); + } + } + return; + } + sbp.cursor = sbp.limit - v_1; + if (habr11()) + return; + sbp.cursor = sbp.limit - v_1; + if (r_mark_lArI()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + return; + } + sbp.cursor = sbp.limit - v_1; + if (r_stem_suffix_chain_before_ki()) + return; + sbp.cursor = sbp.limit - v_1; + if (habr12()) + return; + sbp.cursor = sbp.limit - v_1; + sbp.ket = sbp.cursor; + if (!r_mark_possessives()) { + sbp.cursor = sbp.limit - v_1; + if (!r_mark_sU()) + return; + } + sbp.bra = sbp.cursor; + sbp.slice_del(); + sbp.ket = sbp.cursor; + if (r_mark_lAr()) { + sbp.bra = sbp.cursor; + sbp.slice_del(); + r_stem_suffix_chain_before_ki(); + } + } + + function r_post_process_last_consonants() { + var among_var; + sbp.ket = sbp.cursor; + among_var = sbp.find_among_b(a_23, 4); + if (among_var) { + sbp.bra = sbp.cursor; + switch (among_var) { + case 1: + sbp.slice_from("p"); + break; + case 2: + sbp.slice_from("\u00E7"); + break; + case 3: + sbp.slice_from("t"); + break; + case 4: + sbp.slice_from("k"); + break; + } + } + } + + function habr13() { + while (true) { + var v_1 = sbp.limit - sbp.cursor; + if (sbp.in_grouping_b(g_vowel, 97, 305)) { + sbp.cursor = sbp.limit - v_1; + break; + } + sbp.cursor = sbp.limit - v_1; + if (sbp.cursor <= sbp.limit_backward) + return false; + sbp.cursor--; + } + return true; + } + + function habr14(v_1, c1, c2) { + sbp.cursor = sbp.limit - v_1; + if (habr13()) { + var v_2 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, c1)) { + sbp.cursor = sbp.limit - v_2; + if (!sbp.eq_s_b(1, c2)) + return true; + } + sbp.cursor = sbp.limit - v_1; + var c = sbp.cursor; + sbp.insert(sbp.cursor, sbp.cursor, c2); + sbp.cursor = c; + return false; + } + return true; + } + + function r_append_U_to_stems_ending_with_d_or_g() { + var v_1 = sbp.limit - sbp.cursor; + if (!sbp.eq_s_b(1, "d")) { + sbp.cursor = sbp.limit - v_1; + if (!sbp.eq_s_b(1, "g")) + return; + } + if (habr14(v_1, "a", "\u0131")) + if (habr14(v_1, "e", "i")) + if (habr14(v_1, "o", "u")) + habr14(v_1, "\u00F6", "\u00FC") + } + + function r_more_than_one_syllable_word() { + var v_1 = sbp.cursor, + v_2 = 2, + v_3; + while (true) { + v_3 = sbp.cursor; + while (!sbp.in_grouping(g_vowel, 97, 305)) { + if (sbp.cursor >= sbp.limit) { + sbp.cursor = v_3; + if (v_2 > 0) + return false; + sbp.cursor = v_1; + return true; + } + sbp.cursor++; + } + v_2--; + } + } + + function habr15(v_1, n1, c1) { + while (!sbp.eq_s(n1, c1)) { + if (sbp.cursor >= sbp.limit) + return true; + sbp.cursor++; + } + I_strlen = n1; + if (I_strlen != sbp.limit) + return true; + sbp.cursor = v_1; + return false; + } + + function r_is_reserved_word() { + var v_1 = sbp.cursor; + if (habr15(v_1, 2, "ad")) { + sbp.cursor = v_1; + if (habr15(v_1, 5, "soyad")) + return false; + } + return true; + } + + function r_postlude() { + var v_1 = sbp.cursor; + if (r_is_reserved_word()) + return false; + sbp.limit_backward = v_1; + sbp.cursor = sbp.limit; + r_append_U_to_stems_ending_with_d_or_g(); + sbp.cursor = sbp.limit; + r_post_process_last_consonants(); + return true; + } + this.stem = function() { + if (r_more_than_one_syllable_word()) { + sbp.limit_backward = sbp.cursor; + sbp.cursor = sbp.limit; + r_stem_nominal_verb_suffixes(); + sbp.cursor = sbp.limit; + if (B_c_s_n_s) { + r_stem_noun_suffixes(); + sbp.cursor = sbp.limit_backward; + if (r_postlude()) + return true; + } + } + return false; + } + }; + + /* and return a function that stems a word for the current locale */ + return function(word) { + st.setCurrent(word); + st.stem(); + return st.getCurrent(); + } + })(); + + lunr.Pipeline.registerFunction(lunr.tr.stemmer, 'stemmer-tr'); + + /* stop word filter function */ + lunr.tr.stopWordFilter = function(token) { + if (lunr.tr.stopWordFilter.stopWords.indexOf(token) === -1) { + return token; + } + }; + + lunr.tr.stopWordFilter.stopWords = new lunr.SortedSet(); + lunr.tr.stopWordFilter.stopWords.length = 210; + + // The space at the beginning is crucial: It marks the empty string + // as a stop word. lunr.js crashes during search when documents + // processed by the pipeline still contain the empty string. + lunr.tr.stopWordFilter.stopWords.elements = ' acaba altmış altı ama ancak arada aslında ayrıca bana bazı belki ben benden beni benim beri beş bile bin bir biri birkaç birkez birçok birşey birşeyi biz bizden bize bizi bizim bu buna bunda bundan bunlar bunları bunların bunu bunun burada böyle böylece da daha dahi de defa değil diye diğer doksan dokuz dolayı dolayısıyla dört edecek eden ederek edilecek ediliyor edilmesi ediyor elli en etmesi etti ettiği ettiğini eğer gibi göre halen hangi hatta hem henüz hep hepsi her herhangi herkesin hiç hiçbir iki ile ilgili ise itibaren itibariyle için işte kadar karşın katrilyon kendi kendilerine kendini kendisi kendisine kendisini kez ki kim kimden kime kimi kimse kırk milyar milyon mu mü mı nasıl ne neden nedenle nerde nerede nereye niye niçin o olan olarak oldu olduklarını olduğu olduğunu olmadı olmadığı olmak olması olmayan olmaz olsa olsun olup olur olursa oluyor on ona ondan onlar onlardan onları onların onu onun otuz oysa pek rağmen sadece sanki sekiz seksen sen senden seni senin siz sizden sizi sizin tarafından trilyon tüm var vardı ve veya ya yani yapacak yapmak yaptı yaptıkları yaptığı yaptığını yapılan yapılması yapıyor yedi yerine yetmiş yine yirmi yoksa yüz zaten çok çünkü öyle üzere üç şey şeyden şeyi şeyler şu şuna şunda şundan şunları şunu şöyle'.split(' '); + + lunr.Pipeline.registerFunction(lunr.tr.stopWordFilter, 'stopWordFilter-tr'); + }; +})) diff --git a/static/js/lunr/lunr.tr.min.js b/static/js/lunr/lunr.tr.min.js new file mode 100644 index 0000000..c2d8fb6 --- /dev/null +++ b/static/js/lunr/lunr.tr.min.js @@ -0,0 +1 @@ +!function(r,i){"function"==typeof define&&define.amd?define(i):"object"==typeof exports?module.exports=i():i()(r.lunr)}(this,(function(){return function(r){if(void 0===r)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===r.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var i,e,n;r.tr=function(){this.pipeline.reset(),this.pipeline.add(r.tr.trimmer,r.tr.stopWordFilter,r.tr.stemmer)},r.tr.wordCharacters="A-Za-zªºÀ-ÖØ-öø-ʸˠ-ˤᴀ-ᴥᴬ-ᵜᵢ-ᵥᵫ-ᵷᵹ-ᶾḀ-ỿⁱⁿₐ-ₜKÅℲⅎⅠ-ↈⱠ-ⱿꜢ-ꞇꞋ-ꞭꞰ-ꞷꟷ-ꟿꬰ-ꭚꭜ-ꭤff-stA-Za-z",r.tr.trimmer=r.trimmerSupport.generateTrimmer(r.tr.wordCharacters),r.Pipeline.registerFunction(r.tr.trimmer,"trimmer-tr"),r.tr.stemmer=(i=r.stemmerSupport.Among,e=r.stemmerSupport.SnowballProgram,n=new function(){var r,n=[new i("m",-1,-1),new i("n",-1,-1),new i("miz",-1,-1),new i("niz",-1,-1),new i("muz",-1,-1),new i("nuz",-1,-1),new i("müz",-1,-1),new i("nüz",-1,-1),new i("mız",-1,-1),new i("nız",-1,-1)],t=[new i("leri",-1,-1),new i("ları",-1,-1)],u=[new i("ni",-1,-1),new i("nu",-1,-1),new i("nü",-1,-1),new i("nı",-1,-1)],o=[new i("in",-1,-1),new i("un",-1,-1),new i("ün",-1,-1),new i("ın",-1,-1)],s=[new i("a",-1,-1),new i("e",-1,-1)],c=[new i("na",-1,-1),new i("ne",-1,-1)],l=[new i("da",-1,-1),new i("ta",-1,-1),new i("de",-1,-1),new i("te",-1,-1)],m=[new i("nda",-1,-1),new i("nde",-1,-1)],a=[new i("dan",-1,-1),new i("tan",-1,-1),new i("den",-1,-1),new i("ten",-1,-1)],d=[new i("ndan",-1,-1),new i("nden",-1,-1)],b=[new i("la",-1,-1),new i("le",-1,-1)],w=[new i("ca",-1,-1),new i("ce",-1,-1)],f=[new i("im",-1,-1),new i("um",-1,-1),new i("üm",-1,-1),new i("ım",-1,-1)],_=[new i("sin",-1,-1),new i("sun",-1,-1),new i("sün",-1,-1),new i("sın",-1,-1)],k=[new i("iz",-1,-1),new i("uz",-1,-1),new i("üz",-1,-1),new i("ız",-1,-1)],p=[new i("siniz",-1,-1),new i("sunuz",-1,-1),new i("sünüz",-1,-1),new i("sınız",-1,-1)],g=[new i("lar",-1,-1),new i("ler",-1,-1)],y=[new i("niz",-1,-1),new i("nuz",-1,-1),new i("nüz",-1,-1),new i("nız",-1,-1)],z=[new i("dir",-1,-1),new i("tir",-1,-1),new i("dur",-1,-1),new i("tur",-1,-1),new i("dür",-1,-1),new i("tür",-1,-1),new i("dır",-1,-1),new i("tır",-1,-1)],h=[new i("casına",-1,-1),new i("cesine",-1,-1)],v=[new i("di",-1,-1),new i("ti",-1,-1),new i("dik",-1,-1),new i("tik",-1,-1),new i("duk",-1,-1),new i("tuk",-1,-1),new i("dük",-1,-1),new i("tük",-1,-1),new i("dık",-1,-1),new i("tık",-1,-1),new i("dim",-1,-1),new i("tim",-1,-1),new i("dum",-1,-1),new i("tum",-1,-1),new i("düm",-1,-1),new i("tüm",-1,-1),new i("dım",-1,-1),new i("tım",-1,-1),new i("din",-1,-1),new i("tin",-1,-1),new i("dun",-1,-1),new i("tun",-1,-1),new i("dün",-1,-1),new i("tün",-1,-1),new i("dın",-1,-1),new i("tın",-1,-1),new i("du",-1,-1),new i("tu",-1,-1),new i("dü",-1,-1),new i("tü",-1,-1),new i("dı",-1,-1),new i("tı",-1,-1)],q=[new i("sa",-1,-1),new i("se",-1,-1),new i("sak",-1,-1),new i("sek",-1,-1),new i("sam",-1,-1),new i("sem",-1,-1),new i("san",-1,-1),new i("sen",-1,-1)],W=[new i("miş",-1,-1),new i("muş",-1,-1),new i("müş",-1,-1),new i("mış",-1,-1)],F=[new i("b",-1,1),new i("c",-1,2),new i("d",-1,3),new i("ğ",-1,4)],C=[17,65,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,8,0,0,0,0,0,0,1],S=[1,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,1],P=[65],L=[65],x=[["a",[1,64,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],97,305],["e",[17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130],101,252],["ı",[1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1],97,305],["i",[17],101,105],["o",P,111,117],["ö",L,246,252],["u",P,111,117]],A=new e;function E(r,i,e){for(;;){var n=A.limit-A.cursor;if(A.in_grouping_b(r,i,e)){A.cursor=A.limit-n;break}if(A.cursor=A.limit-n,A.cursor<=A.limit_backward)return;A.cursor--}return 1}function j(){var r=A.limit-A.cursor;E(C,97,305);for(var i=0;iA.limit_backward)&&(A.cursor--,e=A.limit-A.cursor,i()))A.cursor=A.limit-e;else{if(A.cursor=A.limit-n,r())return A.cursor=A.limit-n,!1;if(A.cursor=A.limit-n,A.cursor<=A.limit_backward)return!1;if(A.cursor--,!i())return!1;A.cursor=A.limit-n}return!0}function T(r){return O(r,(function(){return A.in_grouping_b(C,97,305)}))}function Z(){return T((function(){return A.eq_s_b(1,"n")}))}function B(){return T((function(){return A.eq_s_b(1,"y")}))}function D(){return A.find_among_b(n,10)&&O((function(){return A.in_grouping_b(S,105,305)}),(function(){return A.out_grouping_b(C,97,305)}))}function G(){return j()&&A.in_grouping_b(S,105,305)&&T((function(){return A.eq_s_b(1,"s")}))}function H(){return A.find_among_b(t,2)}function I(){return j()&&A.find_among_b(o,4)&&Z()}function J(){return j()&&A.find_among_b(l,4)}function K(){return j()&&A.find_among_b(m,2)}function M(){return j()&&A.find_among_b(f,4)&&B()}function N(){return j()&&A.find_among_b(_,4)}function Q(){return j()&&A.find_among_b(k,4)&&B()}function R(){return A.find_among_b(p,4)}function U(){return j()&&A.find_among_b(g,2)}function V(){return j()&&A.find_among_b(z,8)}function X(){return j()&&A.find_among_b(v,32)&&B()}function Y(){return A.find_among_b(q,8)&&B()}function $(){return j()&&A.find_among_b(W,4)&&B()}function rr(){var r,i;if(A.ket=A.cursor,A.eq_s_b(2,"ki")){if(r=A.limit-A.cursor,J())return A.bra=A.cursor,A.slice_del(),i=A.limit-A.cursor,A.ket=A.cursor,(U()||(A.cursor=A.limit-i,D()&&(A.bra=A.cursor,A.slice_del(),A.ket=A.cursor,U())))&&(A.bra=A.cursor,A.slice_del(),rr()),1;if(A.cursor=A.limit-r,I()){if(A.bra=A.cursor,A.slice_del(),A.ket=A.cursor,i=A.limit-A.cursor,H())A.bra=A.cursor,A.slice_del();else{if(A.cursor=A.limit-i,A.ket=A.cursor,!D()&&(A.cursor=A.limit-i,!G())&&(A.cursor=A.limit-i,!rr()))return 1;A.bra=A.cursor,A.slice_del(),A.ket=A.cursor,U()&&(A.bra=A.cursor,A.slice_del(),rr())}return 1}if(A.cursor=A.limit-r,K()){if(i=A.limit-A.cursor,H())A.bra=A.cursor,A.slice_del();else if(A.cursor=A.limit-i,G())A.bra=A.cursor,A.slice_del(),A.ket=A.cursor,U()&&(A.bra=A.cursor,A.slice_del(),rr());else if(A.cursor=A.limit-i,!rr())return;return 1}}}function ir(r,i,e){var n;return A.cursor=A.limit-r,!function(){for(;;){var r=A.limit-A.cursor;if(A.in_grouping_b(C,97,305)){A.cursor=A.limit-r;break}if(A.cursor=A.limit-r,A.cursor<=A.limit_backward)return;A.cursor--}return 1}()||(n=A.limit-A.cursor,!A.eq_s_b(1,i)&&(A.cursor=A.limit-n,!A.eq_s_b(1,e)))||(A.cursor=A.limit-r,i=A.cursor,A.insert(A.cursor,A.cursor,e),void(A.cursor=i))}function er(r,i,e){for(;!A.eq_s(i,e);){if(A.cursor>=A.limit)return 1;A.cursor++}if(i!=A.limit)return 1;A.cursor=r}this.setCurrent=function(r){A.setCurrent(r)},this.getCurrent=function(){return A.getCurrent()},this.stem=function(){return!!(function(){for(var r,i=A.cursor,e=2;;){for(r=A.cursor;!A.in_grouping(C,97,305);){if(A.cursor>=A.limit)return A.cursor=r,!(0 1.0.0 + this.tokenizerFn = lunr.zh.tokenizer; + } + } + }; + + lunr.zh.tokenizer = function(obj) { + if (!arguments.length || obj == null || obj == undefined) return [] + if (Array.isArray(obj)) return obj.map(function(t) { + return isLunr2 ? new lunr.Token(t.toLowerCase()) : t.toLowerCase() + }) + + nodejiebaDictJson && nodejieba.load(nodejiebaDictJson) + + var str = obj.toString().trim().toLowerCase(); + var tokens = []; + + nodejieba.cut(str, true).forEach(function(seg) { + tokens = tokens.concat(seg.split(' ')) + }) + + tokens = tokens.filter(function(token) { + return !!token; + }); + + var fromIndex = 0 + + return tokens.map(function(token, index) { + if (isLunr2) { + var start = str.indexOf(token, fromIndex) + + var tokenMetadata = {} + tokenMetadata["position"] = [start, token.length] + tokenMetadata["index"] = index + + fromIndex = start + + return new lunr.Token(token, tokenMetadata); + } else { + return token + } + }); + } + + /* lunr trimmer function */ + lunr.zh.wordCharacters = "\\w\u4e00-\u9fa5"; + lunr.zh.trimmer = lunr.trimmerSupport.generateTrimmer(lunr.zh.wordCharacters); + lunr.Pipeline.registerFunction(lunr.zh.trimmer, 'trimmer-zh'); + + /* lunr stemmer function */ + lunr.zh.stemmer = (function() { + + /* TODO Chinese stemmer */ + return function(word) { + return word; + } + })(); + lunr.Pipeline.registerFunction(lunr.zh.stemmer, 'stemmer-zh'); + + /* lunr stop word filter. see https://www.ranks.nl/stopwords/chinese-stopwords */ + lunr.generateStopWordFilter = function (stopWords) { + var words = stopWords.reduce(function (memo, stopWord) { + memo[stopWord] = stopWord; + return memo; + }, {}); + + return function (token) { + if (token && words[token.toString()] !== token.toString()) return token; + }; + } + + lunr.zh.stopWordFilter = lunr.generateStopWordFilter( + '的 一 不 在 人 有 是 为 以 于 上 他 而 后 之 来 及 了 因 下 可 到 由 这 与 也 此 但 并 个 其 已 无 小 我 们 起 最 再 今 去 好 只 又 或 很 亦 某 把 那 你 乃 它 吧 被 比 别 趁 当 从 到 得 打 凡 儿 尔 该 各 给 跟 和 何 还 即 几 既 看 据 距 靠 啦 了 另 么 每 们 嘛 拿 哪 那 您 凭 且 却 让 仍 啥 如 若 使 谁 虽 随 同 所 她 哇 嗡 往 哪 些 向 沿 哟 用 于 咱 则 怎 曾 至 致 着 诸 自'.split(' ')); + lunr.Pipeline.registerFunction(lunr.zh.stopWordFilter, 'stopWordFilter-zh'); + }; +})) diff --git a/static/js/lunr/lunr.zh.min.js b/static/js/lunr/lunr.zh.min.js new file mode 100644 index 0000000..387e69a --- /dev/null +++ b/static/js/lunr/lunr.zh.min.js @@ -0,0 +1 @@ +!function(e,r){"function"==typeof define&&define.amd?define(r):"object"==typeof exports?module.exports=r(require("nodejieba")):r()(e.lunr)}(this,function(n){return function(u,t){if(void 0===u)throw new Error("Lunr is not present. Please include / require Lunr before this script.");if(void 0===u.stemmerSupport)throw new Error("Lunr stemmer support is not present. Please include / require Lunr stemmer support before this script.");var s="2"==u.version[0];u.zh=function(){this.pipeline.reset(),this.pipeline.add(u.zh.trimmer,u.zh.stopWordFilter,u.zh.stemmer),s?this.tokenizer=u.zh.tokenizer:(u.tokenizer&&(u.tokenizer=u.zh.tokenizer),this.tokenizerFn&&(this.tokenizerFn=u.zh.tokenizer))},u.zh.tokenizer=function(e){if(!arguments.length||null==e)return[];if(Array.isArray(e))return e.map(function(e){return s?new u.Token(e.toLowerCase()):e.toLowerCase()});t&&n.load(t);var i=e.toString().trim().toLowerCase(),r=[],o=(n.cut(i,!0).forEach(function(e){r=r.concat(e.split(" "))}),r=r.filter(function(e){return!!e}),0);return r.map(function(e,r){var t,n;return s?(t=i.indexOf(e,o),(n={}).position=[t,e.length],n.index=r,o=t,new u.Token(e,n)):e})},u.zh.wordCharacters="\\w一-龥",u.zh.trimmer=u.trimmerSupport.generateTrimmer(u.zh.wordCharacters),u.Pipeline.registerFunction(u.zh.trimmer,"trimmer-zh"),u.zh.stemmer=function(e){return e},u.Pipeline.registerFunction(u.zh.stemmer,"stemmer-zh"),u.generateStopWordFilter=function(e){var r=e.reduce(function(e,r){return e[r]=r,e},{});return function(e){if(e&&r[e.toString()]!==e.toString())return e}},u.zh.stopWordFilter=u.generateStopWordFilter("的 一 不 在 人 有 是 为 以 于 上 他 而 后 之 来 及 了 因 下 可 到 由 这 与 也 此 但 并 个 其 已 无 小 我 们 起 最 再 今 去 好 只 又 或 很 亦 某 把 那 你 乃 它 吧 被 比 别 趁 当 从 到 得 打 凡 儿 尔 该 各 给 跟 和 何 还 即 几 既 看 据 距 靠 啦 了 另 么 每 们 嘛 拿 哪 那 您 凭 且 却 让 仍 啥 如 若 使 谁 虽 随 同 所 她 哇 嗡 往 哪 些 向 沿 哟 用 于 咱 则 怎 曾 至 致 着 诸 自".split(" ")),u.Pipeline.registerFunction(u.zh.stopWordFilter,"stopWordFilter-zh")}}); diff --git a/static/js/lunr/lunrStemmerSupport.js b/static/js/lunr/lunrStemmerSupport.js new file mode 100755 index 0000000..32959fb --- /dev/null +++ b/static/js/lunr/lunrStemmerSupport.js @@ -0,0 +1,304 @@ +/*! + * Snowball JavaScript Library v0.3 + * http://code.google.com/p/urim/ + * http://snowball.tartarus.org/ + * + * Copyright 2010, Oleg Mazko + * http://www.mozilla.org/MPL/ + */ + +/** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ +; (function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory) + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like environments that support module.exports, + * like Node. + */ + module.exports = factory() + } else { + // Browser globals (root is window) + factory()(root.lunr); + } +}(this, function () { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return function (lunr) { + /* provides utilities for the included stemmers */ + lunr.stemmerSupport = { + Among: function (s, substring_i, result, method) { + this.toCharArray = function (s) { + var sLength = s.length, charArr = new Array(sLength); + for (var i = 0; i < sLength; i++) + charArr[i] = s.charCodeAt(i); + return charArr; + }; + + if ((!s && s != "") || (!substring_i && (substring_i != 0)) || !result) + throw ("Bad Among initialisation: s:" + s + ", substring_i: " + + substring_i + ", result: " + result); + this.s_size = s.length; + this.s = this.toCharArray(s); + this.substring_i = substring_i; + this.result = result; + this.method = method; + }, + SnowballProgram: function () { + var current; + return { + bra: 0, + ket: 0, + limit: 0, + cursor: 0, + limit_backward: 0, + setCurrent: function (word) { + current = word; + this.cursor = 0; + this.limit = word.length; + this.limit_backward = 0; + this.bra = this.cursor; + this.ket = this.limit; + }, + getCurrent: function () { + var result = current; + current = null; + return result; + }, + in_grouping: function (s, min, max) { + if (this.cursor < this.limit) { + var ch = current.charCodeAt(this.cursor); + if (ch <= max && ch >= min) { + ch -= min; + if (s[ch >> 3] & (0X1 << (ch & 0X7))) { + this.cursor++; + return true; + } + } + } + return false; + }, + in_grouping_b: function (s, min, max) { + if (this.cursor > this.limit_backward) { + var ch = current.charCodeAt(this.cursor - 1); + if (ch <= max && ch >= min) { + ch -= min; + if (s[ch >> 3] & (0X1 << (ch & 0X7))) { + this.cursor--; + return true; + } + } + } + return false; + }, + out_grouping: function (s, min, max) { + if (this.cursor < this.limit) { + var ch = current.charCodeAt(this.cursor); + if (ch > max || ch < min) { + this.cursor++; + return true; + } + ch -= min; + if (!(s[ch >> 3] & (0X1 << (ch & 0X7)))) { + this.cursor++; + return true; + } + } + return false; + }, + out_grouping_b: function (s, min, max) { + if (this.cursor > this.limit_backward) { + var ch = current.charCodeAt(this.cursor - 1); + if (ch > max || ch < min) { + this.cursor--; + return true; + } + ch -= min; + if (!(s[ch >> 3] & (0X1 << (ch & 0X7)))) { + this.cursor--; + return true; + } + } + return false; + }, + eq_s: function (s_size, s) { + if (this.limit - this.cursor < s_size) + return false; + for (var i = 0; i < s_size; i++) + if (current.charCodeAt(this.cursor + i) != s.charCodeAt(i)) + return false; + this.cursor += s_size; + return true; + }, + eq_s_b: function (s_size, s) { + if (this.cursor - this.limit_backward < s_size) + return false; + for (var i = 0; i < s_size; i++) + if (current.charCodeAt(this.cursor - s_size + i) != s + .charCodeAt(i)) + return false; + this.cursor -= s_size; + return true; + }, + find_among: function (v, v_size) { + var i = 0, j = v_size, c = this.cursor, l = this.limit, common_i = 0, common_j = 0, first_key_inspected = false; + while (true) { + var k = i + ((j - i) >> 1), diff = 0, common = common_i < common_j + ? common_i + : common_j, w = v[k]; + for (var i2 = common; i2 < w.s_size; i2++) { + if (c + common == l) { + diff = -1; + break; + } + diff = current.charCodeAt(c + common) - w.s[i2]; + if (diff) + break; + common++; + } + if (diff < 0) { + j = k; + common_j = common; + } else { + i = k; + common_i = common; + } + if (j - i <= 1) { + if (i > 0 || j == i || first_key_inspected) + break; + first_key_inspected = true; + } + } + while (true) { + var w = v[i]; + if (common_i >= w.s_size) { + this.cursor = c + w.s_size; + if (!w.method) + return w.result; + var res = w.method(); + this.cursor = c + w.s_size; + if (res) + return w.result; + } + i = w.substring_i; + if (i < 0) + return 0; + } + }, + find_among_b: function (v, v_size) { + var i = 0, j = v_size, c = this.cursor, lb = this.limit_backward, common_i = 0, common_j = 0, first_key_inspected = false; + while (true) { + var k = i + ((j - i) >> 1), diff = 0, common = common_i < common_j + ? common_i + : common_j, w = v[k]; + for (var i2 = w.s_size - 1 - common; i2 >= 0; i2--) { + if (c - common == lb) { + diff = -1; + break; + } + diff = current.charCodeAt(c - 1 - common) - w.s[i2]; + if (diff) + break; + common++; + } + if (diff < 0) { + j = k; + common_j = common; + } else { + i = k; + common_i = common; + } + if (j - i <= 1) { + if (i > 0 || j == i || first_key_inspected) + break; + first_key_inspected = true; + } + } + while (true) { + var w = v[i]; + if (common_i >= w.s_size) { + this.cursor = c - w.s_size; + if (!w.method) + return w.result; + var res = w.method(); + this.cursor = c - w.s_size; + if (res) + return w.result; + } + i = w.substring_i; + if (i < 0) + return 0; + } + }, + replace_s: function (c_bra, c_ket, s) { + var adjustment = s.length - (c_ket - c_bra), left = current + .substring(0, c_bra), right = current.substring(c_ket); + current = left + s + right; + this.limit += adjustment; + if (this.cursor >= c_ket) + this.cursor += adjustment; + else if (this.cursor > c_bra) + this.cursor = c_bra; + return adjustment; + }, + slice_check: function () { + if (this.bra < 0 || this.bra > this.ket || this.ket > this.limit + || this.limit > current.length) + throw ("faulty slice operation"); + }, + slice_from: function (s) { + this.slice_check(); + this.replace_s(this.bra, this.ket, s); + }, + slice_del: function () { + this.slice_from(""); + }, + insert: function (c_bra, c_ket, s) { + var adjustment = this.replace_s(c_bra, c_ket, s); + if (c_bra <= this.bra) + this.bra += adjustment; + if (c_bra <= this.ket) + this.ket += adjustment; + }, + slice_to: function () { + this.slice_check(); + return current.substring(this.bra, this.ket); + }, + eq_v_b: function (s) { + return this.eq_s_b(s.length, s); + } + }; + } + }; + + lunr.trimmerSupport = { + generateTrimmer: function (wordCharacters) { + var startRegex = new RegExp("^[^" + wordCharacters + "]+") + var endRegex = new RegExp("[^" + wordCharacters + "]+$") + + return function (token) { + // for lunr version 2 + if (typeof token.update === "function") { + return token.update(function (s) { + return s + .replace(startRegex, '') + .replace(endRegex, ''); + }) + } else { // for lunr version 1 + return token + .replace(startRegex, '') + .replace(endRegex, ''); + } + }; + } + } + } +})); diff --git a/static/js/lunr/lunrStemmerSupport.min.js b/static/js/lunr/lunrStemmerSupport.min.js new file mode 100755 index 0000000..3567a8c --- /dev/null +++ b/static/js/lunr/lunrStemmerSupport.min.js @@ -0,0 +1 @@ +!function(r,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():t()(r.lunr)}(this,function(){return function(r){r.stemmerSupport={Among:function(r,t,i,s){if(this.toCharArray=function(r){for(var t=r.length,i=new Array(t),s=0;s>3]&1<<(7&s))return this.cursor++,!0}return!1},in_grouping_b:function(r,t,i){if(this.cursor>this.limit_backward){var s=b.charCodeAt(this.cursor-1);if(s<=i&&t<=s&&r[(s-=t)>>3]&1<<(7&s))return this.cursor--,!0}return!1},out_grouping:function(r,t,i){if(this.cursor>3]&1<<(7&s)))return this.cursor++,!0}return!1},out_grouping_b:function(r,t,i){if(this.cursor>this.limit_backward){var s=b.charCodeAt(this.cursor-1);if(i>3]&1<<(7&s)))return this.cursor--,!0}return!1},eq_s:function(r,t){if(this.limit-this.cursor>1),f=0,a=u=(l=r[i]).s_size){if(this.cursor=e+l.s_size,!l.method)return l.result;var m=l.method();if(this.cursor=e+l.s_size,m)return l.result}if((i=l.substring_i)<0)return 0}},find_among_b:function(r,t){for(var i=0,s=t,e=this.cursor,n=this.limit_backward,u=0,o=0,h=!1;;){for(var c,f=i+(s-i>>1),a=0,l=u=(c=r[i]).s_size){if(this.cursor=e-c.s_size,!c.method)return c.result;var m=c.method();if(this.cursor=e-c.s_size,m)return c.result}if((i=c.substring_i)<0)return 0}},replace_s:function(r,t,i){var s=i.length-(t-r);return b=b.substring(0,r)+i+b.substring(t),this.limit+=s,this.cursor>=t?this.cursor+=s:this.cursor>r&&(this.cursor=r),s},slice_check:function(){if(this.bra<0||this.bra>this.ket||this.ket>this.limit||this.limit>b.length)throw"faulty slice operation"},slice_from:function(r){this.slice_check(),this.replace_s(this.bra,this.ket,r)},slice_del:function(){this.slice_from("")},insert:function(r,t,i){t=this.replace_s(r,t,i);r<=this.bra&&(this.bra+=t),r<=this.ket&&(this.ket+=t)},slice_to:function(){return this.slice_check(),b.substring(this.bra,this.ket)},eq_v_b:function(r){return this.eq_s_b(r.length,r)}}}},r.trimmerSupport={generateTrimmer:function(r){var t=new RegExp("^[^"+r+"]+"),i=new RegExp("[^"+r+"]+$");return function(r){return"function"==typeof r.update?r.update(function(r){return r.replace(t,"").replace(i,"")}):r.replace(t,"").replace(i,"")}}}}}); diff --git a/static/js/searchElasticlunr.js b/static/js/searchElasticlunr.js new file mode 100644 index 0000000..481cd39 --- /dev/null +++ b/static/js/searchElasticlunr.js @@ -0,0 +1,3118 @@ +/** + * elasticlunr - http://weixsong.github.io + * Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.5 + * + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + * MIT Licensed + * @license + */ +(function () { + /*! + * elasticlunr.js + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + */ + + /** + * Convenience function for instantiating a new elasticlunr index and configuring it + * with the default pipeline functions and the passed config function. + * + * When using this convenience function a new index will be created with the + * following functions already in the pipeline: + * + * 1. elasticlunr.trimmer - trim non-word character + * 2. elasticlunr.StopWordFilter - filters out any stop words before they enter the + * index + * 3. elasticlunr.stemmer - stems the tokens before entering the index. + * + * + * Example: + * + * var idx = elasticlunr(function () { + * this.addField('id'); + * this.addField('title'); + * this.addField('body'); + * + * //this.setRef('id'); // default ref is 'id' + * + * this.pipeline.add(function () { + * // some custom pipeline function + * }); + * }); + * + * idx.addDoc({ + * id: 1, + * title: 'Oracle released database 12g', + * body: 'Yestaday, Oracle has released their latest database, named 12g, more robust. this product will increase Oracle profit.' + * }); + * + * idx.addDoc({ + * id: 2, + * title: 'Oracle released annual profit report', + * body: 'Yestaday, Oracle has released their annual profit report of 2015, total profit is 12.5 Billion.' + * }); + * + * # simple search + * idx.search('oracle database'); + * + * # search with query-time boosting + * idx.search('oracle database', {fields: {title: {boost: 2}, body: {boost: 1}}}); + * + * @param {Function} config A function that will be called with the new instance + * of the elasticlunr.Index as both its context and first parameter. It can be used to + * customize the instance of new elasticlunr.Index. + * @namespace + * @module + * @return {elasticlunr.Index} + * + */ + const elasticlunr = function (config) { + const idx = new elasticlunr.Index(); + + idx.pipeline.add( + elasticlunr.trimmer, + elasticlunr.stopWordFilter, + elasticlunr.stemmer + ); + + if (config) config.call(idx, idx); + + return idx; + }; + + elasticlunr.version = '0.9.5'; + + // only used this to make elasticlunr.js compatible with lunr-languages + // this is a trick to define a global alias of elasticlunr + lunr = elasticlunr; + + /*! + * elasticlunr.utils + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + */ + + /** + * A namespace containing utils for the rest of the elasticlunr library + */ + elasticlunr.utils = {}; + + /** + * Print a warning message to the console. + * + * @param {String} message The message to be printed. + * @memberOf Utils + */ + elasticlunr.utils.warn = (function (global) { + return function (message) { + if (global.console && console.warn) { + console.warn(message); + } + }; + })(this); + + /** + * Convert an object to string. + * + * In the case of `null` and `undefined` the function returns + * an empty string, in all other cases the result of calling + * `toString` on the passed object is returned. + * + * @param {object} obj The object to convert to a string. + * @return {String} string representation of the passed object. + * @memberOf Utils + */ + elasticlunr.utils.toString = function (obj) { + if (obj === void 0 || obj === null) { + return ''; + } + + return obj.toString(); + }; + /*! + * elasticlunr.EventEmitter + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + */ + + /** + * elasticlunr.EventEmitter is an event emitter for elasticlunr. + * It manages adding and removing event handlers and triggering events and their handlers. + * + * Each event could has multiple corresponding functions, + * these functions will be called as the sequence that they are added into the event. + * + * @constructor + */ + elasticlunr.EventEmitter = function () { + this.events = {}; + }; + + /** + * Binds a handler function to a specific event(s). + * + * Can bind a single function to many different events in one call. + * + * @param {String} [eventName] The name(s) of events to bind this function to. + * @param {Function} fn The function to call when an event is fired. + * @memberOf EventEmitter + */ + elasticlunr.EventEmitter.prototype.addListener = function () { + const args = Array.prototype.slice.call(arguments); + const fn = args.pop(); + const names = args; + + if (typeof fn !== 'function') + throw new TypeError('last argument must be a function'); + + names.forEach(function (name) { + if (!this.hasHandler(name)) this.events[name] = []; + this.events[name].push(fn); + }, this); + }; + + /** + * Removes a handler function from a specific event. + * + * @param {String} eventName The name of the event to remove this function from. + * @param {Function} fn The function to remove from an event. + * @memberOf EventEmitter + */ + elasticlunr.EventEmitter.prototype.removeListener = function (name, fn) { + if (!this.hasHandler(name)) return; + + const fnIndex = this.events[name].indexOf(fn); + if (fnIndex === -1) return; + + this.events[name].splice(fnIndex, 1); + + if (this.events[name].length === 0) delete this.events[name]; + }; + + /** + * Call all functions that bounded to the given event. + * + * Additional data can be passed to the event handler as arguments to `emit` + * after the event name. + * + * @param {String} eventName The name of the event to emit. + * @memberOf EventEmitter + */ + elasticlunr.EventEmitter.prototype.emit = function (name) { + if (!this.hasHandler(name)) return; + + const args = Array.prototype.slice.call(arguments, 1); + + this.events[name].forEach(function (fn) { + fn.apply(undefined, args); + }, this); + }; + + /** + * Checks whether a handler has ever been stored against an event. + * + * @param {String} eventName The name of the event to check. + * @private + * @memberOf EventEmitter + */ + elasticlunr.EventEmitter.prototype.hasHandler = function (name) { + return name in this.events; + }; + /*! + * elasticlunr.tokenizer + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + */ + + /** + * A function for splitting a string into tokens. + * Currently English is supported as default. + * Uses `elasticlunr.tokenizer.seperator` to split strings, you could change + * the value of this property to set how you want strings are split into tokens. + * IMPORTANT: use elasticlunr.tokenizer.seperator carefully, if you are not familiar with + * text process, then you'd better not change it. + * + * @module + * @param {String} str The string that you want to tokenize. + * @see elasticlunr.tokenizer.seperator + * @return {Array} + */ + elasticlunr.tokenizer = function (str) { + if (!arguments.length || str === null || str === undefined) return []; + if (Array.isArray(str)) { + let arr = str.filter(function (token) { + if (token === null || token === undefined) { + return false; + } + + return true; + }); + + arr = arr.map(function (t) { + return elasticlunr.utils.toString(t).toLowerCase(); + }); + + let out = []; + arr.forEach(function (item) { + const tokens = item.split(elasticlunr.tokenizer.seperator); + out = out.concat(tokens); + }, this); + + return out; + } + + return str + .toString() + .trim() + .toLowerCase() + .split(elasticlunr.tokenizer.seperator); + }; + + /** + * Default string seperator. + */ + elasticlunr.tokenizer.defaultSeperator = /[\s-]+/; + + /** + * The sperator used to split a string into tokens. Override this property to change the behaviour of + * `elasticlunr.tokenizer` behaviour when tokenizing strings. By default this splits on whitespace and hyphens. + * + * @static + * @see elasticlunr.tokenizer + */ + elasticlunr.tokenizer.seperator = elasticlunr.tokenizer.defaultSeperator; + + /** + * Set up customized string seperator + * + * @param {Object} sep The customized seperator that you want to use to tokenize a string. + */ + elasticlunr.tokenizer.setSeperator = function (sep) { + if (sep !== null && sep !== undefined && typeof sep === 'object') { + elasticlunr.tokenizer.seperator = sep; + } + }; + + /** + * Reset string seperator + * + */ + elasticlunr.tokenizer.resetSeperator = function () { + elasticlunr.tokenizer.seperator = elasticlunr.tokenizer.defaultSeperator; + }; + + /** + * Get string seperator + * + */ + elasticlunr.tokenizer.getSeperator = function () { + return elasticlunr.tokenizer.seperator; + }; + /*! + * elasticlunr.Pipeline + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + */ + + /** + * elasticlunr.Pipelines maintain an ordered list of functions to be applied to + * both documents tokens and query tokens. + * + * An instance of elasticlunr.Index will contain a pipeline + * with a trimmer, a stop word filter, an English stemmer. Extra + * functions can be added before or after either of these functions or these + * default functions can be removed. + * + * When run the pipeline, it will call each function in turn. + * + * The output of the functions in the pipeline will be passed to the next function + * in the pipeline. To exclude a token from entering the index the function + * should return undefined, the rest of the pipeline will not be called with + * this token. + * + * For serialisation of pipelines to work, all functions used in an instance of + * a pipeline should be registered with elasticlunr.Pipeline. Registered functions can + * then be loaded. If trying to load a serialised pipeline that uses functions + * that are not registered an error will be thrown. + * + * If not planning on serialising the pipeline then registering pipeline functions + * is not necessary. + * + * @constructor + */ + elasticlunr.Pipeline = function () { + this._queue = []; + }; + + elasticlunr.Pipeline.registeredFunctions = {}; + + /** + * Register a function in the pipeline. + * + * Functions that are used in the pipeline should be registered if the pipeline + * needs to be serialised, or a serialised pipeline needs to be loaded. + * + * Registering a function does not add it to a pipeline, functions must still be + * added to instances of the pipeline for them to be used when running a pipeline. + * + * @param {Function} fn The function to register. + * @param {String} label The label to register this function with + * @memberOf Pipeline + */ + elasticlunr.Pipeline.registerFunction = function (fn, label) { + if (label in elasticlunr.Pipeline.registeredFunctions) { + elasticlunr.utils.warn( + 'Overwriting existing registered function: ' + label + ); + } + + fn.label = label; + elasticlunr.Pipeline.registeredFunctions[label] = fn; + }; + + /** + * Get a registered function in the pipeline. + * + * @param {String} label The label of registered function. + * @return {Function} + * @memberOf Pipeline + */ + elasticlunr.Pipeline.getRegisteredFunction = function (label) { + if (label in elasticlunr.Pipeline.registeredFunctions !== true) { + return null; + } + + return elasticlunr.Pipeline.registeredFunctions[label]; + }; + + /** + * Warns if the function is not registered as a Pipeline function. + * + * @param {Function} fn The function to check for. + * @private + * @memberOf Pipeline + */ + elasticlunr.Pipeline.warnIfFunctionNotRegistered = function (fn) { + const isRegistered = fn.label && fn.label in this.registeredFunctions; + + if (!isRegistered) { + elasticlunr.utils.warn( + 'Function is not registered with pipeline. This may cause problems when serialising the index.\n', + fn + ); + } + }; + + /** + * Loads a previously serialised pipeline. + * + * All functions to be loaded must already be registered with elasticlunr.Pipeline. + * If any function from the serialised data has not been registered then an + * error will be thrown. + * + * @param {Object} serialised The serialised pipeline to load. + * @return {elasticlunr.Pipeline} + * @memberOf Pipeline + */ + elasticlunr.Pipeline.load = function (serialised) { + const pipeline = new elasticlunr.Pipeline(); + + serialised.forEach(function (fnName) { + const fn = elasticlunr.Pipeline.getRegisteredFunction(fnName); + + if (fn) { + pipeline.add(fn); + } else { + throw new Error('Cannot load un-registered function: ' + fnName); + } + }); + + return pipeline; + }; + + /** + * Adds new functions to the end of the pipeline. + * + * Logs a warning if the function has not been registered. + * + * @param {Function} functions Any number of functions to add to the pipeline. + * @memberOf Pipeline + */ + elasticlunr.Pipeline.prototype.add = function () { + const fns = Array.prototype.slice.call(arguments); + + fns.forEach(function (fn) { + elasticlunr.Pipeline.warnIfFunctionNotRegistered(fn); + this._queue.push(fn); + }, this); + }; + + /** + * Adds a single function after a function that already exists in the + * pipeline. + * + * Logs a warning if the function has not been registered. + * If existingFn is not found, throw an Exception. + * + * @param {Function} existingFn A function that already exists in the pipeline. + * @param {Function} newFn The new function to add to the pipeline. + * @memberOf Pipeline + */ + elasticlunr.Pipeline.prototype.after = function (existingFn, newFn) { + elasticlunr.Pipeline.warnIfFunctionNotRegistered(newFn); + + const pos = this._queue.indexOf(existingFn); + if (pos === -1) { + throw new Error('Cannot find existingFn'); + } + + this._queue.splice(pos + 1, 0, newFn); + }; + + /** + * Adds a single function before a function that already exists in the + * pipeline. + * + * Logs a warning if the function has not been registered. + * If existingFn is not found, throw an Exception. + * + * @param {Function} existingFn A function that already exists in the pipeline. + * @param {Function} newFn The new function to add to the pipeline. + * @memberOf Pipeline + */ + elasticlunr.Pipeline.prototype.before = function (existingFn, newFn) { + elasticlunr.Pipeline.warnIfFunctionNotRegistered(newFn); + + const pos = this._queue.indexOf(existingFn); + if (pos === -1) { + throw new Error('Cannot find existingFn'); + } + + this._queue.splice(pos, 0, newFn); + }; + + /** + * Removes a function from the pipeline. + * + * @param {Function} fn The function to remove from the pipeline. + * @memberOf Pipeline + */ + elasticlunr.Pipeline.prototype.remove = function (fn) { + const pos = this._queue.indexOf(fn); + if (pos === -1) { + return; + } + + this._queue.splice(pos, 1); + }; + + /** + * Runs the current list of functions that registered in the pipeline against the + * input tokens. + * + * @param {Array} tokens The tokens to run through the pipeline. + * @return {Array} + * @memberOf Pipeline + */ + elasticlunr.Pipeline.prototype.run = function (tokens) { + const out = []; + const tokenLength = tokens.length; + const pipelineLength = this._queue.length; + + for (let i = 0; i < tokenLength; i++) { + let token = tokens[i]; + + for (let j = 0; j < pipelineLength; j++) { + token = this._queue[j](token, i, tokens); + if (token === void 0 || token === null) break; + } + + if (token !== void 0 && token !== null) out.push(token); + } + + return out; + }; + + /** + * Resets the pipeline by removing any existing processors. + * + * @memberOf Pipeline + */ + elasticlunr.Pipeline.prototype.reset = function () { + this._queue = []; + }; + + /** + * Get the pipeline if user want to check the pipeline. + * + * @memberOf Pipeline + */ + elasticlunr.Pipeline.prototype.get = function () { + return this._queue; + }; + + /** + * Returns a representation of the pipeline ready for serialisation. + * Only serialize pipeline function's name. Not storing function, so when + * loading the archived JSON index file, corresponding pipeline function is + * added by registered function of elasticlunr.Pipeline.registeredFunctions + * + * Logs a warning if the function has not been registered. + * + * @return {Array} + * @memberOf Pipeline + */ + elasticlunr.Pipeline.prototype.toJSON = function () { + return this._queue.map(function (fn) { + elasticlunr.Pipeline.warnIfFunctionNotRegistered(fn); + return fn.label; + }); + }; + /*! + * elasticlunr.Index + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + */ + + /** + * elasticlunr.Index is object that manages a search index. It contains the indexes + * and stores all the tokens and document lookups. It also provides the main + * user facing API for the library. + * + * @constructor + */ + elasticlunr.Index = function () { + this._fields = []; + this._ref = 'id'; + this.pipeline = new elasticlunr.Pipeline(); + this.documentStore = new elasticlunr.DocumentStore(); + this.index = {}; + this.eventEmitter = new elasticlunr.EventEmitter(); + this._idfCache = {}; + + this.on( + 'add', + 'remove', + 'update', + function () { + this._idfCache = {}; + }.bind(this) + ); + }; + + /** + * Bind a handler to events being emitted by the index. + * + * The handler can be bound to many events at the same time. + * + * @param {String} [eventName] The name(s) of events to bind the function to. + * @param {Function} fn The serialised set to load. + * @memberOf Index + */ + elasticlunr.Index.prototype.on = function () { + const args = Array.prototype.slice.call(arguments); + return this.eventEmitter.addListener.apply(this.eventEmitter, args); + }; + + /** + * Removes a handler from an event being emitted by the index. + * + * @param {String} eventName The name of events to remove the function from. + * @param {Function} fn The serialised set to load. + * @memberOf Index + */ + elasticlunr.Index.prototype.off = function (name, fn) { + return this.eventEmitter.removeListener(name, fn); + }; + + /** + * Loads a previously serialised index. + * + * Issues a warning if the index being imported was serialised + * by a different version of elasticlunr. + * + * @param {Object} serialisedData The serialised set to load. + * @return {elasticlunr.Index} + * @memberOf Index + */ + elasticlunr.Index.load = function (serialisedData) { + if (serialisedData.version !== elasticlunr.version) { + elasticlunr.utils.warn( + 'version mismatch: current ' + + elasticlunr.version + + ' importing ' + + serialisedData.version + ); + } + + const idx = new this(); + + idx._fields = serialisedData.fields; + idx._ref = serialisedData.ref; + idx.documentStore = elasticlunr.DocumentStore.load( + serialisedData.documentStore + ); + idx.pipeline = elasticlunr.Pipeline.load(serialisedData.pipeline); + idx.index = {}; + for (const field in serialisedData.index) { + idx.index[field] = elasticlunr.InvertedIndex.load( + serialisedData.index[field] + ); + } + + return idx; + }; + + /** + * Adds a field to the list of fields that will be searchable within documents in the index. + * + * Remember that inner index is build based on field, which means each field has one inverted index. + * + * Fields should be added before any documents are added to the index, fields + * that are added after documents are added to the index will only apply to new + * documents added to the index. + * + * @param {String} fieldName The name of the field within the document that should be indexed + * @return {elasticlunr.Index} + * @memberOf Index + */ + elasticlunr.Index.prototype.addField = function (fieldName) { + this._fields.push(fieldName); + this.index[fieldName] = new elasticlunr.InvertedIndex(); + return this; + }; + + /** + * Sets the property used to uniquely identify documents added to the index, + * by default this property is 'id'. + * + * This should only be changed before adding documents to the index, changing + * the ref property without resetting the index can lead to unexpected results. + * + * @param {String} refName The property to use to uniquely identify the + * documents in the index. + * @param {Boolean} emitEvent Whether to emit add events, defaults to true + * @return {elasticlunr.Index} + * @memberOf Index + */ + elasticlunr.Index.prototype.setRef = function (refName) { + this._ref = refName; + return this; + }; + + /** + * + * Set if the JSON format original documents are save into elasticlunr.DocumentStore + * + * Defaultly save all the original JSON documents. + * + * @param {Boolean} save Whether to save the original JSON documents. + * @return {elasticlunr.Index} + * @memberOf Index + */ + elasticlunr.Index.prototype.saveDocument = function (save) { + this.documentStore = new elasticlunr.DocumentStore(save); + return this; + }; + + /** + * Add a JSON format document to the index. + * + * This is the way new documents enter the index, this function will run the + * fields from the document through the index's pipeline and then add it to + * the index, it will then show up in search results. + * + * An 'add' event is emitted with the document that has been added and the index + * the document has been added to. This event can be silenced by passing false + * as the second argument to add. + * + * @param {Object} doc The JSON format document to add to the index. + * @param {Boolean} emitEvent Whether or not to emit events, default true. + * @memberOf Index + */ + elasticlunr.Index.prototype.addDoc = function (doc, emitEvent) { + if (!doc) return; + var emitEvent = emitEvent === undefined ? true : emitEvent; + + const docRef = doc[this._ref]; + + this.documentStore.addDoc(docRef, doc); + this._fields.forEach(function (field) { + const fieldTokens = this.pipeline.run(elasticlunr.tokenizer(doc[field])); + this.documentStore.addFieldLength(docRef, field, fieldTokens.length); + + const tokenCount = {}; + fieldTokens.forEach(function (token) { + if (token in tokenCount) tokenCount[token] += 1; + else tokenCount[token] = 1; + }, this); + + for (const token in tokenCount) { + let termFrequency = tokenCount[token]; + termFrequency = Math.sqrt(termFrequency); + this.index[field].addToken(token, { ref: docRef, tf: termFrequency }); + } + }, this); + + if (emitEvent) this.eventEmitter.emit('add', doc, this); + }; + + /** + * Removes a document from the index by doc ref. + * + * To make sure documents no longer show up in search results they can be + * removed from the index using this method. + * + * A 'remove' event is emitted with the document that has been removed and the index + * the document has been removed from. This event can be silenced by passing false + * as the second argument to remove. + * + * If user setting DocumentStore not storing the documents, then remove doc by docRef is not allowed. + * + * @param {String|Integer} docRef The document ref to remove from the index. + * @param {Boolean} emitEvent Whether to emit remove events, defaults to true + * @memberOf Index + */ + elasticlunr.Index.prototype.removeDocByRef = function (docRef, emitEvent) { + if (!docRef) return; + if (this.documentStore.isDocStored() === false) { + return; + } + + if (!this.documentStore.hasDoc(docRef)) return; + const doc = this.documentStore.getDoc(docRef); + this.removeDoc(doc, false); + }; + + /** + * Removes a document from the index. + * This remove operation could work even the original doc is not store in the DocumentStore. + * + * To make sure documents no longer show up in search results they can be + * removed from the index using this method. + * + * A 'remove' event is emitted with the document that has been removed and the index + * the document has been removed from. This event can be silenced by passing false + * as the second argument to remove. + * + * + * @param {Object} doc The document ref to remove from the index. + * @param {Boolean} emitEvent Whether to emit remove events, defaults to true + * @memberOf Index + */ + elasticlunr.Index.prototype.removeDoc = function (doc, emitEvent) { + if (!doc) return; + + var emitEvent = emitEvent === undefined ? true : emitEvent; + + const docRef = doc[this._ref]; + if (!this.documentStore.hasDoc(docRef)) return; + + this.documentStore.removeDoc(docRef); + + this._fields.forEach(function (field) { + const fieldTokens = this.pipeline.run(elasticlunr.tokenizer(doc[field])); + fieldTokens.forEach(function (token) { + this.index[field].removeToken(token, docRef); + }, this); + }, this); + + if (emitEvent) this.eventEmitter.emit('remove', doc, this); + }; + + /** + * Updates a document in the index. + * + * When a document contained within the index gets updated, fields changed, + * added or removed, to make sure it correctly matched against search queries, + * it should be updated in the index. + * + * This method is just a wrapper around `remove` and `add` + * + * An 'update' event is emitted with the document that has been updated and the index. + * This event can be silenced by passing false as the second argument to update. Only + * an update event will be fired, the 'add' and 'remove' events of the underlying calls + * are silenced. + * + * @param {Object} doc The document to update in the index. + * @param {Boolean} emitEvent Whether to emit update events, defaults to true + * @see Index.prototype.remove + * @see Index.prototype.add + * @memberOf Index + */ + elasticlunr.Index.prototype.updateDoc = function (doc, emitEvent) { + var emitEvent = emitEvent === undefined ? true : emitEvent; + + this.removeDocByRef(doc[this._ref], false); + this.addDoc(doc, false); + + if (emitEvent) this.eventEmitter.emit('update', doc, this); + }; + + /** + * Calculates the inverse document frequency for a token within the index of a field. + * + * @param {String} token The token to calculate the idf of. + * @param {String} field The field to compute idf. + * @see Index.prototype.idf + * @private + * @memberOf Index + */ + elasticlunr.Index.prototype.idf = function (term, field) { + const cacheKey = '@' + field + '/' + term; + if (Object.prototype.hasOwnProperty.call(this._idfCache, cacheKey)) + return this._idfCache[cacheKey]; + + const df = this.index[field].getDocFreq(term); + const idf = 1 + Math.log(this.documentStore.length / (df + 1)); + this._idfCache[cacheKey] = idf; + + return idf; + }; + + /** + * get fields of current index instance + * + * @return {Array} + */ + elasticlunr.Index.prototype.getFields = function () { + return this._fields.slice(); + }; + + /** + * Searches the index using the passed query. + * Queries should be a string, multiple words are allowed. + * + * If config is null, will search all fields defaultly, and lead to OR based query. + * If config is specified, will search specified with query time boosting. + * + * All query tokens are passed through the same pipeline that document tokens + * are passed through, so any language processing involved will be run on every + * query term. + * + * Each query term is expanded, so that the term 'he' might be expanded to + * 'hello' and 'help' if those terms were already included in the index. + * + * Matching documents are returned as an array of objects, each object contains + * the matching document ref, as set for this index, and the similarity score + * for this document against the query. + * + * @param {String} query The query to search the index with. + * @param {JSON} userConfig The user query config, JSON format. + * @return {Object} + * @see Index.prototype.idf + * @see Index.prototype.documentVector + * @memberOf Index + */ + elasticlunr.Index.prototype.search = function (query, userConfig) { + if (!query) return []; + if (typeof query === 'string') { + query = { any: query }; + } else { + query = JSON.parse(JSON.stringify(query)); + } + + let configStr = null; + if (userConfig != null) { + configStr = JSON.stringify(userConfig); + } + + const config = new elasticlunr.Configuration(configStr, this.getFields()).get(); + + const queryTokens = {}; + const queryFields = Object.keys(query); + + for (let i = 0; i < queryFields.length; i++) { + const key = queryFields[i]; + + queryTokens[key] = this.pipeline.run(elasticlunr.tokenizer(query[key])); + } + + const queryResults = {}; + + for (const field in config) { + const tokens = queryTokens[field] || queryTokens.any; + if (!tokens) { + continue; + } + + const fieldSearchResults = this.fieldSearch(tokens, field, config); + const fieldBoost = config[field].boost; + + for (var docRef in fieldSearchResults) { + fieldSearchResults[docRef] = fieldSearchResults[docRef] * fieldBoost; + } + + for (var docRef in fieldSearchResults) { + if (docRef in queryResults) { + queryResults[docRef] += fieldSearchResults[docRef]; + } else { + queryResults[docRef] = fieldSearchResults[docRef]; + } + } + } + + const results = []; + let result; + for (var docRef in queryResults) { + result = { ref: docRef, score: queryResults[docRef] }; + if (this.documentStore.hasDoc(docRef)) { + result.doc = this.documentStore.getDoc(docRef); + } + results.push(result); + } + + results.sort(function (a, b) { + return b.score - a.score; + }); + return results; + }; + + /** + * search queryTokens in specified field. + * + * @param {Array} queryTokens The query tokens to query in this field. + * @param {String} field Field to query in. + * @param {elasticlunr.Configuration} config The user query config, JSON format. + * @return {Object} + */ + elasticlunr.Index.prototype.fieldSearch = function ( + queryTokens, + fieldName, + config + ) { + const booleanType = config[fieldName].bool; + const expand = config[fieldName].expand; + const boost = config[fieldName].boost; + let scores = null; + const docTokens = {}; + + // Do nothing if the boost is 0 + if (boost === 0) { + return; + } + + queryTokens.forEach(function (token) { + let tokens = [token]; + if (expand === true) { + tokens = this.index[fieldName].expandToken(token); + } + // Consider every query token in turn. If expanded, each query token + // corresponds to a set of tokens, which is all tokens in the + // index matching the pattern queryToken* . + // For the set of tokens corresponding to a query token, find and score + // all matching documents. Store those scores in queryTokenScores, + // keyed by docRef. + // Then, depending on the value of booleanType, combine the scores + // for this query token with previous scores. If booleanType is OR, + // then merge the scores by summing into the accumulated total, adding + // new document scores are required (effectively a union operator). + // If booleanType is AND, accumulate scores only if the document + // has previously been scored by another query token (an intersection + // operation0. + // Furthermore, since when booleanType is AND, additional + // query tokens can't add new documents to the result set, use the + // current document set to limit the processing of each new query + // token for efficiency (i.e., incremental intersection). + + const queryTokenScores = {}; + tokens.forEach(function (key) { + let docs = this.index[fieldName].getDocs(key); + const idf = this.idf(key, fieldName); + + if (scores && booleanType === 'AND') { + // special case, we can rule out documents that have been + // already been filtered out because they weren't scored + // by previous query token passes. + const filteredDocs = {}; + for (var docRef in scores) { + if (docRef in docs) { + filteredDocs[docRef] = docs[docRef]; + } + } + docs = filteredDocs; + } + // only record appeared token for retrieved documents for the + // original token, not for expaned token. + // beause for doing coordNorm for a retrieved document, coordNorm only care how many + // query token appear in that document. + // so expanded token should not be added into docTokens, if added, this will pollute the + // coordNorm + if (key === token) { + this.fieldSearchStats(docTokens, key, docs); + } + + for (var docRef in docs) { + const tf = this.index[fieldName].getTermFrequency(key, docRef); + const fieldLength = this.documentStore.getFieldLength( + docRef, + fieldName + ); + let fieldLengthNorm = 1; + if (fieldLength !== 0) { + fieldLengthNorm = 1 / Math.sqrt(fieldLength); + } + + let penality = 1; + if (key !== token) { + // currently I'm not sure if this penality is enough, + // need to do verification + penality = + (1 - (key.length - token.length) / key.length) * 0.15; + } + + const score = tf * idf * fieldLengthNorm * penality; + + if (docRef in queryTokenScores) { + queryTokenScores[docRef] += score; + } else { + queryTokenScores[docRef] = score; + } + } + }, this); + + scores = this.mergeScores(scores, queryTokenScores, booleanType); + }, this); + + scores = this.coordNorm(scores, docTokens, queryTokens.length); + return scores; + }; + + /** + * Merge the scores from one set of tokens into an accumulated score table. + * Exact operation depends on the op parameter. If op is 'AND', then only the + * intersection of the two score lists is retained. Otherwise, the union of + * the two score lists is returned. For internal use only. + * + * @param {Object} bool accumulated scores. Should be null on first call. + * @param {String} scores new scores to merge into accumScores. + * @param {Object} op merge operation (should be 'AND' or 'OR'). + * + */ + + elasticlunr.Index.prototype.mergeScores = function (accumScores, scores, op) { + if (!accumScores) { + return scores; + } + if (op === 'AND') { + const intersection = {}; + for (var docRef in scores) { + if (docRef in accumScores) { + intersection[docRef] = accumScores[docRef] + scores[docRef]; + } + } + return intersection; + } else { + for (var docRef in scores) { + if (docRef in accumScores) { + accumScores[docRef] += scores[docRef]; + } else { + accumScores[docRef] = scores[docRef]; + } + } + return accumScores; + } + }; + + /** + * Record the occuring query token of retrieved doc specified by doc field. + * Only for inner user. + * + * @param {Object} docTokens a data structure stores which token appears in the retrieved doc. + * @param {String} token query token + * @param {Object} docs the retrieved documents of the query token + * + */ + elasticlunr.Index.prototype.fieldSearchStats = function (docTokens, token, docs) { + for (const doc in docs) { + if (doc in docTokens) { + docTokens[doc].push(token); + } else { + docTokens[doc] = [token]; + } + } + }; + + /** + * coord norm the score of a doc. + * if a doc contain more query tokens, then the score will larger than the doc + * contains less query tokens. + * + * only for inner use. + * + * @param {Object} results first results + * @param {Object} docs field search results of a token + * @param {Integer} n query token number + * @return {Object} + */ + elasticlunr.Index.prototype.coordNorm = function (scores, docTokens, n) { + for (const doc in scores) { + if (!(doc in docTokens)) continue; + const tokens = docTokens[doc].length; + scores[doc] = (scores[doc] * tokens) / n; + } + + return scores; + }; + + /** + * Returns a representation of the index ready for serialisation. + * + * @return {Object} + * @memberOf Index + */ + elasticlunr.Index.prototype.toJSON = function () { + const indexJson = {}; + this._fields.forEach(function (field) { + indexJson[field] = this.index[field].toJSON(); + }, this); + + return { + version: elasticlunr.version, + fields: this._fields, + ref: this._ref, + documentStore: this.documentStore.toJSON(), + index: indexJson, + pipeline: this.pipeline.toJSON(), + }; + }; + + /** + * Applies a plugin to the current index. + * + * A plugin is a function that is called with the index as its context. + * Plugins can be used to customise or extend the behaviour the index + * in some way. A plugin is just a function, that encapsulated the custom + * behaviour that should be applied to the index. + * + * The plugin function will be called with the index as its argument, additional + * arguments can also be passed when calling use. The function will be called + * with the index as its context. + * + * Example: + * + * var myPlugin = function (idx, arg1, arg2) { + * // `this` is the index to be extended + * // apply any extensions etc here. + * } + * + * var idx = elasticlunr(function () { + * this.use(myPlugin, 'arg1', 'arg2') + * }) + * + * @param {Function} plugin The plugin to apply. + * @memberOf Index + */ + elasticlunr.Index.prototype.use = function (plugin) { + const args = Array.prototype.slice.call(arguments, 1); + args.unshift(this); + plugin.apply(this, args); + }; + /*! + * elasticlunr.DocumentStore + * Copyright (C) 2017 Wei Song + */ + + /** + * elasticlunr.DocumentStore is a simple key-value document store used for storing sets of tokens for + * documents stored in index. + * + * elasticlunr.DocumentStore store original JSON format documents that you could build search snippet by this original JSON document. + * + * user could choose whether original JSON format document should be store, if no configuration then document will be stored defaultly. + * If user care more about the index size, user could select not store JSON documents, then this will has some defects, such as user + * could not use JSON document to generate snippets of search results. + * + * @param {Boolean} save If the original JSON document should be stored. + * @constructor + * @module + */ + elasticlunr.DocumentStore = function (save) { + if (save === null || save === undefined) { + this._save = true; + } else { + this._save = save; + } + + this.docs = {}; + this.docInfo = {}; + this.length = 0; + }; + + /** + * Loads a previously serialised document store + * + * @param {Object} serialisedData The serialised document store to load. + * @return {elasticlunr.DocumentStore} + */ + elasticlunr.DocumentStore.load = function (serialisedData) { + const store = new this(); + + store.length = serialisedData.length; + store.docs = serialisedData.docs; + store.docInfo = serialisedData.docInfo; + store._save = serialisedData.save; + + return store; + }; + + /** + * check if current instance store the original doc + * + * @return {Boolean} + */ + elasticlunr.DocumentStore.prototype.isDocStored = function () { + return this._save; + }; + + /** + * Stores the given doc in the document store against the given id. + * If docRef already exist, then update doc. + * + * Document is store by original JSON format, then you could use original document to generate search snippets. + * + * @param {Integer|String} docRef The key used to store the JSON format doc. + * @param {Object} doc The JSON format doc. + */ + elasticlunr.DocumentStore.prototype.addDoc = function (docRef, doc) { + if (!this.hasDoc(docRef)) this.length++; + + if (this._save === true) { + this.docs[docRef] = clone(doc); + } else { + this.docs[docRef] = null; + } + }; + + /** + * Retrieves the JSON doc from the document store for a given key. + * + * If docRef not found, return null. + * If user set not storing the documents, return null. + * + * @param {Integer|String} docRef The key to lookup and retrieve from the document store. + * @return {Object} + * @memberOf DocumentStore + */ + elasticlunr.DocumentStore.prototype.getDoc = function (docRef) { + if (this.hasDoc(docRef) === false) return null; + return this.docs[docRef]; + }; + + /** + * Checks whether the document store contains a key (docRef). + * + * @param {Integer|String} docRef The id to look up in the document store. + * @return {Boolean} + * @memberOf DocumentStore + */ + elasticlunr.DocumentStore.prototype.hasDoc = function (docRef) { + return docRef in this.docs; + }; + + /** + * Removes the value for a key in the document store. + * + * @param {Integer|String} docRef The id to remove from the document store. + * @memberOf DocumentStore + */ + elasticlunr.DocumentStore.prototype.removeDoc = function (docRef) { + if (!this.hasDoc(docRef)) return; + + delete this.docs[docRef]; + delete this.docInfo[docRef]; + this.length--; + }; + + /** + * Add field length of a document's field tokens from pipeline results. + * The field length of a document is used to do field length normalization even without the original JSON document stored. + * + * @param {Integer|String} docRef document's id or reference + * @param {String} fieldName field name + * @param {Integer} length field length + */ + elasticlunr.DocumentStore.prototype.addFieldLength = function ( + docRef, + fieldName, + length + ) { + if (docRef === null || docRef === undefined) return; + if (this.hasDoc(docRef) == false) return; + + if (!this.docInfo[docRef]) this.docInfo[docRef] = {}; + this.docInfo[docRef][fieldName] = length; + }; + + /** + * Update field length of a document's field tokens from pipeline results. + * The field length of a document is used to do field length normalization even without the original JSON document stored. + * + * @param {Integer|String} docRef document's id or reference + * @param {String} fieldName field name + * @param {Integer} length field length + */ + elasticlunr.DocumentStore.prototype.updateFieldLength = function ( + docRef, + fieldName, + length + ) { + if (docRef === null || docRef === undefined) return; + if (this.hasDoc(docRef) == false) return; + + this.addFieldLength(docRef, fieldName, length); + }; + + /** + * get field length of a document by docRef + * + * @param {Integer|String} docRef document id or reference + * @param {String} fieldName field name + * @return {Integer} field length + */ + elasticlunr.DocumentStore.prototype.getFieldLength = function (docRef, fieldName) { + if (docRef === null || docRef === undefined) return 0; + + if (!(docRef in this.docs)) return 0; + if (!(fieldName in this.docInfo[docRef])) return 0; + return this.docInfo[docRef][fieldName]; + }; + + /** + * Returns a JSON representation of the document store used for serialisation. + * + * @return {Object} JSON format + * @memberOf DocumentStore + */ + elasticlunr.DocumentStore.prototype.toJSON = function () { + return { + docs: this.docs, + docInfo: this.docInfo, + length: this.length, + save: this._save, + }; + }; + + /** + * Cloning object + * + * @param {Object} object in JSON format + * @return {Object} copied object + */ + function clone(obj) { + if (obj === null || typeof obj !== 'object') return obj; + + const copy = obj.constructor(); + + for (const attr in obj) { + if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr]; + } + + return copy; + } + /*! + * elasticlunr.stemmer + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt + */ + + /** + * elasticlunr.stemmer is an english language stemmer, this is a JavaScript + * implementation of the PorterStemmer taken from http://tartarus.org/~martin + * + * @module + * @param {String} str The string to stem + * @return {String} + * @see elasticlunr.Pipeline + */ + elasticlunr.stemmer = (function () { + const step2list = { + ational: 'ate', + tional: 'tion', + enci: 'ence', + anci: 'ance', + izer: 'ize', + bli: 'ble', + alli: 'al', + entli: 'ent', + eli: 'e', + ousli: 'ous', + ization: 'ize', + ation: 'ate', + ator: 'ate', + alism: 'al', + iveness: 'ive', + fulness: 'ful', + ousness: 'ous', + aliti: 'al', + iviti: 'ive', + biliti: 'ble', + logi: 'log', + }; + + const step3list = { + icate: 'ic', + ative: '', + alize: 'al', + iciti: 'ic', + ical: 'ic', + ful: '', + ness: '', + }; + + const c = '[^aeiou]'; // consonant + const v = '[aeiouy]'; // vowel + const C = c + '[^aeiouy]*'; // consonant sequence + const V = v + '[aeiou]*'; // vowel sequence + + const mgr0 = '^(' + C + ')?' + V + C; // [C]VC... is m>0 + const meq1 = '^(' + C + ')?' + V + C + '(' + V + ')?$'; // [C]VC[V] is m=1 + const mgr1 = '^(' + C + ')?' + V + C + V + C; // [C]VCVC... is m>1 + const s_v = '^(' + C + ')?' + v; // vowel in stem + + const re_mgr0 = new RegExp(mgr0); + const re_mgr1 = new RegExp(mgr1); + const re_meq1 = new RegExp(meq1); + const re_s_v = new RegExp(s_v); + + const re_1a = /^(.+?)(ss|i)es$/; + const re2_1a = /^(.+?)([^s])s$/; + const re_1b = /^(.+?)eed$/; + const re2_1b = /^(.+?)(ed|ing)$/; + const re_1b_2 = /.$/; + const re2_1b_2 = /(at|bl|iz)$/; + const re3_1b_2 = new RegExp('([^aeiouylsz])\\1$'); + const re4_1b_2 = new RegExp('^' + C + v + '[^aeiouwxy]$'); + + const re_1c = /^(.+?[^aeiou])y$/; + const re_2 = + /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/; + + const re_3 = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/; + + const re_4 = + /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/; + const re2_4 = /^(.+?)(s|t)(ion)$/; + + const re_5 = /^(.+?)e$/; + const re_5_1 = /ll$/; + const re3_5 = new RegExp('^' + C + v + '[^aeiouwxy]$'); + + const porterStemmer = function porterStemmer(w) { + let stem, suffix, firstch, re, re2, re3, re4; + + if (w.length < 3) { + return w; + } + + firstch = w.substr(0, 1); + if (firstch == 'y') { + w = firstch.toUpperCase() + w.substr(1); + } + + // Step 1a + re = re_1a; + re2 = re2_1a; + + if (re.test(w)) { + w = w.replace(re, '$1$2'); + } else if (re2.test(w)) { + w = w.replace(re2, '$1$2'); + } + + // Step 1b + re = re_1b; + re2 = re2_1b; + if (re.test(w)) { + var fp = re.exec(w); + re = re_mgr0; + if (re.test(fp[1])) { + re = re_1b_2; + w = w.replace(re, ''); + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1]; + re2 = re_s_v; + if (re2.test(stem)) { + w = stem; + re2 = re2_1b_2; + re3 = re3_1b_2; + re4 = re4_1b_2; + if (re2.test(w)) { + w = w + 'e'; + } else if (re3.test(w)) { + re = re_1b_2; + w = w.replace(re, ''); + } else if (re4.test(w)) { + w = w + 'e'; + } + } + } + + // Step 1c - replace suffix y or Y by i if preceded by a non-vowel which is not the first letter of the word (so cry -> cri, by -> by, say -> say) + re = re_1c; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + w = stem + 'i'; + } + + // Step 2 + re = re_2; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = re_mgr0; + if (re.test(stem)) { + w = stem + step2list[suffix]; + } + } + + // Step 3 + re = re_3; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + suffix = fp[2]; + re = re_mgr0; + if (re.test(stem)) { + w = stem + step3list[suffix]; + } + } + + // Step 4 + re = re_4; + re2 = re2_4; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = re_mgr1; + if (re.test(stem)) { + w = stem; + } + } else if (re2.test(w)) { + var fp = re2.exec(w); + stem = fp[1] + fp[2]; + re2 = re_mgr1; + if (re2.test(stem)) { + w = stem; + } + } + + // Step 5 + re = re_5; + if (re.test(w)) { + var fp = re.exec(w); + stem = fp[1]; + re = re_mgr1; + re2 = re_meq1; + re3 = re3_5; + if (re.test(stem) || (re2.test(stem) && !re3.test(stem))) { + w = stem; + } + } + + re = re_5_1; + re2 = re_mgr1; + if (re.test(w) && re2.test(w)) { + re = re_1b_2; + w = w.replace(re, ''); + } + + // and turn initial Y back to y + + if (firstch == 'y') { + w = firstch.toLowerCase() + w.substr(1); + } + + return w; + }; + + return porterStemmer; + })(); + + elasticlunr.Pipeline.registerFunction(elasticlunr.stemmer, 'stemmer'); + /*! + * elasticlunr.stopWordFilter + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + */ + + /** + * elasticlunr.stopWordFilter is an English language stop words filter, any words + * contained in the stop word list will not be passed through the filter. + * + * This is intended to be used in the Pipeline. If the token does not pass the + * filter then undefined will be returned. + * Currently this StopwordFilter using dictionary to do O(1) time complexity stop word filtering. + * + * @module + * @param {String} token The token to pass through the filter + * @return {String} + * @see elasticlunr.Pipeline + */ + elasticlunr.stopWordFilter = function (token) { + if (token && elasticlunr.stopWordFilter.stopWords[token] !== true) { + return token; + } + }; + + /** + * Remove predefined stop words + * if user want to use customized stop words, user could use this function to delete + * all predefined stopwords. + * + * @return {null} + */ + elasticlunr.clearStopWords = function () { + elasticlunr.stopWordFilter.stopWords = {}; + }; + + /** + * Add customized stop words + * user could use this function to add customized stop words + * + * @params {Array} words customized stop words + * @return {null} + */ + elasticlunr.addStopWords = function (words) { + if (words == null || Array.isArray(words) === false) return; + + words.forEach(function (word) { + elasticlunr.stopWordFilter.stopWords[word] = true; + }, this); + }; + + /** + * Reset to default stop words + * user could use this function to restore default stop words + * + * @return {null} + */ + elasticlunr.resetStopWords = function () { + elasticlunr.stopWordFilter.stopWords = elasticlunr.defaultStopWords; + }; + + elasticlunr.defaultStopWords = { + '': true, + a: true, + able: true, + about: true, + across: true, + after: true, + all: true, + almost: true, + also: true, + am: true, + among: true, + an: true, + and: true, + any: true, + are: true, + as: true, + at: true, + be: true, + because: true, + been: true, + but: true, + by: true, + can: true, + cannot: true, + could: true, + dear: true, + did: true, + do: true, + does: true, + either: true, + else: true, + ever: true, + every: true, + for: true, + from: true, + get: true, + got: true, + had: true, + has: true, + have: true, + he: true, + her: true, + hers: true, + him: true, + his: true, + how: true, + however: true, + i: true, + if: true, + in: true, + into: true, + is: true, + it: true, + its: true, + just: true, + least: true, + let: true, + like: true, + likely: true, + may: true, + me: true, + might: true, + most: true, + must: true, + my: true, + neither: true, + no: true, + nor: true, + not: true, + of: true, + off: true, + often: true, + on: true, + only: true, + or: true, + other: true, + our: true, + own: true, + rather: true, + said: true, + say: true, + says: true, + she: true, + should: true, + since: true, + so: true, + some: true, + than: true, + that: true, + the: true, + their: true, + them: true, + then: true, + there: true, + these: true, + they: true, + this: true, + tis: true, + to: true, + too: true, + twas: true, + us: true, + wants: true, + was: true, + we: true, + were: true, + what: true, + when: true, + where: true, + which: true, + while: true, + who: true, + whom: true, + why: true, + will: true, + with: true, + would: true, + yet: true, + you: true, + your: true, + }; + + elasticlunr.stopWordFilter.stopWords = elasticlunr.defaultStopWords; + + elasticlunr.Pipeline.registerFunction(elasticlunr.stopWordFilter, 'stopWordFilter'); + /*! + * elasticlunr.trimmer + * Copyright (C) 2017 Oliver Nightingale + * Copyright (C) 2017 Wei Song + */ + + /** + * elasticlunr.trimmer is a pipeline function for trimming non word + * characters from the begining and end of tokens before they + * enter the index. + * + * This implementation may not work correctly for non latin + * characters and should either be removed or adapted for use + * with languages with non-latin characters. + * + * @module + * @param {String} token The token to pass through the filter + * @return {String} + * @see elasticlunr.Pipeline + */ + elasticlunr.trimmer = function (token) { + if (token === null || token === undefined) { + throw new Error('token should not be undefined'); + } + + return token.replace(/^\W+/, '').replace(/\W+$/, ''); + }; + + elasticlunr.Pipeline.registerFunction(elasticlunr.trimmer, 'trimmer'); + /*! + * elasticlunr.InvertedIndex + * Copyright (C) 2017 Wei Song + * Includes code from - http://tartarus.org/~martin/PorterStemmer/js.txt + */ + + /** + * elasticlunr.InvertedIndex is used for efficiently storing and + * lookup of documents that contain a given token. + * + * @constructor + */ + elasticlunr.InvertedIndex = function () { + this.root = { docs: {}, df: 0 }; + }; + + /** + * Loads a previously serialised inverted index. + * + * @param {Object} serialisedData The serialised inverted index to load. + * @return {elasticlunr.InvertedIndex} + */ + elasticlunr.InvertedIndex.load = function (serialisedData) { + const idx = new this(); + idx.root = serialisedData.root; + + return idx; + }; + + /** + * Adds a {token: tokenInfo} pair to the inverted index. + * If the token already exist, then update the tokenInfo. + * + * tokenInfo format: { ref: 1, tf: 2} + * tokenInfor should contains the document's ref and the tf(token frequency) of that token in + * the document. + * + * By default this function starts at the root of the current inverted index, however + * it can start at any node of the inverted index if required. + * + * @param {String} token + * @param {Object} tokenInfo format: { ref: 1, tf: 2} + * @param {Object} root An optional node at which to start looking for the + * correct place to enter the doc, by default the root of this elasticlunr.InvertedIndex + * is used. + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.addToken = function (token, tokenInfo, root) { + var root = root || this.root; + let idx = 0; + + while (idx <= token.length - 1) { + const key = token[idx]; + + if (!(key in root)) root[key] = { docs: {}, df: 0 }; + idx += 1; + root = root[key]; + } + + const docRef = tokenInfo.ref; + if (!root.docs[docRef]) { + // if this doc not exist, then add this doc + root.docs[docRef] = { tf: tokenInfo.tf }; + root.df += 1; + } else { + // if this doc already exist, then update tokenInfo + root.docs[docRef] = { tf: tokenInfo.tf }; + } + }; + + /** + * Checks whether a token is in this elasticlunr.InvertedIndex. + * + * + * @param {String} token The token to be checked + * @return {Boolean} + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.hasToken = function (token) { + if (!token) return false; + + let node = this.root; + + for (let i = 0; i < token.length; i++) { + if (!node[token[i]]) return false; + node = node[token[i]]; + } + + return true; + }; + + /** + * Retrieve a node from the inverted index for a given token. + * If token not found in this InvertedIndex, return null. + * + * + * @param {String} token The token to get the node for. + * @return {Object} + * @see InvertedIndex.prototype.get + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.getNode = function (token) { + if (!token) return null; + + let node = this.root; + + for (let i = 0; i < token.length; i++) { + if (!node[token[i]]) return null; + node = node[token[i]]; + } + + return node; + }; + + /** + * Retrieve the documents of a given token. + * If token not found, return {}. + * + * + * @param {String} token The token to get the documents for. + * @return {Object} + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.getDocs = function (token) { + const node = this.getNode(token); + if (node == null) { + return {}; + } + + return node.docs; + }; + + /** + * Retrieve term frequency of given token in given docRef. + * If token or docRef not found, return 0. + * + * + * @param {String} token The token to get the documents for. + * @param {String|Integer} docRef + * @return {Integer} + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.getTermFrequency = function (token, docRef) { + const node = this.getNode(token); + + if (node == null) { + return 0; + } + + if (!(docRef in node.docs)) { + return 0; + } + + return node.docs[docRef].tf; + }; + + /** + * Retrieve the document frequency of given token. + * If token not found, return 0. + * + * + * @param {String} token The token to get the documents for. + * @return {Object} + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.getDocFreq = function (token) { + const node = this.getNode(token); + + if (node == null) { + return 0; + } + + return node.df; + }; + + /** + * Remove the document identified by document's ref from the token in the inverted index. + * + * + * @param {String} token Remove the document from which token. + * @param {String} ref The ref of the document to remove from given token. + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.removeToken = function (token, ref) { + if (!token) return; + const node = this.getNode(token); + + if (node == null) return; + + if (ref in node.docs) { + delete node.docs[ref]; + node.df -= 1; + } + }; + + /** + * Find all the possible suffixes of given token using tokens currently in the inverted index. + * If token not found, return empty Array. + * + * @param {String} token The token to expand. + * @return {Array} + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.expandToken = function (token, memo, root) { + if (token == null || token == '') return []; + var memo = memo || []; + + if (root == void 0) { + root = this.getNode(token); + if (root == null) return memo; + } + + if (root.df > 0) memo.push(token); + + for (const key in root) { + if (key === 'docs') continue; + if (key === 'df') continue; + this.expandToken(token + key, memo, root[key]); + } + + return memo; + }; + + /** + * Returns a representation of the inverted index ready for serialisation. + * + * @return {Object} + * @memberOf InvertedIndex + */ + elasticlunr.InvertedIndex.prototype.toJSON = function () { + return { + root: this.root, + }; + }; + + /*! + * elasticlunr.Configuration + * Copyright (C) 2017 Wei Song + */ + + /** + * elasticlunr.Configuration is used to analyze the user search configuration. + * + * By elasticlunr.Configuration user could set query-time boosting, boolean model in each field. + * + * Currently configuration supports: + * 1. query-time boosting, user could set how to boost each field. + * 2. boolean model chosing, user could choose which boolean model to use for each field. + * 3. token expandation, user could set token expand to True to improve Recall. Default is False. + * + * Query time boosting must be configured by field category, "boolean" model could be configured + * by both field category or globally as the following example. Field configuration for "boolean" + * will overwrite global configuration. + * Token expand could be configured both by field category or golbally. Local field configuration will + * overwrite global configuration. + * + * configuration example: + * { + * fields:{ + * title: {boost: 2}, + * body: {boost: 1} + * }, + * bool: "OR" + * } + * + * "bool" field configuation overwrite global configuation example: + * { + * fields:{ + * title: {boost: 2, bool: "AND"}, + * body: {boost: 1} + * }, + * bool: "OR" + * } + * + * "expand" example: + * { + * fields:{ + * title: {boost: 2, bool: "AND"}, + * body: {boost: 1} + * }, + * bool: "OR", + * expand: true + * } + * + * "expand" example for field category: + * { + * fields:{ + * title: {boost: 2, bool: "AND", expand: true}, + * body: {boost: 1} + * }, + * bool: "OR" + * } + * + * setting the boost to 0 ignores the field (this will only search the title): + * { + * fields:{ + * title: {boost: 1}, + * body: {boost: 0} + * } + * } + * + * then, user could search with configuration to do query-time boosting. + * idx.search('oracle database', {fields: {title: {boost: 2}, body: {boost: 1}}}); + * + * + * @constructor + * + * @param {String} config user configuration + * @param {Array} fields fields of index instance + * @module + */ + elasticlunr.Configuration = function (config, fields) { + var config = config || ''; + + if (fields == undefined || fields == null) { + throw new Error('fields should not be null'); + } + + this.config = {}; + + let userConfig; + try { + userConfig = JSON.parse(config); + this.buildUserConfig(userConfig, fields); + } catch (error) { + elasticlunr.utils.warn( + 'user configuration parse failed, will use default configuration' + ); + this.buildDefaultConfig(fields); + } + }; + + /** + * Build default search configuration. + * + * @param {Array} fields fields of index instance + */ + elasticlunr.Configuration.prototype.buildDefaultConfig = function (fields) { + this.reset(); + fields.forEach(function (field) { + this.config[field] = { + boost: 1, + bool: 'OR', + expand: false, + }; + }, this); + }; + + /** + * Build user configuration. + * + * @param {JSON} config User JSON configuratoin + * @param {Array} fields fields of index instance + */ + elasticlunr.Configuration.prototype.buildUserConfig = function (config, fields) { + let global_bool = 'OR'; + let global_expand = false; + + this.reset(); + if ('bool' in config) { + global_bool = config.bool || global_bool; + } + + if ('expand' in config) { + global_expand = config.expand || global_expand; + } + + if ('fields' in config) { + for (const field in config.fields) { + if (fields.indexOf(field) > -1) { + const field_config = config.fields[field]; + let field_expand = global_expand; + if (field_config.expand != undefined) { + field_expand = field_config.expand; + } + + this.config[field] = { + boost: + field_config.boost || field_config.boost === 0 + ? field_config.boost + : 1, + bool: field_config.bool || global_bool, + expand: field_expand, + }; + } else { + elasticlunr.utils.warn( + 'field name in user configuration not found in index instance fields' + ); + } + } + } else { + this.addAllFields2UserConfig(global_bool, global_expand, fields); + } + }; + + /** + * Add all fields to user search configuration. + * + * @param {String} bool Boolean model + * @param {String} expand Expand model + * @param {Array} fields fields of index instance + */ + elasticlunr.Configuration.prototype.addAllFields2UserConfig = function ( + bool, + expand, + fields + ) { + fields.forEach(function (field) { + this.config[field] = { + boost: 1, + bool, + expand, + }; + }, this); + }; + + /** + * get current user configuration + */ + elasticlunr.Configuration.prototype.get = function () { + return this.config; + }; + + /** + * reset user search configuration. + */ + elasticlunr.Configuration.prototype.reset = function () { + this.config = {}; + }; + /** + * sorted_set.js is added only to make elasticlunr.js compatible with lunr-languages. + * if elasticlunr.js support different languages by default, this will make elasticlunr.js + * much bigger that not good for browser usage. + * + */ + + /*! + * lunr.SortedSet + * Copyright (C) 2017 Oliver Nightingale + */ + + /** + * lunr.SortedSets are used to maintain an array of uniq values in a sorted + * order. + * + * @constructor + */ + lunr.SortedSet = function () { + this.length = 0; + this.elements = []; + }; + + /** + * Loads a previously serialised sorted set. + * + * @param {Array} serialisedData The serialised set to load. + * @returns {lunr.SortedSet} + * @memberOf SortedSet + */ + lunr.SortedSet.load = function (serialisedData) { + const set = new this(); + + set.elements = serialisedData; + set.length = serialisedData.length; + + return set; + }; + + /** + * Inserts new items into the set in the correct position to maintain the + * order. + * + * @param {Object} The objects to add to this set. + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.add = function () { + let i, element; + + for (i = 0; i < arguments.length; i++) { + element = arguments[i]; + if (~this.indexOf(element)) continue; + this.elements.splice(this.locationFor(element), 0, element); + } + + this.length = this.elements.length; + }; + + /** + * Converts this sorted set into an array. + * + * @returns {Array} + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.toArray = function () { + return this.elements.slice(); + }; + + /** + * Creates a new array with the results of calling a provided function on every + * element in this sorted set. + * + * Delegates to Array.prototype.map and has the same signature. + * + * @param {Function} fn The function that is called on each element of the + * set. + * @param {Object} ctx An optional object that can be used as the context + * for the function fn. + * @returns {Array} + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.map = function (fn, ctx) { + return this.elements.map(fn, ctx); + }; + + /** + * Executes a provided function once per sorted set element. + * + * Delegates to Array.prototype.forEach and has the same signature. + * + * @param {Function} fn The function that is called on each element of the + * set. + * @param {Object} ctx An optional object that can be used as the context + * @memberOf SortedSet + * for the function fn. + */ + lunr.SortedSet.prototype.forEach = function (fn, ctx) { + return this.elements.forEach(fn, ctx); + }; + + /** + * Returns the index at which a given element can be found in the + * sorted set, or -1 if it is not present. + * + * @param {Object} elem The object to locate in the sorted set. + * @returns {Number} + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.indexOf = function (elem) { + let start = 0; + let end = this.elements.length; + let sectionLength = end - start; + let pivot = start + Math.floor(sectionLength / 2); + let pivotElem = this.elements[pivot]; + + while (sectionLength > 1) { + if (pivotElem === elem) return pivot; + + if (pivotElem < elem) start = pivot; + if (pivotElem > elem) end = pivot; + + sectionLength = end - start; + pivot = start + Math.floor(sectionLength / 2); + pivotElem = this.elements[pivot]; + } + + if (pivotElem === elem) return pivot; + + return -1; + }; + + /** + * Returns the position within the sorted set that an element should be + * inserted at to maintain the current order of the set. + * + * This function assumes that the element to search for does not already exist + * in the sorted set. + * + * @param {Object} elem The elem to find the position for in the set + * @returns {Number} + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.locationFor = function (elem) { + let start = 0; + let end = this.elements.length; + let sectionLength = end - start; + let pivot = start + Math.floor(sectionLength / 2); + let pivotElem = this.elements[pivot]; + + while (sectionLength > 1) { + if (pivotElem < elem) start = pivot; + if (pivotElem > elem) end = pivot; + + sectionLength = end - start; + pivot = start + Math.floor(sectionLength / 2); + pivotElem = this.elements[pivot]; + } + + if (pivotElem > elem) return pivot; + if (pivotElem < elem) return pivot + 1; + }; + + /** + * Creates a new lunr.SortedSet that contains the elements in the intersection + * of this set and the passed set. + * + * @param {lunr.SortedSet} otherSet The set to intersect with this set. + * @returns {lunr.SortedSet} + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.intersect = function (otherSet) { + const intersectSet = new lunr.SortedSet(); + let i = 0; + let j = 0; + const a_len = this.length; + const b_len = otherSet.length; + const a = this.elements; + const b = otherSet.elements; + + while (true) { + if (i > a_len - 1 || j > b_len - 1) break; + + if (a[i] === b[j]) { + intersectSet.add(a[i]); + i++, j++; + continue; + } + + if (a[i] < b[j]) { + i++; + continue; + } + + if (a[i] > b[j]) { + j++; + continue; + } + } + + return intersectSet; + }; + + /** + * Makes a copy of this set + * + * @returns {lunr.SortedSet} + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.clone = function () { + const clone = new lunr.SortedSet(); + + clone.elements = this.toArray(); + clone.length = clone.elements.length; + + return clone; + }; + + /** + * Creates a new lunr.SortedSet that contains the elements in the union + * of this set and the passed set. + * + * @param {lunr.SortedSet} otherSet The set to union with this set. + * @returns {lunr.SortedSet} + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.union = function (otherSet) { + let longSet, shortSet, unionSet; + + if (this.length >= otherSet.length) { + (longSet = this), (shortSet = otherSet); + } else { + (longSet = otherSet), (shortSet = this); + } + + unionSet = longSet.clone(); + + for ( + let i = 0, shortSetElements = shortSet.toArray(); + i < shortSetElements.length; + i++ + ) { + unionSet.add(shortSetElements[i]); + } + + return unionSet; + }; + + /** + * Returns a representation of the sorted set ready for serialisation. + * + * @returns {Array} + * @memberOf SortedSet + */ + lunr.SortedSet.prototype.toJSON = function () { + return this.toArray(); + }; + /** + * export the module via AMD, CommonJS or as a browser global + * Export code from https://github.com/umdjs/umd/blob/master/returnExports.js + */ + (function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(factory); + } else if (typeof exports === 'object') { + /** + * Node. Does not work with strict CommonJS, but + * only CommonJS-like enviroments that support module.exports, + * like Node. + */ + module.exports = factory(); + } else { + // Browser globals (root is window) + root.elasticlunr = factory(); + } + })(this, function () { + /** + * Just return a value to define the module export. + * This example returns an object, but the module + * can return a function as the exported value. + */ + return elasticlunr; + }); +})(); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // +// End of elasticlunr code (http://elasticlunr.com/elasticlunr.js) // +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // + +window.onload = function () { + if (!document.body.contains(document.getElementById('searchModal'))) { + return; + } + + const results = document.getElementById('results'); + const searchInput = document.getElementById('searchInput'); + const searchModal = document.getElementById('searchModal'); + const searchButton = document.getElementById('search-button'); + const nResultsSpan = document.getElementById('n-results'); + const clearSearchButton = document.getElementById('clear-search'); + const resultsContainer = document.getElementById('results-container'); + + // Replace $SHORTCUT in search icon title with actual OS-specific shortcut. + function getShortcut() { + const userAgent = window.navigator.userAgent.toLowerCase(); + if (userAgent.includes('mac')) { + return 'Cmd + K'; + } else { + return 'Ctrl + K'; + } + } + + function setAttributes(element, attributeNames) { + const shortcut = getShortcut(); + attributeNames.forEach((attributeName) => { + let attributeValue = element.getAttribute(attributeName); + if (attributeValue) { + attributeValue = attributeValue.replace('$SHORTCUT', shortcut); + element.setAttribute(attributeName, attributeValue); + } + }); + } + setAttributes(searchButton, ['title', 'aria-label']); + + // Make search button keyboard accessible. + searchButton.addEventListener('keydown', function (event) { + if (event.key === 'Enter' || event.key === ' ') { + searchButton.click(); + } + }); + + let lastFocusedElement; + function openSearchModal() { + lastFocusedElement = document.activeElement; + loadSearchIndex(); + searchModal.style.display = 'block'; + searchInput.focus(); + } + + function closeModal() { + searchModal.style.display = 'none'; + clearSearch(); + if (lastFocusedElement && document.body.contains(lastFocusedElement)) { + lastFocusedElement.focus(); + } + } + + function toggleModalVisibility() { + const isModalOpen = searchModal.style.display === 'block'; + if (isModalOpen) { + closeModal(); + } else { + openSearchModal(); + } + } + + // Function to remove 'selected' class from all divs except the one passed. + function clearSelected(exceptDiv = null) { + const divs = results.querySelectorAll('#results > div'); + divs.forEach((div) => { + if (div !== exceptDiv) { + div.setAttribute('aria-selected', 'false'); + } + }); + } + + function updateSelection(div) { + if (div.getAttribute('aria-selected') !== 'true') { + clearSelected(div); + div.setAttribute('aria-selected', 'true'); + } + searchInput.setAttribute('aria-activedescendant', div.id); + } + + function clearSearch() { + searchInput.value = ''; + results.innerHTML = ''; + nResultsSpan.textContent = '0'; + resultsContainer.style.display = 'none'; + searchInput.removeAttribute('aria-activedescendant'); + } + + // Close modal when clicking/tapping outside. + function handleModalInteraction(event) { + if (event.target === searchModal) { + closeModal(); + } + event.stopPropagation(); // Prevents tapping through the modal. + } + searchModal.addEventListener('click', handleModalInteraction); + searchModal.addEventListener('touchend', handleModalInteraction); + + // Close modal when pressing escape. + document.addEventListener('keydown', function (event) { + if (event.key === 'Escape') { + closeModal(); + } + }); + + clearSearchButton.addEventListener('click', function () { + clearSearch(); + searchInput.focus(); + }); + clearSearchButton.addEventListener('keydown', function (event) { + if (event.key === 'Enter' || event.key === ' ') { + clearSearch(); + searchInput.focus(); + event.preventDefault(); + } + }); + + // The index loads on mouseover/tap. + // Clicking/tapping the search button opens the modal. + searchButton.addEventListener('mouseover', loadSearchIndex); + searchButton.addEventListener('click', openSearchModal); + searchButton.addEventListener('touchstart', openSearchModal); + + let searchIndexPromise = null; + function loadSearchIndex() { + if (!searchIndexPromise) { + // Check if the search index is already loaded in the window object + if (window.searchIndex) { + // If the index is pre-loaded, use it directly. + searchIndexPromise = Promise.resolve( + elasticlunr.Index.load(window.searchIndex) + ); + } else { + // If the index is not pre-loaded, fetch it from the JSON file. + const language = document.documentElement + .getAttribute('lang') + .substring(0, 2); + let basePath = document + .querySelector("meta[name='base']") + .getAttribute('content'); + if (basePath.endsWith('/')) { + basePath = basePath.slice(0, -1); + } + + searchIndexPromise = fetch( + basePath + '/search_index.' + language + '.json' + ) + .then((response) => response.json()) + .then((json) => elasticlunr.Index.load(json)); + } + } + } + + function getByteByBinary(binaryCode) { + // Binary system, starts with `0b` in ES6 + // Octal number system, starts with `0` in ES5 and starts with `0o` in ES6 + // Hexadecimal, starts with `0x` in both ES5 and ES6 + var byteLengthDatas = [0, 1, 2, 3, 4]; + var len = byteLengthDatas[Math.ceil(binaryCode.length / 8)]; + return len; + } + + function getByteByHex(hexCode) { + return getByteByBinary(parseInt(hexCode, 16).toString(2)); + } + + function substringByByte(str, maxLength) { + let result = ''; + let flag = false; + let len = 0; + let length = 0; + let length2 = 0; + for (let i = 0; i < str.length; i++) { + const code = str.codePointAt(i).toString(16); + if (code.length > 4) { + i++; + if (i + 1 < str.length) { + flag = str.codePointAt(i + 1).toString(16) === '200d'; + } + } + if (flag) { + len += getByteByHex(code); + if (i == str.length - 1) { + length += len; + if (length <= maxLength) { + result += str.substr(length2, i - length2 + 1); + } else { + break; + } + } + } else { + if (len != 0) { + length += len; + length += getByteByHex(code); + if (length <= maxLength) { + result += str.substr(length2, i - length2 + 1); + length2 = i + 1; + } else { + break; + } + len = 0; + continue; + } + length += getByteByHex(code); + if (length <= maxLength) { + if (code.length <= 4) { + result += str[i]; + } else { + result += str[i - 1] + str[i]; + } + length2 = i + 1; + } else { + break; + } + } + } + return result; + } + + function generateSnippet(text, searchTerms) { + const BASE_SCORE = 2; + const FIRST_WORD_SCORE = 8; + const HIGHLIGHT_SCORE = 40; + const PRE_MATCH_CONTEXT_WORDS = 4; + const SNIPPET_LENGTH = 150; + const WINDOW_SIZE = 30; + + const stemmedTerms = searchTerms.map(function (term) { + return elasticlunr.stemmer(term.toLowerCase()); + }); + + let totalLength = 0; + const tokenScores = []; + const sentences = text.toLowerCase().split('. '); + + for (const sentence of sentences) { + const words = sentence.split(/[\s\n]/); + let isFirstWord = true; + + for (const word of words) { + if (word.length > 0) { + let score = isFirstWord ? FIRST_WORD_SCORE : BASE_SCORE; + for (const stemmedTerm of stemmedTerms) { + if (elasticlunr.stemmer(word).startsWith(stemmedTerm)) { + score = HIGHLIGHT_SCORE; + } + } + tokenScores.push([word, score, totalLength]); + isFirstWord = false; + } + totalLength += word.length + 1; + } + totalLength += 1; + } + + if (tokenScores.length === 0) { + return text.length > SNIPPET_LENGTH + ? text.substring(0, SNIPPET_LENGTH) + '…' + : text; + } + + const scores = []; + let windowScore = 0; + + for (var i = 0; i < Math.min(tokenScores.length, WINDOW_SIZE); i++) { + windowScore += tokenScores[i][1]; + } + scores.push(windowScore); + + // Slide the window and update the score. + for (var i = 1; i <= tokenScores.length - WINDOW_SIZE; i++) { + windowScore -= tokenScores[i - 1][1]; + windowScore += tokenScores[i + WINDOW_SIZE - 1][1]; + scores.push(windowScore); + } + + let maxScoreIndex = 0; + let maxScore = 0; + for (var i = scores.length - 1; i >= 0; i--) { + if (maxScore < scores[i]) { + maxScore = scores[i]; + maxScoreIndex = i; + } + } + + const snippet = []; + // From my testing, the context is more clear if we start a few words back. + let start = adjustStartPos( + text, + tokenScores[maxScoreIndex][2], + PRE_MATCH_CONTEXT_WORDS + ); + + function adjustStartPos(text, matchStartIndex, numWordsBack) { + let spaceCount = 0; + let index = matchStartIndex - 1; + while (index >= 0 && spaceCount < numWordsBack) { + if (text[index] === ' ' && text[index - 1] !== '.') { + spaceCount++; + } else if (text[index] === '.' && text[index + 1] === ' ') { + // Stop if the match is at the start of a sentence. + break; + } + index--; + } + return spaceCount === numWordsBack ? index + 1 : matchStartIndex; + } + const re = /^[\x00-\xff]+$/; // Regular expression for ASCII check. + for ( + var i = maxScoreIndex; + i < maxScoreIndex + WINDOW_SIZE && i < tokenScores.length; + i++ + ) { + const wordData = tokenScores[i]; + if (start < wordData[2]) { + snippet.push(text.substring(start, wordData[2])); + start = wordData[2]; + } + + if (wordData[1] === HIGHLIGHT_SCORE) { + snippet.push(''); + } + const end = wordData[2] + wordData[0].length; + // Handle non-ASCII characters. + if (!re.test(wordData[0]) && wordData[0].length >= 12) { + const strBefore = text.substring(wordData[2], end); + const strAfter = substringByByte(strBefore, 12); + snippet.push(strAfter); + } else { + snippet.push(text.substring(wordData[2], end)); + } + + if (wordData[1] === HIGHLIGHT_SCORE) { + snippet.push(''); + } + start = end; + } + + snippet.push('…'); + const joinedSnippet = snippet.join(''); + let truncatedSnippet = joinedSnippet; + if (joinedSnippet.replace(/<[^>]+>/g, '').length > SNIPPET_LENGTH) { + truncatedSnippet = joinedSnippet.substring(0, SNIPPET_LENGTH) + '…'; + } + + return truncatedSnippet; + } + + // Handle input in the search box. + searchInput.addEventListener( + 'input', + async function () { + const searchTerm = this.value.trim(); + const searchIndex = await searchIndexPromise; + results.innerHTML = ''; + + resultsContainer.style.display = searchTerm.length > 0 ? 'block' : 'none'; + + // Perform the search and store the results. + const searchResults = searchIndex.search(searchTerm, { + bool: 'OR', + fields: { + title: { boost: 3 }, + body: { boost: 2 }, + description: { boost: 1 }, + path: { boost: 1 }, + }, + }); + + // Update the number of results. + updateResultText(searchResults.length); + + // Display the results. + let resultIdCounter = 0; // Counter to generate unique IDs. + searchResults.forEach(function (result) { + if (result.doc.title || result.doc.path || result.doc.id) { + const resultDiv = document.createElement('div'); + resultDiv.setAttribute('role', 'option'); + resultDiv.id = 'result-' + resultIdCounter++; + resultDiv.innerHTML = ''; + const linkElement = resultDiv.querySelector('a'); + const titleElement = resultDiv.querySelector('span:first-child'); + const snippetElement = resultDiv.querySelector('span:nth-child(2)'); + + // Determine the text for the title. + titleElement.textContent = + result.doc.title || result.doc.path || result.doc.id; + + // Determine if the body or description is available for the snippet. + let snippetText = result.doc.body + ? generateSnippet(result.doc.body, searchTerm.split(/\s+/)) + : result.doc.description + ? result.doc.description + : ''; + snippetElement.innerHTML = snippetText; + + // Create the hyperlink. + let href = result.ref; + if (result.doc.body) { + // Include text fragment if body is available. + const encodedSearchTerm = encodeURIComponent(searchTerm); + href += `#:~:text=${encodedSearchTerm}`; + } + linkElement.href = href; + + results.appendChild(resultDiv); + } + }); + + searchInput.setAttribute( + 'aria-expanded', + resultIdCounter > 0 ? 'true' : 'false' + ); + + if (results.firstChild) { + updateSelection(results.firstChild); + } + + results.addEventListener('mouseover', function (event) { + if (event.target.closest('div[role="option"]')) { + updateSelection(event.target.closest('div[role="option"]')); + } + }); + + // Add touch events to the results. + setupTouchEvents(); + }, + true + ); + + function updateResultText(count) { + const nResultsSpan = document.getElementById('n-results'); + nResultsSpan.textContent = count.toString(); + + const singular = document.getElementById('result-text-singular'); + const plural = document.getElementById('result-text-plural'); + + if (count === 1) { + singular.style.display = 'inline'; + plural.style.display = 'none'; + } else { + singular.style.display = 'none'; + plural.style.display = 'inline'; + } + } + + function setupTouchEvents() { + const resultDivs = document.querySelectorAll('#results > div'); + resultDivs.forEach((div) => { + // Remove existing listener to avoid duplicates. + div.removeEventListener('touchstart', handleTouchStart); + div.addEventListener('touchstart', handleTouchStart); + }); + } + + function handleTouchStart() { + updateSelection(this); + } + + // Handle keyboard navigation. + document.addEventListener('keydown', function (event) { + // Add handling for the modal open/close shortcut. + const isMac = navigator.userAgent.toLowerCase().includes('mac'); + const MODAL_SHORTCUT_KEY = 'k'; + const modalShortcutModifier = isMac ? event.metaKey : event.ctrlKey; + + if (event.key === MODAL_SHORTCUT_KEY && modalShortcutModifier) { + event.preventDefault(); + toggleModalVisibility(); + return; + } + + const activeElement = document.activeElement; + if ( + event.key === 'Tab' && + (activeElement === searchInput || activeElement === clearSearchButton) + ) { + event.preventDefault(); + const nextFocusableElement = + activeElement === searchInput ? clearSearchButton : searchInput; + nextFocusableElement.focus(); + return; + } + + function updateResultSelection(newIndex, divsArray) { + updateSelection(divsArray[newIndex]); + divsArray[newIndex].scrollIntoView({ block: 'nearest', inline: 'start' }); + } + + const resultDivs = results.querySelectorAll('#results > div'); + if (resultDivs.length === 0) return; + + const divsArray = Array.from(resultDivs); + let activeDiv = results.querySelector('[aria-selected="true"]'); + let activeDivIndex = divsArray.indexOf(activeDiv); + + if ( + ['ArrowUp', 'ArrowDown', 'Home', 'End', 'PageUp', 'PageDown'].includes( + event.key + ) + ) { + event.preventDefault(); + let newIndex = activeDivIndex; + + switch (event.key) { + case 'ArrowUp': + newIndex = Math.max(activeDivIndex - 1, 0); + break; + case 'ArrowDown': + newIndex = Math.min(activeDivIndex + 1, divsArray.length - 1); + break; + case 'Home': + newIndex = 0; + break; + case 'End': + newIndex = divsArray.length - 1; + break; + case 'PageUp': + newIndex = Math.max(activeDivIndex - 3, 0); + break; + case 'PageDown': + newIndex = Math.min(activeDivIndex + 3, divsArray.length - 1); + break; + } + + if (newIndex !== activeDivIndex) { + updateResultSelection(newIndex, divsArray); + } + } + + if (event.key === 'Enter' && activeDiv) { + event.preventDefault(); + event.stopImmediatePropagation(); + const anchorTag = activeDiv.querySelector('a'); + if (anchorTag) { + window.location.href = anchorTag.getAttribute('href'); + } + closeModal(); // Necessary when linking to the current page. + } + }); +}; diff --git a/static/js/searchElasticlunr.min.js b/static/js/searchElasticlunr.min.js new file mode 100644 index 0000000..abd7cb1 --- /dev/null +++ b/static/js/searchElasticlunr.min.js @@ -0,0 +1 @@ +!function(){const a=function(e){var t=new a.Index;return t.pipeline.add(a.trimmer,a.stopWordFilter,a.stemmer),e&&e.call(t,t),t};var t;a.version="0.9.5",(lunr=a).utils={},a.utils.warn=(t=this,function(e){t.console&&console.warn&&console.warn(e)}),a.utils.toString=function(e){return null==e?"":e.toString()},a.EventEmitter=function(){this.events={}},a.EventEmitter.prototype.addListener=function(){const e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},a.EventEmitter.prototype.removeListener=function(e,t){this.hasHandler(e)&&-1!==(t=this.events[e].indexOf(t))&&(this.events[e].splice(t,1),0===this.events[e].length)&&delete this.events[e]},a.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){const t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},a.EventEmitter.prototype.hasHandler=function(e){return e in this.events},a.tokenizer=function(n){if(!arguments.length||null==n)return[];if(Array.isArray(n)){let e=n.filter(function(e){return null!=e}),t=(e=e.map(function(e){return a.utils.toString(e).toLowerCase()}),[]);return e.forEach(function(e){e=e.split(a.tokenizer.seperator),t=t.concat(e)},this),t}return n.toString().trim().toLowerCase().split(a.tokenizer.seperator)},a.tokenizer.defaultSeperator=/[\s-]+/,a.tokenizer.seperator=a.tokenizer.defaultSeperator,a.tokenizer.setSeperator=function(e){null!=e&&"object"==typeof e&&(a.tokenizer.seperator=e)},a.tokenizer.resetSeperator=function(){a.tokenizer.seperator=a.tokenizer.defaultSeperator},a.tokenizer.getSeperator=function(){return a.tokenizer.seperator},a.Pipeline=function(){this._queue=[]},a.Pipeline.registeredFunctions={},a.Pipeline.registerFunction=function(e,t){t in a.Pipeline.registeredFunctions&&a.utils.warn("Overwriting existing registered function: "+t),e.label=t,a.Pipeline.registeredFunctions[t]=e},a.Pipeline.getRegisteredFunction=function(e){return e in a.Pipeline.registeredFunctions!=1?null:a.Pipeline.registeredFunctions[e]},a.Pipeline.warnIfFunctionNotRegistered=function(e){e.label&&e.label in this.registeredFunctions||a.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},a.Pipeline.load=function(e){const n=new a.Pipeline;return e.forEach(function(e){var t=a.Pipeline.getRegisteredFunction(e);if(!t)throw new Error("Cannot load un-registered function: "+e);n.add(t)}),n},a.Pipeline.prototype.add=function(){Array.prototype.slice.call(arguments).forEach(function(e){a.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},a.Pipeline.prototype.after=function(e,t){if(a.Pipeline.warnIfFunctionNotRegistered(t),-1===(e=this._queue.indexOf(e)))throw new Error("Cannot find existingFn");this._queue.splice(e+1,0,t)},a.Pipeline.prototype.before=function(e,t){if(a.Pipeline.warnIfFunctionNotRegistered(t),-1===(e=this._queue.indexOf(e)))throw new Error("Cannot find existingFn");this._queue.splice(e,0,t)},a.Pipeline.prototype.remove=function(e){-1!==(e=this._queue.indexOf(e))&&this._queue.splice(e,1)},a.Pipeline.prototype.run=function(o){var e=[],t=o.length,i=this._queue.length;for(let n=0;ne&&(n=i),o=n-t,i=t+Math.floor(o/2),r=this.elements[i]}return r===e?i:-1},lunr.SortedSet.prototype.locationFor=function(e){let t=0,n=this.elements.length,o=n-t,i=t+Math.floor(o/2),r=this.elements[i];for(;1e&&(n=i),o=n-t,i=t+Math.floor(o/2),r=this.elements[i];return r>e?i:ri-1||o>r-1);)s[n]!==l[o]?s[n]l[o]&&o++:(t.add(s[n]),n++,o++);return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){let t,n,o;n=this.length>=e.length?(t=this,e):(t=e,this),o=t.clone();for(let e=0,t=n.toArray();e{let t=n.getAttribute(e);t&&(t=t.replace("$SHORTCUT",v),n.setAttribute(e,t))})}s.addEventListener("keydown",function(e){"Enter"!==e.key&&" "!==e.key||s.click()}),h.addEventListener("click",o),h.addEventListener("touchend",o),document.addEventListener("keydown",function(e){"Escape"===e.key&&u()}),y.addEventListener("click",function(){t(),f.focus()}),y.addEventListener("keydown",function(e){"Enter"!==e.key&&" "!==e.key||(t(),f.focus(),e.preventDefault())}),s.addEventListener("mouseover",i),s.addEventListener("click",l),s.addEventListener("touchstart",l);let r=null;function l(){e=document.activeElement,i(),h.style.display="block",f.focus()}function u(){h.style.display="none",t(),e&&document.body.contains(e)&&e.focus()}function c(e){var t;"true"!==e.getAttribute("aria-selected")&&([t=null]=[e],d.querySelectorAll("#results > div").forEach(e=>{e!==t&&e.setAttribute("aria-selected","false")}),e.setAttribute("aria-selected","true")),f.setAttribute("aria-activedescendant",e.id)}function t(){f.value="",d.innerHTML="",p.textContent="0",m.style.display="none",f.removeAttribute("aria-activedescendant")}function o(e){e.target===h&&u(),e.stopPropagation()}function i(){if(!r)if(window.searchIndex)r=Promise.resolve(elasticlunr.Index.load(window.searchIndex));else{var t=document.documentElement.getAttribute("lang").substring(0,2);let e=document.querySelector("meta[name='base']").getAttribute("content");e.endsWith("/")&&(e=e.slice(0,-1)),r=fetch(e+"/search_index."+t+".json").then(e=>e.json()).then(e=>elasticlunr.Index.load(e))}}function g(e){return e=parseInt(e,16).toString(2),[0,1,2,3,4][Math.ceil(e.length/8)]}function a(){c(this)}f.addEventListener("input",async function(){const s=this.value.trim(),e=await r;d.innerHTML="",m.style.display=0",n.querySelector("a")),i=n.querySelector("span:first-child"),r=n.querySelector("span:nth-child(2)"),i=(i.textContent=t.doc.title||t.doc.path||t.doc.id,t.doc.body?function(n,e){const o=150,i=e.map(function(e){return elasticlunr.stemmer(e.toLowerCase())});let r=0;var s=[],e=n.toLowerCase().split(". ");for(const n of e){const e=n.split(/[\s\n]/);let t=!0;for(const n of e){if(0o?n.substring(0,o)+"…":n;var t=[];let l=0;for(var u=0;u"),e[2]+e[0].length);if(!h.test(e[0])&&12<=e[0].length){const i=function(t){let n="",o=!1,i=0,r=0,s=0;for(let e=0;e"),f=o}d.push("…");var p=e=d.join("");return e.replace(/<[^>]+>/g,"").length>o?e.substring(0,o)+"…":p}(t.doc.body,s.split(/\s+/)):t.doc.description||"");r.innerHTML=i;let e=t.ref;t.doc.body&&(e+="#:~:text="+encodeURIComponent(s)),o.href=e,d.appendChild(n)}}),f.setAttribute("aria-expanded",0 div").forEach(e=>{e.removeEventListener("touchstart",a),e.addEventListener("touchstart",a)})},!0),document.addEventListener("keydown",function(t){var e=navigator.userAgent.toLowerCase().includes("mac")?t.metaKey:t.ctrlKey;if("k"===t.key&&e)t.preventDefault(),("block"===h.style.display?u:l)();else if(e=document.activeElement,"Tab"!==t.key||e!==f&&e!==y){if(0!==(r=d.querySelectorAll("#results > div")).length){var n,o,i=Array.from(r),r=d.querySelector('[aria-selected="true"]'),s=i.indexOf(r);if(["ArrowUp","ArrowDown","Home","End","PageUp","PageDown"].includes(t.key)){t.preventDefault();let e=s;switch(t.key){case"ArrowUp":e=Math.max(s-1,0);break;case"ArrowDown":e=Math.min(s+1,i.length-1);break;case"Home":e=0;break;case"End":e=i.length-1;break;case"PageUp":e=Math.max(s-3,0);break;case"PageDown":e=Math.min(s+3,i.length-1)}e!==s&&(c((o=i)[n=e]),o[n].scrollIntoView({block:"nearest",inline:"start"}))}if("Enter"===t.key&&r){t.preventDefault(),t.stopImmediatePropagation();const d=r.querySelector("a");d&&(window.location.href=d.getAttribute("href")),u()}}}else t.preventDefault(),(e===f?y:f).focus()})}}; diff --git a/templates/partials/footer.html b/templates/partials/footer.html index 73bdde2..e46f9cc 100644 --- a/templates/partials/footer.html +++ b/templates/partials/footer.html @@ -115,4 +115,9 @@ {%- if email_needs_decoding -%} {%- endif -%} + + {# Modal structure for search #} + {%- if config.build_search_index -%} + {% include "partials/search_modal.html" %} + {%- endif -%} diff --git a/templates/partials/header.html b/templates/partials/header.html index 676731f..0ab0c3c 100644 --- a/templates/partials/header.html +++ b/templates/partials/header.html @@ -1,6 +1,7 @@ + {# Site title #} {%- include "partials/title.html" -%} @@ -155,4 +156,30 @@ {%- include "partials/analytics.html" -%} {%- endif -%} + {# Search #} + {%- if config.build_search_index -%} + {%- if config.search.index_format -%} + {%- set search_index_format = config.search.index_format -%} + {%- elif config.extra.index_format -%} + {# Necessary to support Zola 0.17.X, as it doesn't have access to config.search.index_format #} + {# See: https://github.com/getzola/zola/issues/2165 #} + {%- set search_index_format = config.extra.index_format -%} + {%- else -%} + {%- set search_index_format = "elasticlunr_json" -%} + {%- endif -%} + + {%- if search_index_format == "elasticlunr_javascript" -%} + + {%- endif -%} + + {# Main search script #} + + + {# Support correct stemming and stop word filtering in non-English search #} + {%- if lang != "en" -%} + + + {%- endif -%} + {%- endif -%} + diff --git a/templates/partials/nav.html b/templates/partials/nav.html index f8a5cd1..591089c 100644 --- a/templates/partials/nav.html +++ b/templates/partials/nav.html @@ -18,6 +18,18 @@ {% endfor %} {%- endif -%} + {# Search #} + {%- if config.build_search_index %} + {%- set search_icon_title = macros_translate::translate(key='search_icon_title', default='Press $SHORTCUT to open search', language_strings=language_strings) -%} +
  • +
    + + + +
    +
  • + {%- endif %} + {# Language switcher #} {# Display the language switcher only if more than one language is available #} {%- if config.languages | length > 0 %} diff --git a/templates/partials/search_modal.html b/templates/partials/search_modal.html new file mode 100644 index 0000000..2bca8ed --- /dev/null +++ b/templates/partials/search_modal.html @@ -0,0 +1,24 @@ +