Language detection
Which of 69 languages a text is in, its script and how sure: route tickets, tag posts, pick a spell-checker.
Version 1.0.0 · 2 functions · 1 crate
Functions
What use lang.qwer gives a program, with the types Quillo sees. To take only some, or under other names: use detect_language, detect_script from lang (Quillo 0.6).
detect_language(text: str) → any?{ code, name, script, confidence, reliable } for text (code is ISO 639-3: "eng", "fra", "jpn"), or null when it cannot tell.
detect_script(text: str) → str?Only the script text is written in ("Latin", "Cyrillic", "Arabic", "Han", ...), or null.
Get it
$ quillo install lang # lang.qwer into this folder$ quillo install lang --example # and its example, lang.qweOr with curl:
$ curl -O https://quillolang.org/plugins/files/lang.qwer$ curl -O https://quillolang.org/plugins/files/lang.qweThen, in your program, all of it or only what you call:
use lang.qweruse detect_language, detect_script from lang // Quillo 0.6: only theseIt uses this crate, which cargo fetches the first time the plugin is built:
whatlang = "0.16"Example
// Tells the language of each message.//// quillo run lang.qwe then open http://localhost:8080/detect?text=Bonjour+tout+le+mondeuse "lang.qwer"route GET /detect ? { text: str } = detect_language(text)route GET /many = ["Where is my order?", "¿Dónde está mi pedido?", "Wo ist meine Bestellung?", "私の注文はどこですか"] | map((t) => { text: t, lang: detect_language(t)?.code })$ quillo run lang.qwe$ curl 'localhost:8080/detect?text=Bonjour+tout+le+monde%2C+comment+allez-vous'$ curl 'localhost:8080/many'Source
//! Which language a text is in, of 69, with its script and how sure: route support tickets, pick a spell-checker, tag posts.//! version: 1.0.0//!//! [dependencies]//! whatlang = "0.16"use serde_json::{json, Value};/// `{ code, name, script, confidence, reliable }` for `text` (`code` is ISO 639-3: "eng", "fra", "jpn"), or null when it cannot tell.pub fn detect_language(text: &str) -> Option<Value> { whatlang::detect(text).map(|i| json!({ "code": i.lang().code(), "name": i.lang().eng_name(), "script": i.script().name(), "confidence": (i.confidence() * 100.0).round() / 100.0, "reliable": i.is_reliable(), }))}/// Only the script `text` is written in ("Latin", "Cyrillic", "Arabic", "Han", ...), or null.pub fn detect_script(text: &str) -> Option<String> { whatlang::detect_script(text).map(|s| s.name().to_string())}Related
sentiment.qwer · 1.0.0How positive or negative English text is, by VADER: scores from -1 to 1 that understand not good, VERY good!!! and emoji, for reviews, tickets and feedback.7 views · 9 downloadsCase case.qwer · 1.0.0Text in snake_case, camelCase, PascalCase, kebab-case, CONSTANT_CASE, Title Case and Sentence case: column names as API keys and labels.7 views · 8 downloadsChinese words 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 downloadsEmoji emoji.qwer · 1.0.0Emoji for chat and comments: :shortcodes: turned into emoji and back, emoji found with their names, stripped from subjects, and searched by name for a picker.7 views · 8 downloadsFluent translations fluent.qwer · 1.0.0Project Fluent translations (.ftl): messages formatted by locale with each language's plural forms, selectors on gender or anything else, terms and attributes, fallback from one locale to the next, and translation files checked and compared.8 views · 7 downloadsFuzzy search fuzzy.qwer · 1.0.0Rank names against what someone typed, typos and all, edit distances, and did-you-mean.7 views · 8 downloadsThread 0 posts
On Language detection: questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.