// A tag cloud that counts "runs", "running" and "run" as one word, in English and French.
//
//   quillo run stemming.qwe      then open http://localhost:8080/cloud

use "stemming.qwer"

let posts = ["Running shoes for runners", "How I run every morning", "The runner's guide to running in the rain"]

route GET /cloud {
    let counts = {}
    for p in posts {
        for s in stem_text(p, "en")? {
            counts = set(counts, s, (counts[s] ?? 0) + 1)
        }
    }
    counts
}

route GET /stem ? { word: str, lang: str = "en" } = { word, stem: stem(word, lang)? }

route GET /same = { en: stem_same("connected", "connection", "en")?, fr: stem_same("continuer", "continuation", "fr")?, french: stem_text("Les chanteuses chantaient des chansons", "fr")? }
