Swedish language pack
Swedish bundle for the Piko linguistics service. It supplies a Snowball stemmer, a Swedish phonetic encoder, and a stop-word list, all through a single blank import with no glue code.
Overview
The Swedish pack registers three adapters under the language code swedish. The stemmer is kljensen/snowball configured for Swedish (for example flickorna to flick). The phonetic encoder applies Swedish-specific digraph rules for fuzzy sound-based matching. It collapses sounds such as sj, skj, stj, and tj to a single code. The encoder caps the output at a maximum length (default 6), so each code runs at most six characters and often shorter. The stop-word provider holds 111 entries covering articles, conjunctions, prepositions, pronouns, auxiliaries, negations, quantifiers, and common adverbs.
Each adapter is a clean port implementation. The stemmer satisfies StemmerPort, the encoder satisfies PhoneticEncoderPort, and the provider satisfies StopWordsProviderPort. Compile-time assertions guard each one. All three resolve through a single WithLanguage("swedish") lookup, so Swedish slots into the same registries any consumer queries by name.
The package itself contains no exported types or constructors. It exists to register the three adapters through init() side effects in the per-feature sub-packages (linguistics_phonetic_swedish, linguistics_stemmer_swedish, linguistics_stopwords_swedish). It is pure Go, so it needs no build tag or CGO and runs in interpreted dev-i mode.
Bootstrap
A blank import is enough. Each sub-package's init() registers itself with the linguistics domain registry. The import must be present in the final binary's import graph for any Swedish component to resolve.
import (
_ "piko.sh/piko/wdk/linguistics/linguistics_language_swedish"
)
After import, select the language on an analyser through WithLanguage. This one call looks up the stemmer, phonetic encoder, and stop words from their registries.
import "piko.sh/piko/wdk/linguistics"
config := linguistics.DefaultConfigForLanguage("swedish")
analyser := linguistics.NewAnalyser(config, linguistics.WithLanguage("swedish"))
The cache_linguistics bridge wraps this in NewTextAnalyserForLanguage, which takes any language code and calls the same lookup. The pattern is identical across every language pack, so swapping swedish for norwegian is a one-import change.
See also
Other language packs:
Consumers:
- Cache linguistics bridge, wires a registered language into the cache search analyser.
Framework docs:
- Linguistics API reference, every type and function on the linguistics service.