Skip to content

Python-C usage and API

Radixor-C mirrors the public stemming API of radixor so an application can usually switch imports without changing its stemming calls:

from radixor_c import Stemmer

stemmer = Stemmer("en")

Model selection

Stemmer("en")                              # language alias
Stemmer("us-uk-default")                  # full standard model ID
Stemmer(compiled="domain-english.rxc")    # application-owned compiled model

path= is accepted as an alias for a compiled model path for API compatibility, but it does not compile a text dictionary in Radixor-C.

Stemming calls

Call Result for a recognized word Result when no patch applies
stem(word) dominant stem None
stem_batch(words) one dominant result per input None at that position
stemWord(word) dominant stem original word
stemWords(words) one result per input original word at that position
stem_all(word) ranked candidate stems empty list
stem_all_batch(words) candidates per input empty list at that position

The bounded result cache defaults to 10,000 entries. Set cache_size=0 to disable it or use the PyStemmer-compatible maxCacheSize name.

Stemmer("en", cache_size=0)
Stemmer("english", 50_000)

Use lowercase=False only when inputs have already been normalized. Stemmer instances are safe to share between Python threads.

Lookup policy for customized models

Radixor-C cannot modify a trie, but it can serve a customized .rxc produced by Java or the PyO3 TrieBuilder. Select how rules along one trie path are resolved with lookup=:

Value Selection
"first" (default) stop at the shallowest accepting generalization; preserves historical behavior
"last" prefer the deepest exact rule, using the generalization as fallback
"all" make stem_all return candidates from deepest to shallowest; scalar calls behave like "last"
custom = Stemmer(compiled="custom-en.rxc", lookup="last")
custom.stemWord("kubernetes")

The mode is a runtime policy and is not stored in the compiled model. See Customizing a Dictionary for the trie shape and a visual explanation.

Scope boundary

Radixor-C does not expose radixor.compile(...), textual dictionary loading, or trie modification. Compile or extend models outside the serving process and load the finished artifact. The shared Data Formats page shows which tool creates each artifact; the runtime chooser compares all three implementations.