Stop words
Stop words of 58 languages (the, and, of; le, et, de), and text with them taken out, for search queries, keywords and tag clouds.
Version 1.0.0 · 4 functions · 1 crate
Functions
What use stopwords.qwer gives a program, with the types Quillo sees. To take only some, or under other names: use stopwords_list, stopwords_is from stopwords (Quillo 0.6).
stopwords_list(language: str) → listor an errorThe stop words of language, a two-letter code ("en", "fr", "de", "es", "ja"...), in lower case.
stopwords_is(word: str, language: str) → boolor an errorWhether word is a stop word of language, case ignored.
stopwords_remove(text: str, language: str) → listor an errorThe words of text that are not stop words, in order, as written: the text split at anything but letters, digits, ' and -. Up to 1 MB.
stopwords_languages() → listThe languages there are, as codes.
Get it
$ quillo install stopwords # stopwords.qwer into this folder$ quillo install stopwords --example # and its example, stopwords.qweOr with curl:
$ curl -O https://quillolang.org/plugins/files/stopwords.qwer$ curl -O https://quillolang.org/plugins/files/stopwords.qweThen, in your program, all of it or only what you call:
use stopwords.qweruse stopwords_list, stopwords_is from stopwords // Quillo 0.6: only theseIt uses this crate, which cargo fetches the first time the plugin is built:
stop-words = "0.10"Example
// A search box that ignores "the", "a" and "of", and a word count of what is left.//// quillo run stopwords.qwe then open http://localhost:8080/query?q=the%20history%20of%20the%20roman%20empireuse "stopwords.qwer"route GET /query ? { q: str, lang: str = "en" } = { terms: stopwords_remove(q, lang)? }route GET /french = { terms: stopwords_remove("Le petit prince et la rose de son astéroïde", "fr")?, is_stop: stopwords_is("Les", "fr")? }route GET /languages = { count: len(stopwords_languages()), english: len(stopwords_list("en")?) }$ quillo run stopwords.qwe$ curl 'localhost:8080/query?q=the%20history%20of%20the%20roman%20empire'$ curl 'localhost:8080/french'Source
//! Stop words ("the", "and", "of"; "le", "et", "de") of 50+ languages, and text with them taken out, for search, keywords and tag clouds.//! version: 1.0.0//!//! [dependencies]//! stop-words = "0.10"use std::collections::HashSet;fn words(language: &str) -> Result<&'static [&'static str], String> { let l = language.trim().to_lowercase(); stop_words::lookup(if l.is_empty() { "en" } else { &l }).ok_or_else(|| format!("no stop words for {:?}; see stopwords_languages()", language))}/// The stop words of `language`, a two-letter code ("en", "fr", "de", "es", "ja"...), in lower case.pub fn stopwords_list(language: &str) -> Result<Vec<String>, String> { Ok(words(language)?.iter().map(|w| w.to_string()).collect())}/// Whether `word` is a stop word of `language`, case ignored.pub fn stopwords_is(word: &str, language: &str) -> Result<bool, String> { Ok(words(language)?.contains(&word.trim().to_lowercase().as_str()))}/// The words of `text` that are not stop words, in order, as written: the text split at anything but letters, digits, `'` and `-`. Up to 1 MB.pub fn stopwords_remove(text: &str, language: &str) -> Result<Vec<String>, String> { if text.len() > 1_000_000 { return Err("text up to 1 MB".into()); } let set: HashSet<&str> = words(language)?.iter().copied().collect(); Ok(text .split(|c: char| !(c.is_alphanumeric() || c == '\'' || c == '’' || c == '-')) .map(|w| w.trim_matches(|c: char| c == '\'' || c == '’' || c == '-')) .filter(|w| !w.is_empty() && !set.contains(w.to_lowercase().as_str())) .map(String::from) .collect())}/// The languages there are, as codes.pub fn stopwords_languages() -> Vec<String> { stop_words::available_languages().iter().map(|s| s.to_string()).collect()}Related
chinese_segment.qwer · 1.0.0Chinese text split into words for search indexes and counts, with parts of speech, and written in pinyin with tones, tone numbers or initials for sorting and finding names.7 views · 7 downloadsStemming stemming.qwer · 1.0.0Words cut to their stems in 18 languages, so running, runs and run count as one word in a search or a tag cloud.7 views · 8 downloadsFuzzy search fuzzy.qwer · 1.0.0Rank names against what someone typed, typos and all, edit distances, and did-you-mean.7 views · 8 downloadsHyphenation hyphenation.qwer · 1.0.0Words hyphenated by the rules of 80 languages and spellings, patterns built in: a word's syllables, soft hyphens put in text and HTML for narrow columns and e-mails, and text wrapped at a width with words broken where they may be.6 views · 7 downloadsJapanese kana kana.qwer · 1.0.0Japanese kana: romaji typed as hiragana or katakana, kana written in Hepburn romaji, hiragana and katakana each to the other, half-width katakana from bank and till systems made full-width, and which scripts a text uses.6 views · 10 downloadsKeywords keywords.qwer · 1.0.0The keywords and key phrases of a text by RAKE, TextRank or TF-IDF, with stop words of 58 languages left out: tags, SEO and related posts.7 views · 6 downloadsThread 0 posts
On Stop words: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.