feat!: modularize stemmer models and release infrastructure
Move bundled stemmer dictionaries from the core artifact into independently versioned model modules. Add model discovery and explicit model-loading APIs, a standard model aggregate, a model BOM, and dedicated model and catalog release workflows. Add full PoliMorf integration, model provenance and licensing validation, streaming model-input verification, strict dependency verification, consumer resolution tests, Configuration Cache compatibility, and expanded JMH, quality, documentation, and release checks. Upgrade the CycloneDX and JMH Gradle plugins and remove Gradle 10 and Java compiler deprecations. BREAKING CHANGE: The core Radixor artifact no longer contains bundled stemmer dictionaries. Applications must add the required model artifacts, the standard model aggregate, or model dependencies managed through the Radixor model BOM.
This commit is contained in:
@@ -17,6 +17,10 @@ The build-time flow is:
|
||||
Dictionary -> Mutable trie -> Reduced trie -> Compiled trie
|
||||
```
|
||||
|
||||
For registered models, the dictionary is an independently versioned GZip resource discovered through a descriptor and verified before this flow begins. The model resource is input to trie construction, not a precompiled trie. See [Model Selection and Loading](model-selection-and-loading.md) for discovery and [Architecture](architecture.md) for component and release boundaries.
|
||||
|
||||
Explicit descriptors and stable model IDs now use the same compiled-value path as language defaults. `loadCompiled(descriptor, ...)` and `loadCompiled(modelId, ...)` first build with serialized patch commands and then map those values to `CompiledPatchCommand` while preserving metadata, reduction semantics, and ranked `getAll` order. Very large inputs can have a high temporary construction peak; PoliMorf is verified in an isolated 6 GiB JVM rather than increasing ordinary test or Gradle daemon heaps.
|
||||
|
||||
At runtime, the compiled trie does not directly return the final stem string. It returns one or more stored patch commands for the addressed key, and those commands are then applied to the original input word.
|
||||
|
||||
## Why this matters
|
||||
@@ -50,3 +54,5 @@ For most readers, the best order is:
|
||||
- [Programmatic usage](programmatic-usage.md)
|
||||
- [CLI compilation](cli-compilation.md)
|
||||
- [Dictionary format](dictionary-format.md)
|
||||
- [Model selection and loading](model-selection-and-loading.md)
|
||||
- [Stemmer models](stemmer-models.md)
|
||||
|
||||
@@ -2,6 +2,92 @@
|
||||
|
||||
This document explains the structural architecture of **Radixor**: what data is stored, how it flows through the build pipeline, and how runtime lookup works once a compiled trie has been produced.
|
||||
|
||||
## Component boundaries
|
||||
|
||||
| Component | Responsibility |
|
||||
|---|---|
|
||||
| Root Radixor core | Patch commands, dictionary parser, trie construction/lookup, descriptor and registry APIs, loaders; no language data |
|
||||
| Individual model module | Immutable source input and license; publishes one independently versioned resource JAR |
|
||||
| `StemmerModelRegistry` | Deterministic index/descriptor discovery and selection by model ID or language default |
|
||||
| `StemmerModelDescriptor` | Immutable public view of validated runtime identity, format, resource, checksum, and source URL |
|
||||
| Model convention plugin | Validates inputs and generates the resource namespace, descriptor, index, license, and publication |
|
||||
| Standard aggregate | POM-only transitive runtime dependencies for one default per language |
|
||||
| Verification classpaths | Direct individual-model dependencies for tests, quality evaluation, and JMH, including optional PoliMorf |
|
||||
| Models BOM | POM-only recommended individual model versions in Maven dependency management |
|
||||
| Documentation staging | Maintained `docs/` plus generated catalog under `build/mkdocs-source/` |
|
||||
| Release workflows | Independent core, one-model, and catalog publication boundaries |
|
||||
|
||||
Read [Model Selection and Loading](model-selection-and-loading.md) for executable application examples and [Stemmer Models](stemmer-models.md) for artifact maintenance.
|
||||
|
||||
## Runtime model discovery and loading
|
||||
|
||||
The implemented sequence is:
|
||||
|
||||
1. use the thread context `ClassLoader`, or an explicit non-null loader;
|
||||
2. enumerate every `META-INF/radixor/models.index` with `ClassLoader.getResources(...)`;
|
||||
3. sort index URLs and validate every descriptor path;
|
||||
4. read descriptor resources and required properties;
|
||||
5. validate model ID, language, exact resource namespace, checksum syntax, format name, and format version;
|
||||
6. sort descriptors by model ID and reject duplicate IDs;
|
||||
7. resolve either `Language.defaultModelId()` or an exact explicit model ID;
|
||||
8. open the declared model resource with the descriptor's discovering loader;
|
||||
9. compare SHA-256 over the compressed bytes;
|
||||
10. decompress GZip and parse UTF-8 Radixor dictionary rows;
|
||||
11. build and reduce a `FrequencyTrie`;
|
||||
12. optionally compile stored patch strings into `CompiledPatchCommand` values for the language-oriented compiled API.
|
||||
|
||||
Descriptor discovery verifies resource presence before selection. Byte-level checksum verification happens when the selected model is loaded. The registry never scans arbitrary JAR contents and never selects “the first model for a language.”
|
||||
|
||||
### Default Polish resolution
|
||||
|
||||
`StemmerPatchTrieLoader.Language.PL_PL` declares `pl-pl-unimorph` in the enum constructor. A language-oriented load creates a context-loader registry and calls `requireDefault(PL_PL)`. If that ID is absent, loading stops with `StemmerModelNotFoundException` naming `org.egothor:radixor-model-pl-pl-unimorph:<version>`.
|
||||
|
||||
### Explicit PoliMorf resolution
|
||||
|
||||
`registry.require("pl-pl-polimorf")` addresses the alternative directly. It neither changes nor consults the Polish default. Both descriptors may coexist; duplicate declarations of either same ID are rejected.
|
||||
|
||||
## Version axes
|
||||
|
||||
| Version | Owned by | Compatibility purpose |
|
||||
|---|---|---|
|
||||
| Core version | Root Git-derived release | Java implementation and public API |
|
||||
| Model artifact version | Each `model-version.txt` | One independently published model JAR |
|
||||
| Catalog version | `models/catalog-version.txt` | Standard aggregate and BOM recommendation set |
|
||||
| Source dictionary version | Module provenance | Upstream lexical data lineage |
|
||||
| Model format version | Descriptor and registry | Loader compatibility for packaged dictionary representation |
|
||||
|
||||
No equality relationship is implied between these values.
|
||||
|
||||
## Build topology and generated output
|
||||
|
||||
`models/model-projects.properties` is the single Gradle-readable topology list for the 21 individual model projects and their default or optional aggregate role. Per-model build scripts and generated descriptors remain authoritative for language, resource, provenance, checksum, and model-specific metadata. `settings.gradle`, root verification classpaths, the standard POM, and BOM constraints all derive membership from the topology list.
|
||||
|
||||
Gradle implicitly creates the lifecycle parent `:models` because child paths are nested. It has no build script, applied project plugin, Maven coordinate, publication, or archive. The root CycloneDX plugin exposes direct-task instances to subprojects internally; every subproject instance is disabled, so only root `:cyclonedxDirectBom` can generate an SBOM. The ignored path `models/build/` is generated output, not a module, and the supported build does not write reports there. Root aggregate reports, including `verifyJmhModelClasspath`, belong under `build/reports/models/`; each individual model retains its own outputs under `models/<model-id>/build/`.
|
||||
|
||||
`models/bom` is a Maven dependency BOM: it controls recommended dependency versions and adds no runtime artifacts. The root CycloneDX task produces a software bill of materials (SBOM) under `build/reports/sbom/`. These artifacts have different purposes and output locations.
|
||||
|
||||
## Build-time model packaging
|
||||
|
||||
The `org.egothor.radixor.model` convention plugin treats `src/modelInput` as immutable. `validateModelInput` checks the GZip stream, strict UTF-8, dictionary rows, ID, semantic model version, and license. `prepareModelResources` copies identical compressed bytes under `org/egothor/stemmer/models/<model-id>/stemmer.gz` and generates the descriptor, index, and packaged license under `build/`. `verifyModelDescriptor` checks the digest, while `verifyModelJar` checks the unique resource, packaged-byte digest, metadata, and dictionary-free documentation artifacts. The root `runtimeModelIntegrationTest` accepts `-PmodelId=<id>` and verifies transformation of a packaged resource into `FrequencyTrie<CompiledPatchCommand>`; PoliMorf release validation depends on this complete runtime test.
|
||||
|
||||
For UniMorph models, the convention validates and packages one model-specific attribution,
|
||||
licensing, provenance, and contribution notice. Source and packaged notice bytes must match. The
|
||||
notice identifies CC BY-SA 3.0 through its canonical URI; no project-wide CC license directory or
|
||||
duplicated full legal text is used. Descriptors distinguish exact revisions from the explicit
|
||||
legacy-import sentinel. UniMorph supplies morphological data; runtime patch commands and tries are
|
||||
constructed by Radixor. The Java software remains BSD-3-Clause, while PoliMorf data remains under
|
||||
its separately packaged BSD-2-Clause license.
|
||||
|
||||
## Release and security boundaries
|
||||
|
||||
| Tag | Publication boundary |
|
||||
|---|---|
|
||||
| `release@<core-version>` | Root `org.egothor:radixor` artifacts only; never model JARs |
|
||||
| `model/<model-id>@<model-version>` | Exactly one matching model; never core, catalog, or other models |
|
||||
| `models-catalog@<catalog-version>` | BOM and standard aggregate only; never model bytes |
|
||||
|
||||
License inclusion, strict metadata paths, resource presence, SHA-256 verification, unsupported-format rejection, and duplicate-ID rejection form the model integrity boundary. These checks detect packaging mistakes and corruption; model data remains non-executable dictionary input.
|
||||
|
||||
## The central idea
|
||||
|
||||
Radixor does not store final stems directly as a large flat lookup table. Instead, it stores **patch commands** that describe how a word form should be transformed into a canonical stem.
|
||||
@@ -10,7 +96,7 @@ For example, if a dictionary states that `running` should reduce to `run`, the f
|
||||
|
||||
That matters because many words share similar transformation patterns. Once those mappings are organized in a trie and compiled into a canonical structure, the result is much smaller and more reusable than a naive direct-output table.
|
||||
|
||||
## End-to-end build flow
|
||||
## Trie construction flow
|
||||
|
||||
The full build-time flow is:
|
||||
|
||||
@@ -191,7 +277,7 @@ This is why a very large dictionary can still produce a manageable deployable ru
|
||||
|
||||
The compactness of the final artifact should not be confused with the memory usage of preparation.
|
||||
|
||||
Before reduction has completed, the mutable build-time structure must exist in memory. For large dictionaries, that temporary preparation cost can be noticeably higher than the size of the final persisted artifact or the loaded compiled trie.
|
||||
Before reduction has completed, the mutable build-time structure must exist in memory. For large dictionaries, that temporary preparation cost can be noticeably higher than the size of the final persisted artifact or the loaded compiled trie. PoliMorf is the exceptional current case: two complete test constructions took 23.7 and 23.5 seconds, produced 358,993 canonical nodes, and used a task-specific 6 GiB maximum heap. The process peak does not establish the retained heap of the final trie, which is not currently measured separately.
|
||||
|
||||
That is why the preferred operational model is usually:
|
||||
|
||||
@@ -218,3 +304,5 @@ Determinism matters not only for tests, but also for operational trust. It makes
|
||||
- [Reduction Semantics](reduction-semantics.md)
|
||||
- [Programmatic usage](programmatic-usage.md)
|
||||
- [CLI compilation](cli-compilation.md)
|
||||
- [Model selection and loading](model-selection-and-loading.md)
|
||||
- [Stemmer models](stemmer-models.md)
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
Radixor contains internal trie microbenchmarks, a separate stemmer comparison suite, and a dictionary coverage benchmark for Radixor itself. Published stemmer comparison results must come only from benchmark classes matching `.*StemmerComparisonBenchmark.*`; internal `FrequencyTrie*` microbenchmarks are not part of those results.
|
||||
|
||||
Every current default Radixor benchmark scenario uses the model ID declared by its `Language.defaultModelId()`. The root JMH runtime configuration depends directly on all default model projects plus optional `pl-pl-polimorf`; no benchmark-pack project or artifact exists. These dependencies are benchmark-only and never enter the root published POM. A PoliMorf comparison must be labeled with model ID `pl-pl-polimorf`, while the default Polish row remains `pl-pl-unimorph`.
|
||||
|
||||
The optional model now has a verified complete compiled loading path. This does not alter existing benchmark rows or make PoliMorf part of the representative English JMH run. Any future full PoliMorf benchmark must provision its documented startup heap independently and record the exact model artifact version and checksum.
|
||||
|
||||
This page is the entry point for benchmark interpretation. Detailed tables and long reference material are split into focused subpages so that important points do not get buried.
|
||||
|
||||
## Key Takeaways
|
||||
@@ -40,3 +44,4 @@ The [English dictionary coverage benchmark](benchmarks/reference/english-coverag
|
||||
The current measured language results are published in [Language Benchmark Pages](benchmarks/languages/index.md). Generated local report files for this benchmark update are listed in [Benchmark environment and reports](benchmarks/reference/environment.md).
|
||||
|
||||
JMH TXT and CSV reports are still published as benchmark artifacts. They are no longer converted into a Shields endpoint benchmark badge.
|
||||
Model IDs, independent artifact versions, and descriptor checksums identify inputs for future reproducibility. Historical snapshots remain tied to the model inputs used when measured; the optional PoliMorf model must not be retroactively attributed to results that predate it. See [Model Selection and Loading](model-selection-and-loading.md) and [Reproducibility](benchmarks/reference/reproducibility.md).
|
||||
|
||||
@@ -4,7 +4,9 @@ This evaluation measures agreement between the relation predicted by a stemmer a
|
||||
|
||||
## Scope and fair-comparison rules
|
||||
|
||||
The authoritative Radixor language universe is the reconciled set of `stemmer.gz` resources under `src/main/resources` and `StemmerPatchTrieLoader.Language`. Radixor is evaluated for every reconciled language. A third-party adapter is evaluated only for languages supported by its tested implementation and having a compatible Radixor dictionary; unsupported combinations are absent rather than assigned zero quality.
|
||||
The authoritative Radixor language universe is the reconciliation of registered default model descriptors and `StemmerPatchTrieLoader.Language`. Radixor is evaluated for every reconciled language. Optional models are separate comparison rows. A third-party adapter is evaluated only for languages supported by its tested implementation and having a compatible Radixor dictionary; unsupported combinations are absent rather than assigned zero quality.
|
||||
|
||||
Model identity is part of the candidate identity. Default Polish means `pl-pl-unimorph`; optional PoliMorf means `pl-pl-polimorf`. Results for those inputs must not be combined or relabeled, and historical snapshots cannot acquire a newer model identity retroactively.
|
||||
|
||||
Within one language and dictionary mode, every adapter receives the same original included forms. Exact duplicates are removed only within one dictionary row. Identical surface forms in different rows remain distinct entries. Candidate strings use exact `String.equals`, with no evaluation-only lowercasing, normalization, accent removal, or gold-label-aware selection. Adapter preprocessing and lifecycle match the JMH comparison path.
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Benchmark Methodology
|
||||
|
||||
The stemmer comparison suite measures Radixor and Java stemmers on the same language and deterministic Radixor dictionary-derived data. Published Radixor rows in this refresh use contracted compiled patch tries, where uniform preferred-command subtrees are collapsed into accepting leaves before the trie is frozen for lookup. For each language, the bundled dictionary resource stores the expected root as the first tab-separated field on a line and its surface forms on the same line. Every single-token field on that line can therefore be paired with the same expected root.
|
||||
The stemmer comparison suite measures Radixor and Java stemmers on the same language and deterministic Radixor model dictionary-derived data. Published Radixor rows in this refresh use contracted compiled patch tries, where uniform preferred-command subtrees are collapsed into accepting leaves before the trie is frozen for lookup. For each language, the registered default model resource stores the expected root as the first tab-separated field on a line and its surface forms on the same line. Every single-token field on that line can therefore be paired with the same expected root.
|
||||
|
||||
Published stemmer comparison results must come only from benchmark classes matching `.*StemmerComparisonBenchmark.*`. Internal `FrequencyTrie*` microbenchmarks are not part of those results.
|
||||
|
||||
@@ -33,7 +33,7 @@ Radixor is measured over dictionary tokens from its own resources: lower-case wi
|
||||
|
||||
Lucene TokenFilter paths include required normalization in the measured pipeline. Examples include lower-case normalization for filters requiring lower-case input, German normalization before German light/minimal stemming, and Persian decimal, Arabic, and Persian normalization before Persian stemming. No ASCII folding is applied to Czech or Polish paths, because those Lucene stemmers are diacritic-aware or dictionary/table-backed for those languages. TokenFilter throughput methods materialize each emitted `CharTermAttribute` as a `String` before passing it to the JMH `Blackhole`, so output consumption is easier to inspect and closer to the direct stemmer methods.
|
||||
|
||||
For right-to-left Radixor languages, patch application uses the traversal direction stored in trie metadata. This is required because static backward patch application is not correct for all bundled languages.
|
||||
For right-to-left Radixor languages, patch application uses the traversal direction stored in trie metadata. This is required because static backward patch application is not correct for all registered language models.
|
||||
|
||||
## Quality Metric
|
||||
|
||||
@@ -57,3 +57,4 @@ Morfologik can emit multiple terms for one input token. The quality benchmark us
|
||||
Quality reports use JMH auxiliary counter rows. Exact-root accounting is deterministic for a fixed corpus and stemmer, so repeated measurement samples duplicate the same counters; documentation uses the counter ratios and does not interpret quality benchmark timing scores.
|
||||
|
||||
Pairwise over-stemming, under-stemming, candidate-aware policies, balanced accuracy, and partition comparison are a separate analytical evaluation. See [Linguistic Quality Methodology](linguistic-quality.md); exact-root accuracy must not be interpreted as the complement of pairwise under-stemming.
|
||||
Default rows use `Language.defaultModelId()`. Optional variants require a separate model field; `pl-pl-unimorph` and `pl-pl-polimorf` must never share an ambiguous Polish label. The benchmark runtime receives each resource exactly once from its individual model JAR through direct JMH runtime dependencies. See [Model Selection and Loading](../../model-selection-and-loading.md).
|
||||
|
||||
@@ -20,7 +20,8 @@ The CSV contains raw TP, FP, FN, and TN counts; raw over/under numerators and de
|
||||
./gradlew publishStemmingQualityDocumentation
|
||||
./gradlew verifyStemmingQualityDocumentation
|
||||
./gradlew test
|
||||
mkdocs build --strict
|
||||
./gradlew prepareMkDocsSource
|
||||
mkdocs build --strict --config-file build/mkdocs/mkdocs.yml
|
||||
```
|
||||
|
||||
`stemmingQuality` performs the expensive complete evaluation and is intentionally not attached to `test` or `check`. It prepares JMH third-party dependencies automatically and writes:
|
||||
@@ -34,6 +35,26 @@ Audit mode is enabled with `-PstemmingQualityAudit=true`. Language, stemmer, dic
|
||||
|
||||
`publishStemmingQualityDocumentation` validates the complete build CSV, copies a versioned documentation snapshot, and replaces only marked generated sections. `verifyStemmingQualityDocumentation` re-renders from the checked-in snapshot and fails on changed values, ordering, missing pages, duplicate keys, arithmetic inconsistencies, policy violations, or stale sections.
|
||||
|
||||
The model catalog and rendered site are build outputs under `build/`. They are generated for publication and are never maintained in Git.
|
||||
|
||||
For new measurements, record language, stable model ID, model artifact version, descriptor checksum, source dictionary identity/version, core revision, and benchmark configuration. JMH resolves the required default models and optional PoliMorf directly from their individual model JARs; these benchmark-only dependencies are not transitive to ordinary users.
|
||||
|
||||
Current model descriptors also record the official repository, dataset, license, attribution,
|
||||
verification date, transformations, and source-revision status. Exact historical revisions were
|
||||
not recorded for the legacy UniMorph imports; that limitation is disclosed with
|
||||
`not-recorded-in-legacy-import` rather than reconstructed. Future imports must record the exact
|
||||
upstream revision and source-archive checksum. This reproducibility limitation does not replace or
|
||||
weaken the packaged license and attribution requirements.
|
||||
|
||||
Each UniMorph-derived model artifact carries its own notice with the canonical CC BY-SA 3.0 URI,
|
||||
upstream attribution, transformations, ShareAlike statement, and Leo Galambos contribution notice.
|
||||
The full CC legal text is not duplicated or presented as a root-project license. PoliMorf retains
|
||||
its separately packaged BSD-2-Clause license.
|
||||
|
||||
For a future full PoliMorf measurement, also record the startup heap separately from benchmark parameters. Complete runtime construction is currently verified with a dedicated 6 GiB maximum heap; this limit is neither a retained-trie measurement nor a setting applied to ordinary JMH runs.
|
||||
|
||||
The Pages workflow publishes that staged documentation together with Javadoc, JUnit, PMD, JaCoCo, PIT, representative JMH, SBOM, optional dependency-check output, badge metadata, and retained build history. Its filesystem merge explicitly preserves the `builds/` tree in the separate `gh-pages` publication branch, so documentation regeneration cannot erase durable report URLs.
|
||||
|
||||
## Performance benchmark reproduction
|
||||
|
||||
The JMH comparison command family is:
|
||||
@@ -46,7 +67,7 @@ The exact JMH configuration, hardware, operating system, and JDK captured for th
|
||||
|
||||
## Recorded and unavailable provenance
|
||||
|
||||
The performance documentation records its 2026-07-06 environment, JDK 25.0.3, operating system, and hardware. The quality CSV records the evaluated identifiers and counts but does not embed the Radixor Git revision, generation date, JDK, operating system, dictionary content hash, or immutable upstream revisions for every downloaded source. These fields are explicitly unavailable for this snapshot and are not reconstructed from filesystem timestamps.
|
||||
The performance documentation records its 2026-07-06 environment, JDK 25.0.3, operating system, and hardware. The quality CSV records the evaluated identifiers and counts but does not embed the Radixor Git revision, generation date, JDK, operating system, model ID, dictionary content hash, or immutable upstream revisions for every downloaded source. These fields are explicitly unavailable for this historical snapshot and are not reconstructed from filesystem timestamps. In particular, the snapshot predates the optional PoliMorf integration and must not be relabeled as `pl-pl-polimorf`.
|
||||
|
||||
Dependency versions that are reproducible from repository configuration include Apache Lucene 10.5.0, Morfologik 2.1.9, the Ukrainian dictionary artifact 4.9.1, and JMH 1.37. Other upstream branches or downloaded dictionary revisions should be pinned and embedded in a future result schema.
|
||||
|
||||
@@ -59,3 +80,4 @@ Audit reports preserve original multilingual forms and identify high-contributin
|
||||
## JMH badge compatibility
|
||||
|
||||
The quality documentation generator does not invoke JMH, change JMH result formats, or modify badge tooling. Existing JMH result paths and historical badge-compatible inputs remain independent. The repository currently publishes coverage and mutation badge metadata and retains JMH TXT/CSV artifacts as documented in [Environment and reports](environment.md).
|
||||
See [Model Selection and Loading](../../model-selection-and-loading.md), [Stemmer Models](../../stemmer-models.md), and the generated [model catalog](../../stemmer-model-catalog.md) for current model identities.
|
||||
|
||||
@@ -4,7 +4,7 @@ The JMH adapter registry is authoritative for evaluated implementations and lang
|
||||
|
||||
| Family or implementation | Upstream / attribution | Tested version or revision | Evaluated scope | Output capability and adapter behaviour | Interpretation notes |
|
||||
| --- | --- | --- | --- | --- | --- |
|
||||
| Radixor | Egothor / Radixor project | Current repository revision; exact revision was not embedded in the quality CSV | All 20 reconciled Radixor dictionary languages; 19 have benchmark pages | Deterministic preferred patch via `get`; ranked distinct alternatives via `getAll`; primary is always included | Dictionary-derived compiled patch trie. Quality depends on dictionary coverage and annotation. |
|
||||
| Radixor | Egothor / Radixor project | Current repository revision; exact revision was not embedded in the quality CSV | All 20 reconciled default model languages; 19 have benchmark pages | Deterministic preferred patch via `get`; ranked distinct alternatives via `getAll`; primary is always included | Model-dictionary-derived compiled patch trie. Default rows use each language's stable default model ID. |
|
||||
| Apache Lucene language stem filters | Apache Lucene project | 10.5.0 | Adapter-declared language-specific subsets | TokenFilter lifecycle and language normalization match JMH; normally single-output | Light, minimal, possessive, and language stem filters deliberately implement different scopes. Narrow scope is not a defect. |
|
||||
| Apache Lucene SnowballFilter | Apache Lucene project using Snowball algorithms | Lucene 10.5.0 | Snowball-supported subset of Radixor languages | Single primary token emitted through the Lucene TokenFilter path | Includes TokenStream overhead and required normalization. |
|
||||
| Official Snowball Java | Snowball project | Repository preparation downloads the configured upstream Java distribution; an immutable revision was not recorded in the quality CSV | Same-language adapter subset | Direct generated Java API; single output | Rule-based suffix algorithms provide broad baselines rather than dictionary-root guarantees. |
|
||||
@@ -24,6 +24,7 @@ Candidate sets are non-null, non-empty, contain the deterministic primary output
|
||||
|
||||
## Coverage fairness
|
||||
|
||||
Radixor coverage is derived independently from its resources and language enumeration. Third-party coverage is the intersection of that universe with actual adapter support. Absence therefore means “not supported or not configured for this language,” not “zero quality.” Consult each language page for the exact evaluated rows.
|
||||
Radixor coverage is derived from registered default descriptors reconciled with language enumeration. Third-party coverage is the intersection of that universe with actual adapter support. Absence therefore means “not supported or not configured for this language,” not “zero quality.” Optional `pl-pl-polimorf` is a separate model row and does not replace default `pl-pl-unimorph`. Consult each language page for the exact evaluated rows.
|
||||
|
||||
Project authors and organizations are named only where repository configuration or source notices establish attribution. No broader authorship or license claim is inferred when metadata was not captured.
|
||||
The JMH runtime configuration directly includes optional models needed for controlled comparisons; ordinary users do not receive these benchmark-only dependencies transitively. Historical rows retain their original model inputs. See [Model Selection and Loading](../../model-selection-and-loading.md).
|
||||
|
||||
@@ -1,267 +1,104 @@
|
||||
# Built-in Languages
|
||||
# Built-in Languages and Default Models
|
||||
|
||||
Radixor ships with a curated set of bundled stemmer dictionaries that can be loaded directly from the library distribution. These resources are intended to provide an immediately usable baseline for evaluation, prototyping, integration, and general-purpose stemming workloads, while still fitting naturally into workflows where the bundled baseline is later refined, extended, or replaced with custom lexical data.
|
||||
“Supported language” means that Radixor defines a language enum value and publishes a corresponding default model artifact. It does not mean that a dictionary is embedded in the core JAR. Applications add model artifacts explicitly or use the optional standard pack.
|
||||
|
||||
## Overview
|
||||
The language enum carries language identity, writing direction, a legacy resource-directory name, and the stable default model ID. A model descriptor carries the independently versioned model identity and resource. See [Model Selection and Loading](model-selection-and-loading.md) for the API and the generated [model catalog](stemmer-model-catalog.md) for versions, provenance, checksums, and sizes.
|
||||
|
||||
Bundled dictionaries are exposed through:
|
||||
## Defaults and variants
|
||||
|
||||
```java
|
||||
org.egothor.stemmer.StemmerPatchTrieLoader.Language
|
||||
```
|
||||
| Language | Enum | Default model ID | Default artifact | Optional variants |
|
||||
|---|---|---|---|---|
|
||||
| Czech | `CS_CZ` | `cs-cz-default` | `org.egothor:radixor-model-cs-cz-default` | — |
|
||||
| Danish | `DA_DK` | `da-dk-default` | `org.egothor:radixor-model-da-dk-default` | — |
|
||||
| German | `DE_DE` | `de-de-default` | `org.egothor:radixor-model-de-de-default` | — |
|
||||
| Spanish | `ES_ES` | `es-es-default` | `org.egothor:radixor-model-es-es-default` | — |
|
||||
| Persian | `FA_IR` | `fa-ir-default` | `org.egothor:radixor-model-fa-ir-default` | — |
|
||||
| Finnish | `FI_FI` | `fi-fi-default` | `org.egothor:radixor-model-fi-fi-default` | — |
|
||||
| French | `FR_FR` | `fr-fr-default` | `org.egothor:radixor-model-fr-fr-default` | — |
|
||||
| Hebrew | `HE_IL` | `he-il-default` | `org.egothor:radixor-model-he-il-default` | — |
|
||||
| Hungarian | `HU_HU` | `hu-hu-default` | `org.egothor:radixor-model-hu-hu-default` | — |
|
||||
| Italian | `IT_IT` | `it-it-default` | `org.egothor:radixor-model-it-it-default` | — |
|
||||
| Norwegian Bokmål | `NB_NO` | `nb-no-default` | `org.egothor:radixor-model-nb-no-default` | — |
|
||||
| Dutch | `NL_NL` | `nl-nl-default` | `org.egothor:radixor-model-nl-nl-default` | — |
|
||||
| Norwegian Nynorsk | `NN_NO` | `nn-no-default` | `org.egothor:radixor-model-nn-no-default` | — |
|
||||
| Polish | `PL_PL` | `pl-pl-unimorph` | `org.egothor:radixor-model-pl-pl-unimorph` | `pl-pl-polimorf` / `org.egothor:radixor-model-pl-pl-polimorf` |
|
||||
| Portuguese | `PT_PT` | `pt-pt-default` | `org.egothor:radixor-model-pt-pt-default` | — |
|
||||
| Russian | `RU_RU` | `ru-ru-default` | `org.egothor:radixor-model-ru-ru-default` | — |
|
||||
| Swedish | `SV_SE` | `sv-se-default` | `org.egothor:radixor-model-sv-se-default` | — |
|
||||
| Ukrainian | `UK_UA` | `uk-ua-default` | `org.egothor:radixor-model-uk-ua-default` | — |
|
||||
| English | `US_UK` | `us-uk-default` | `org.egothor:radixor-model-us-uk-default` | — |
|
||||
| Yiddish | `YI` | `yi-default` | `org.egothor:radixor-model-yi-default` | — |
|
||||
|
||||
Each bundled dictionary is packaged with the library as a compressed UTF-8 text resource. When loaded through the runtime API, the resource is parsed by `StemmerDictionaryParser`, transformed into patch-command mappings, and compiled into a read-only `FrequencyTrie<CompiledPatchCommand>` by `StemmerPatchTrieLoader`.
|
||||
The maintained table deliberately avoids duplicating mutable provenance and checksum fields. Those values come from module metadata and are generated into the model catalog.
|
||||
|
||||
The bundled language definition also carries a language-level right-to-left flag. That flag is used by the loader to derive the `WordTraversalDirection` used for both trie-key construction and patch-command generation. In practice, left-to-right bundled languages use historical backward Egothor traversal, while right-to-left bundled languages use forward traversal over the stored form.
|
||||
## The Polish dual-model case
|
||||
|
||||
## Supported bundled languages
|
||||
`PL_PL` represents Polish. It is not an alias for either source dictionary.
|
||||
|
||||
The following bundled language identifiers are currently available:
|
||||
- `loadCompiled(Language.PL_PL, ...)` resolves `pl-pl-unimorph`.
|
||||
- `registry.require("pl-pl-polimorf")` resolves the optional PoliMorf model.
|
||||
- `StemmerPatchTrieLoader.loadCompiled("pl-pl-polimorf", true, reductionMode)` constructs its compiled trie explicitly; complete construction is verified with a dedicated 6 GiB test heap.
|
||||
- Both artifacts may be present and loaded independently.
|
||||
- Adding PoliMorf does not change the language default.
|
||||
- Radixor does not merge their dictionaries or outputs automatically.
|
||||
|
||||
| Language | Enum constant | Writing direction | Notes | Benchmark page |
|
||||
|---|---|---:|---|---|
|
||||
| Czech | `CS_CZ` | LTR | Bundled general-purpose dictionary | [Czech](benchmarks/languages/czech.md) |
|
||||
| Danish | `DA_DK` | LTR | Bundled general-purpose dictionary | [Danish](benchmarks/languages/danish.md) |
|
||||
| German | `DE_DE` | LTR | Bundled general-purpose dictionary | [German](benchmarks/languages/german.md) |
|
||||
| Spanish | `ES_ES` | LTR | Bundled general-purpose dictionary | [Spanish](benchmarks/languages/spanish.md) |
|
||||
| Persian | `FA_IR` | RTL | Bundled dictionary uses forward traversal over the stored form | [Persian](benchmarks/languages/persian.md) |
|
||||
| Finnish | `FI_FI` | LTR | Bundled general-purpose dictionary | [Finnish](benchmarks/languages/finnish.md) |
|
||||
| French | `FR_FR` | LTR | Bundled general-purpose dictionary | [French](benchmarks/languages/french.md) |
|
||||
| Hebrew | `HE_IL` | RTL | Bundled dictionary uses forward traversal over the stored form | No same-language external benchmark in this run |
|
||||
| Hungarian | `HU_HU` | LTR | Bundled general-purpose dictionary | [Hungarian](benchmarks/languages/hungarian.md) |
|
||||
| Italian | `IT_IT` | LTR | Bundled general-purpose dictionary | [Italian](benchmarks/languages/italian.md) |
|
||||
| Norwegian Bokmål | `NB_NO` | LTR | Bundled general-purpose dictionary | [Norwegian Bokmal](benchmarks/languages/norwegian-bokmal.md) |
|
||||
| Dutch | `NL_NL` | LTR | Bundled general-purpose dictionary | [Dutch](benchmarks/languages/dutch.md) |
|
||||
| Norwegian Nynorsk | `NN_NO` | LTR | Bundled general-purpose dictionary | [Norwegian Nynorsk](benchmarks/languages/norwegian-nynorsk.md) |
|
||||
| Polish | `PL_PL` | LTR | Bundled general-purpose dictionary | [Polish](benchmarks/languages/polish.md) |
|
||||
| Portuguese | `PT_PT` | LTR | Bundled general-purpose dictionary | [Portuguese](benchmarks/languages/portuguese.md) |
|
||||
| Russian | `RU_RU` | LTR | Bundled general-purpose dictionary | [Russian](benchmarks/languages/russian.md) |
|
||||
| Swedish | `SV_SE` | LTR | Bundled general-purpose dictionary | [Swedish](benchmarks/languages/swedish.md) |
|
||||
| Ukrainian | `UK_UA` | LTR | Bundled general-purpose dictionary | [Ukrainian](benchmarks/languages/ukrainian.md) |
|
||||
| English | `US_UK` | LTR | Bundled general-purpose dictionary | [English](benchmarks/languages/english.md) |
|
||||
| Yiddish | `YI` | RTL | Bundled dictionary uses forward traversal over the stored form | [Yiddish](benchmarks/languages/yiddish.md) |
|
||||
UniMorph and PoliMorf have different lexical sources and provenance. Applications should compare outputs with application-specific regression tests before changing an explicit model choice.
|
||||
|
||||
## Basic usage
|
||||
## Dependency patterns
|
||||
|
||||
Load a bundled dictionary like this:
|
||||
Minimal English:
|
||||
|
||||
```java
|
||||
import java.io.IOException;
|
||||
|
||||
import org.egothor.stemmer.CompiledPatchCommand;
|
||||
import org.egothor.stemmer.FrequencyTrie;
|
||||
import org.egothor.stemmer.ReductionMode;
|
||||
import org.egothor.stemmer.StemmerPatchTrieLoader;
|
||||
|
||||
public final class BuiltInExample {
|
||||
|
||||
private BuiltInExample() {
|
||||
throw new AssertionError("No instances.");
|
||||
}
|
||||
|
||||
public static void main(final String[] arguments) throws IOException {
|
||||
final FrequencyTrie<CompiledPatchCommand> trie = StemmerPatchTrieLoader.loadCompiled(
|
||||
StemmerPatchTrieLoader.Language.US_UK,
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
|
||||
System.out.println(trie.traversalDirection());
|
||||
}
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-model-us-uk-default:1.0.0'
|
||||
}
|
||||
```
|
||||
|
||||
This call loads the bundled dictionary resource for the selected language, parses its lexical entries, derives patch-command mappings, and compiles the result into a read-only trie.
|
||||
All documented defaults:
|
||||
|
||||
## Example: stemming with a bundled dictionary
|
||||
|
||||
```java
|
||||
import java.io.IOException;
|
||||
|
||||
import org.egothor.stemmer.CompiledPatchCommand;
|
||||
import org.egothor.stemmer.FrequencyTrie;
|
||||
import org.egothor.stemmer.ReductionMode;
|
||||
import org.egothor.stemmer.StemmerPatchTrieLoader;
|
||||
|
||||
public final class EnglishExample {
|
||||
|
||||
private EnglishExample() {
|
||||
throw new AssertionError("No instances.");
|
||||
}
|
||||
|
||||
public static void main(final String[] arguments) throws IOException {
|
||||
final FrequencyTrie<CompiledPatchCommand> trie = StemmerPatchTrieLoader.loadCompiled(
|
||||
StemmerPatchTrieLoader.Language.US_UK,
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
|
||||
final String word = "running";
|
||||
final CompiledPatchCommand patch = trie.get(word);
|
||||
final String stem = patch == null ? word : patch.apply(word);
|
||||
|
||||
System.out.println(word + " -> " + stem);
|
||||
}
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-models-standard:<catalog-version>'
|
||||
}
|
||||
```
|
||||
|
||||
`CompiledPatchCommand` values are compiled with the traversal direction used when the trie and its patch commands were produced.
|
||||
The standard pack is metadata-only and excludes optional PoliMorf.
|
||||
|
||||
## Traversal behavior and right-to-left languages
|
||||
Every individual model artifact carries its own provenance and licensing material. UniMorph
|
||||
models carry different model-specific CC BY-SA 3.0 notices because their official language
|
||||
repositories identify different lexical sources and contributors. Each notice preserves upstream
|
||||
attribution and records the Radixor transformations and Leo Galambos contribution statement.
|
||||
Legacy imports disclose when an exact historical revision was not recorded; this is a
|
||||
reproducibility limitation, not a claim that the source or license is unknown.
|
||||
|
||||
Bundled dictionaries are not all processed identically.
|
||||
|
||||
For traditional left-to-right suffix-oriented resources, Radixor preserves historical Egothor behavior and traverses logical word characters backward. That means trie paths are constructed from the logical end of the stored word toward its beginning, and patch commands are interpreted with the same backward traversal model.
|
||||
|
||||
For bundled right-to-left languages such as Persian, Hebrew, and Yiddish, Radixor uses forward traversal over the stored form. In those cases:
|
||||
|
||||
- trie keys are traversed from the logical beginning of the stored form,
|
||||
- patch commands are generated in that same forward direction,
|
||||
- compiled patch-command application uses `WordTraversalDirection.FORWARD`, which is naturally captured when `loadCompiled(...)` creates `CompiledPatchCommand` values.
|
||||
|
||||
This design keeps the traversal policy explicit and consistent across dictionary loading, trie lookup, binary persistence, builder reconstruction, and patch application.
|
||||
|
||||
## Reduction behavior
|
||||
|
||||
Bundled dictionaries can be compiled using any supported `ReductionMode`. The reduction configuration controls how semantically equivalent subtrees are merged during trie compilation, while preserving the contract of the selected mode.
|
||||
|
||||
Typical entry points are:
|
||||
|
||||
- `StemmerPatchTrieLoader.loadCompiled(language, storeOriginal, reductionMode)`
|
||||
- `StemmerPatchTrieLoader.loadCompiled(language, storeOriginal, reductionSettings)`
|
||||
|
||||
For most users, `ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS` is the most conservative general-purpose choice because it preserves ranked `getAll(...)` behavior.
|
||||
|
||||
Compiled bundled dictionaries also use internal uniform-subtree contraction. If a whole subtree
|
||||
would return the same preferred patch command, Radixor stores that subtree as an accepting leaf and
|
||||
removes the deeper branches. This is the contracted trie representation used by the published
|
||||
benchmark tables and is independent of the public reduction mode selected by the caller.
|
||||
|
||||
## Intended role of bundled dictionaries
|
||||
|
||||
Bundled dictionaries should be understood as practical default resources.
|
||||
|
||||
They are a good fit when:
|
||||
|
||||
- a supported language is already available,
|
||||
- immediate usability matters,
|
||||
- a reasonable baseline is sufficient,
|
||||
- the goal is evaluation, prototyping, or straightforward integration.
|
||||
|
||||
They are also well suited to staged refinement workflows in which a bundled base is loaded first, then extended with domain-specific vocabulary, and finally persisted as a custom binary artifact.
|
||||
|
||||
## Character representation
|
||||
|
||||
Bundled dictionaries are ordinary UTF-8 lexical resources. The parser reads them as text, the trie stores standard Java strings, and the patch-command model operates on general character sequences.
|
||||
|
||||
This is important for two reasons:
|
||||
|
||||
1. the built-in resources are not limited to ASCII-only processing,
|
||||
2. the traversal model is orthogonal to character encoding and script choice.
|
||||
|
||||
In other words, right-to-left handling in the loader is about logical traversal strategy, not about introducing a separate character model.
|
||||
|
||||
## When to prefer custom dictionaries
|
||||
|
||||
A custom dictionary is usually the better choice when:
|
||||
|
||||
- domain-specific vocabulary materially affects stemming quality,
|
||||
- lexical coverage must be controlled more precisely,
|
||||
- a stronger lexical resource is available than the bundled baseline,
|
||||
- operational requirements demand an explicitly curated, versioned artifact.
|
||||
|
||||
Typical examples include:
|
||||
|
||||
- technical terminology,
|
||||
- biomedical language,
|
||||
- legal or financial vocabulary,
|
||||
- organization-specific product and process names,
|
||||
- dictionaries maintained with project-specific validation rules.
|
||||
|
||||
## Production recommendation
|
||||
|
||||
For production systems, the most robust workflow is usually:
|
||||
|
||||
1. start from a bundled dictionary when it is suitable,
|
||||
2. extend it with domain-specific forms if needed,
|
||||
3. rebuild it into a binary artifact,
|
||||
4. deploy that compiled binary artifact,
|
||||
5. load it at runtime through `loadBinaryCompiled(...)`.
|
||||
|
||||
This avoids repeated startup parsing and makes the deployed stemming behavior explicit, reproducible, and versionable.
|
||||
|
||||
## Example refinement workflow
|
||||
## Loading a language default
|
||||
|
||||
```java
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import org.egothor.stemmer.FrequencyTrie;
|
||||
import org.egothor.stemmer.FrequencyTrieBuilders;
|
||||
import org.egothor.stemmer.PatchCommandEncoder;
|
||||
import org.egothor.stemmer.ReductionMode;
|
||||
import org.egothor.stemmer.ReductionSettings;
|
||||
import org.egothor.stemmer.StemmerPatchTrieBinaryIO;
|
||||
import org.egothor.stemmer.StemmerPatchTrieLoader;
|
||||
|
||||
public final class BundledRefinementExample {
|
||||
|
||||
private BundledRefinementExample() {
|
||||
throw new AssertionError("No instances.");
|
||||
}
|
||||
|
||||
public static void main(final String[] arguments) throws IOException {
|
||||
final FrequencyTrie<String> base = StemmerPatchTrieLoader.load(
|
||||
final FrequencyTrie<CompiledPatchCommand> trie =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
StemmerPatchTrieLoader.Language.US_UK,
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
|
||||
final FrequencyTrie.Builder<String> builder = FrequencyTrieBuilders.copyOf(
|
||||
base,
|
||||
String[]::new,
|
||||
ReductionSettings.withDefaults(
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS));
|
||||
|
||||
final PatchCommandEncoder encoder = PatchCommandEncoder.builder()
|
||||
.traversalDirection(base.traversalDirection())
|
||||
.build();
|
||||
|
||||
builder.put("microservices", encoder.encode("microservices", "microservice"));
|
||||
|
||||
final FrequencyTrie<String> compiled = builder.build();
|
||||
|
||||
StemmerPatchTrieBinaryIO.write(compiled, Path.of("english-custom.radixor.gz"));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The reconstructed builder preserves the traversal direction of the source trie, so refinements remain semantically aligned with the original bundled dictionary.
|
||||
The call discovers the default descriptor from the runtime classpath, verifies its compressed resource, parses the GZip UTF-8 dictionary, and constructs a read-only trie. A missing default throws `StemmerModelNotFoundException`; there is no arbitrary fallback.
|
||||
|
||||
## Extending language support
|
||||
## Writing direction
|
||||
|
||||
The built-in set is intentionally a practical baseline rather than a closed catalog. Additional languages, stronger lexical coverage, and improved dictionaries for currently supported languages are all natural extension paths.
|
||||
Persian, Hebrew, and Yiddish declare right-to-left language metadata and use forward traversal over stored forms. Other defaults use historical backward Egothor traversal. This setting must remain aligned across dictionary parsing, trie lookup, patch generation, persistence, and application. Model identity remains separate from writing direction.
|
||||
|
||||
What matters most is not only the number of entries, but the quality, consistency, maintainability, and operational usefulness of the lexical resource being added.
|
||||
## Custom and persisted alternatives
|
||||
|
||||
## Related API surface
|
||||
Registered model artifacts are a convenient reproducible baseline. Applications may instead load caller-owned textual dictionaries or persist compiled `.radixor.gz` tries. Those paths are distinct from model artifact discovery:
|
||||
|
||||
The following types are typically involved when working with bundled dictionaries:
|
||||
- a model `stemmer.gz` is a compressed textual dictionary plus descriptor/index metadata;
|
||||
- a `.radixor.gz` created by the binary writer is a persisted compiled trie;
|
||||
- a source dictionary is upstream input, not automatically a valid model artifact.
|
||||
|
||||
- `StemmerPatchTrieLoader`
|
||||
- `StemmerPatchTrieLoader.Language`
|
||||
- `FrequencyTrie`
|
||||
- `PatchCommandEncoder`
|
||||
- `WordTraversalDirection`
|
||||
- `ReductionMode`
|
||||
- `ReductionSettings`
|
||||
- `StemmerPatchTrieBinaryIO`
|
||||
- `FrequencyTrieBuilders`
|
||||
See [Dictionary Format](dictionary-format.md), [CLI Compilation](cli-compilation.md), and [Stemmer Models](stemmer-models.md).
|
||||
|
||||
## Next steps
|
||||
## Benchmark interpretation
|
||||
|
||||
- [Quick start](quick-start.md)
|
||||
- [Dictionary format](dictionary-format.md)
|
||||
- [CLI compilation](cli-compilation.md)
|
||||
- [Programmatic usage](programmatic-usage.md)
|
||||
|
||||
## Summary
|
||||
|
||||
Radixor’s built-in language support provides immediate usability, a professionally defined baseline API, and a practical starting point for custom refinement. The bundled set now includes both left-to-right and right-to-left languages, and the library models that distinction explicitly through `WordTraversalDirection` so that trie construction, lookup, and patch application remain consistent.
|
||||
Benchmark rows must identify the Radixor model ID used. Default rows use the default IDs above. Optional Polish PoliMorf comparisons must be labeled `pl-pl-polimorf`; they are not interchangeable with the historical default Polish row. Continue with [Benchmarking](benchmarking.md) and [Reproducibility](benchmarks/reference/reproducibility.md).
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
Radixor provides a command-line compiler for turning line-oriented dictionary files into compact binary stemmer artifacts.
|
||||
|
||||
The CLI output is not a model JAR. A model artifact contains a compressed textual dictionary, descriptor, index, checksum, and license so the runtime registry can discover and compile it. The CLI instead emits an already compiled binary trie for direct `loadBinaryCompiled(...)` use. Choose the model-module workflow when independently published classpath discovery is required; choose the CLI when the application owns a compiled binary asset.
|
||||
|
||||
This is the preferred preparation workflow when stemming should run against an already compiled artifact rather than against raw dictionary input. The CLI reads the dictionary, derives patch commands, builds a mutable trie, applies the selected subtree reduction strategy, and writes the final compiled trie in the project binary format under GZip compression. The result is a deployment-ready `.radixor.gz` file that can be loaded directly by application code.
|
||||
|
||||
## What the CLI does
|
||||
@@ -17,6 +19,10 @@ The `Compile` tool performs the following steps:
|
||||
|
||||
This workflow is intentionally aligned with the same dictionary semantics used elsewhere in the library. Remarks introduced by `#` or `//` are supported through the shared dictionary parser.
|
||||
|
||||
## Create a registered custom model instead
|
||||
|
||||
To publish or deploy a custom dictionary through `StemmerModelRegistry`, do not merely rename CLI output to `stemmer.gz`. Create `models/<model-id>`, preserve the textual dictionary as a GZip module input, provide source metadata and a license, apply `org.egothor.radixor.model`, and run the model validation tasks. The resulting JAR has an index, descriptor, namespaced textual dictionary, checksum, and license. Detailed packaging is documented in [Stemmer Models](stemmer-models.md); selection is documented in [Model Selection and Loading](model-selection-and-loading.md).
|
||||
|
||||
## Basic usage
|
||||
|
||||
```bash
|
||||
@@ -220,6 +226,8 @@ The ranked `getAll()` mode is the safest default. The unordered and dominant mod
|
||||
|
||||
Compilation is usually a one-time step and is generally fast. The more important operational consideration is memory usage during preparation, because the dictionary-derived mutable structure exists before reduction compacts it into the final read-only trie. This is especially relevant for very large source dictionaries.
|
||||
|
||||
The complete PoliMorf model is the current exceptional case: registered-model verification uses `runtimeModelIntegrationTest` with a 6 GiB maximum heap, configurable through `-PradixorLargeModelMaxHeap=<size>`. This setting applies only to that isolated test process, not the Gradle daemon or ordinary tests.
|
||||
|
||||
## Example workflow
|
||||
|
||||
### 1. Prepare a dictionary
|
||||
@@ -282,3 +290,5 @@ The CLI and the programmatic API implement the same conceptual preparation step.
|
||||
- [Quick start](quick-start.md)
|
||||
- [Programmatic usage](programmatic-usage.md)
|
||||
- [Architecture and reduction](architecture-and-reduction.md)
|
||||
!!! note "Radixor 4 model artifacts"
|
||||
Language dictionaries are independently versioned runtime model artifacts, not resources embedded in `radixor`. Language-based APIs resolve deterministic defaults through `StemmerModelRegistry`; see [Stemmer Models](stemmer-models.md).
|
||||
|
||||
@@ -37,7 +37,7 @@ This API is expected to remain supportable across future versions. The preferred
|
||||
|
||||
Examples of likely additive evolution include:
|
||||
|
||||
- additional bundled language resources,
|
||||
- additional independently versioned language models,
|
||||
- fuller support for diacritics or native-script language resources,
|
||||
- expanded documentation and operational tooling,
|
||||
- new convenience methods that do not break existing code.
|
||||
@@ -83,6 +83,8 @@ Compiled `FrequencyTrie` instances are immutable and thread-safe for concurrent
|
||||
|
||||
Serialized patch-command strings remain the stable stored representation used by textual dictionaries and binary artifacts. Runtime stemming should use `CompiledPatchCommand` values produced by `StemmerPatchTrieLoader.loadCompiled(...)`, `StemmerPatchTrieLoader.loadBinaryCompiled(...)`, or `PatchCommandEncoder.compile(...)`.
|
||||
|
||||
Language-default, descriptor, and stable model-ID `loadCompiled` entry points share the same compiled-value conversion. Explicit model IDs never fall back to a language default. Model loading is not cached, and construction-memory requirements are model-dependent; the unusually large PoliMorf input is verified separately with a 6 GiB maximum heap.
|
||||
|
||||
The historical `PatchCommandEncoder.apply(...)` and String-based `applyTo(...)` overloads remain compatibility APIs during the 2.x transition, but they are deprecated because they reparse the patch-command string on each application. See [Migration and Backward Compatibility](migration-and-backward-compatibility.md) for old and new code examples.
|
||||
|
||||
Compiled buffer-oriented `CompiledPatchCommand.applyTo(...)` overloads use caller-owned output storage. They do not retain output arrays and report insufficient capacity with `CompiledPatchCommand.APPLY_INSUFFICIENT_CAPACITY`.
|
||||
@@ -110,7 +112,7 @@ The following kinds of change are generally compatible with the project’s dire
|
||||
|
||||
- improved internal data structures,
|
||||
- changes inside `org.egothor.stemmer.trie`,
|
||||
- expanded bundled dictionaries,
|
||||
- expanded model dictionaries,
|
||||
- additional supported languages,
|
||||
- improved native-script handling,
|
||||
- better benchmarks, tests, and reports,
|
||||
@@ -122,11 +124,11 @@ The project should be able to improve substantially while keeping the main user-
|
||||
|
||||
Some areas should be treated as stable in intent but still approached carefully when changed.
|
||||
|
||||
### Bundled dictionary contents
|
||||
### Independently versioned model contents
|
||||
|
||||
Bundled resources are versioned project data, not immutable language standards. Their contents may improve over time.
|
||||
Model resources are independently versioned project data, not immutable language standards. Their contents may improve over time.
|
||||
|
||||
That means stemming outcomes can legitimately change when bundled dictionaries are refined or expanded. Such changes are compatible with the project’s direction, but they should still be understood as behavior changes at the lexical-resource level.
|
||||
That means stemming outcomes can legitimately change when a model artifact is updated. Such changes are separate from core compatibility and should be reviewed as lexical-resource behavior changes.
|
||||
|
||||
### Binary format evolution
|
||||
|
||||
@@ -159,7 +161,7 @@ Users should avoid depending on:
|
||||
- internal trie package details,
|
||||
- undocumented internal classes or intermediate representations,
|
||||
- incidental internal ordering outside documented lookup semantics,
|
||||
- assumptions that bundled dictionary contents will never evolve,
|
||||
- assumptions that a model's dictionary contents will never evolve across model versions,
|
||||
- assumptions that internal binary-format details are frozen forever.
|
||||
|
||||
If a behavior is important to your integration, it should ideally be documented at the public API or project-documentation level rather than inferred from internal implementation details.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
High-quality dictionaries are one of the most valuable ways to improve **Radixor**.
|
||||
|
||||
The project already includes practical bundled dictionaries for common use, but the long-term quality and language reach of the stemmer depend heavily on the quality of its lexical resources. Contributions are therefore welcome not only in the form of code changes, but also in the form of well-prepared dictionary data for existing or additional languages.
|
||||
The project already publishes practical model dictionaries for common use, but long-term quality and language reach depend heavily on lexical-resource quality. Contributions may provide well-prepared model inputs for existing or additional languages.
|
||||
|
||||
This document explains what makes a dictionary contribution useful, how to structure it, and how to prepare it so that it integrates cleanly with the project.
|
||||
|
||||
@@ -52,7 +52,7 @@ For full format details, see [Dictionary format](dictionary-format.md).
|
||||
|
||||
The most useful dictionary contributions generally fall into one of four categories.
|
||||
|
||||
### 1. Stronger dictionaries for already bundled languages
|
||||
### 1. Stronger models for already supported languages
|
||||
|
||||
Improving lexical quality for already supported languages is often more valuable than merely expanding the language list. Better coverage, cleaner canonicalization, and improved consistency directly improve practical stemming outcomes.
|
||||
|
||||
@@ -68,7 +68,7 @@ That convention belongs to the supplied dictionaries, not to the underlying algo
|
||||
|
||||
### 4. Domain-quality refinements
|
||||
|
||||
Some contributions may be more appropriate as curated domain extensions than as replacements for a general-purpose bundled dictionary. These are still useful when they are clearly scoped and operationally coherent.
|
||||
Some contributions may be more appropriate as curated domain extensions than as replacements for a general-purpose default model. These are still useful when clearly scoped and operationally coherent.
|
||||
|
||||
## Normalization guidance
|
||||
|
||||
@@ -139,6 +139,14 @@ A dictionary should read like a curated lexical resource, not like an unfiltered
|
||||
|
||||
## Practical preparation workflow
|
||||
|
||||
Before conversion, record the official source project and repository, exact revision or release,
|
||||
source-archive checksum, retrieval date, dataset license and URI, supplied attribution, and any
|
||||
required upstream notice. Add a model-specific notice describing every material transformation and
|
||||
the license applied to the derived data, including its canonical URI. Record any protectable
|
||||
Radixor-specific contribution without claiming ownership over the upstream data. A legacy model
|
||||
may disclose that its historical revision was not recorded; new imports must record an exact
|
||||
revision and source-archive checksum rather than using that sentinel.
|
||||
|
||||
A disciplined dictionary contribution should typically follow this path:
|
||||
|
||||
1. prepare or normalize the lexical source,
|
||||
@@ -183,7 +191,7 @@ This note does not need to be long. It simply needs to make the resource intelli
|
||||
|
||||
## Bundled-resource expectations
|
||||
|
||||
Not every useful dictionary must automatically become a bundled language resource.
|
||||
Not every useful dictionary must automatically become a published default model.
|
||||
|
||||
To be suitable for bundling, a dictionary should generally be:
|
||||
|
||||
|
||||
@@ -2,6 +2,27 @@
|
||||
|
||||
Radixor uses a simple line-oriented dictionary format designed for practical stemming workflows. The textual source format is tab-separated values, meaning that columns are separated by the tab character.
|
||||
|
||||
## Source text, model resource, and compiled trie
|
||||
|
||||
Three artifacts must not be confused:
|
||||
|
||||
| Artifact | Representation | Consumer |
|
||||
|---|---|---|
|
||||
| Source textual dictionary | Plain UTF-8 tab-separated rows | Authors, parser, CLI, or model preparation |
|
||||
| Registered model resource | The same Radixor dictionary bytes under GZip, accompanied by index, descriptor, checksum, and license | `StemmerModelRegistry` and `StemmerPatchTrieLoader` |
|
||||
| Persisted compiled trie | GZip-compressed Radixor binary format, commonly `.radixor.gz` | `loadBinaryCompiled(...)` |
|
||||
|
||||
The model file named `stemmer.gz` is not Java serialization and is not a pre-instantiated or persisted trie. It is compressed textual dictionary input parsed when the model is loaded.
|
||||
|
||||
Consequently, compressed size is not a construction-memory estimate. The PoliMorf resource is 12,624,997 bytes compressed and 68,093,680 bytes decompressed, while full parsing, trie construction, reduction, and patch compilation require a dedicated verification JVM with a 6 GiB maximum heap.
|
||||
|
||||
Comment headers in maintained model inputs summarize provenance but do not replace packaged legal
|
||||
material. Each UniMorph-derived artifact includes a language-specific notice describing its
|
||||
official repository, lexical source, upstream attribution, CC BY-SA 3.0 canonical URI, ShareAlike
|
||||
status, Radixor transformations, and Leo Galambos's protectable model-data contributions. The
|
||||
notice does not claim ownership over the underlying data. GZip packaging and descriptor/checksum
|
||||
generation are disclosed transformations; the in-memory trie is a Radixor runtime structure.
|
||||
|
||||
Each logical line describes one canonical stem and zero or more known word variants that should reduce to that stem. The format is intentionally lightweight, easy to maintain in source control, and directly consumable both by the programmatic loader and by the CLI compiler.
|
||||
|
||||
## Core structure
|
||||
@@ -129,7 +150,11 @@ run running runs ran
|
||||
|
||||
## Character set, compression, and normalization
|
||||
|
||||
Dictionary files are read as UTF-8 text. Files loaded through `StemmerPatchTrieLoader.load(Path, ...)` may be either plain UTF-8 text or GZip-compressed UTF-8 text; the loader detects GZip input from the stream header instead of relying on the file extension. Bundled dictionaries are stored as GZip resources and are decoded as UTF-8 after decompression.
|
||||
Dictionary files are read as UTF-8 text. Files loaded through `StemmerPatchTrieLoader.load(Path, ...)` may be either plain UTF-8 text or GZip-compressed UTF-8 text; the loader detects GZip input from the stream header instead of relying on the file extension. Registered model dictionaries are stored as GZip resources and are decoded as UTF-8 after decompression.
|
||||
|
||||
## Turn a dictionary into a model artifact
|
||||
|
||||
An arbitrary classpath copy is not a discoverable model. A model module places immutable input and its license under `models/<model-id>/src/modelInput/`, declares metadata and an independent version, and applies the model convention plugin. The build validates the input, copies identical bytes into a generated namespaced resource, generates `META-INF/radixor/models.index` and a descriptor, records SHA-256, and packages licensing material. See [Stemmer Models](stemmer-models.md#create-or-update-a-model-module) for the complete procedure and [Model Selection and Loading](model-selection-and-loading.md) for runtime use.
|
||||
|
||||
The parser and trie are not restricted to ASCII. Dictionary items are ordinary Java `String` values, and trie traversal works over Java `char` sequences. This supports Latin-script data with diacritics, Cyrillic data, Hebrew, Persian, Yiddish, and other scripts represented in UTF-8, subject to the normal Java `String` model and the project’s traversal configuration.
|
||||
|
||||
@@ -235,3 +260,5 @@ To understand how those dictionary lines are transformed into compiled runtime a
|
||||
- [CLI compilation](cli-compilation.md)
|
||||
- [Programmatic usage](programmatic-usage.md)
|
||||
- [Architecture and reduction](architecture-and-reduction.md)
|
||||
!!! note "Radixor 4 model artifacts"
|
||||
Language dictionaries are independently versioned runtime model artifacts, not resources embedded in `radixor`. Language-based APIs resolve deterministic defaults through `StemmerModelRegistry`; see [Stemmer Models](stemmer-models.md).
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
# Fast Track
|
||||
|
||||
This page is the shortest path from an empty Java project to a working Radixor stemmer.
|
||||
It deliberately uses a bundled dictionary and the preferred compiled-command runtime API, so the
|
||||
It deliberately uses an external model artifact and the preferred compiled-command runtime API, so the
|
||||
first result does not require writing a dictionary, running the CLI compiler, or understanding
|
||||
reduction internals.
|
||||
|
||||
Use this page when the goal is:
|
||||
|
||||
- add the dependency,
|
||||
- load a bundled language resource,
|
||||
- load a registered language model,
|
||||
- stem a token,
|
||||
- know where to go next.
|
||||
|
||||
@@ -23,14 +23,14 @@ groupId: org.egothor
|
||||
artifactId: radixor
|
||||
```
|
||||
|
||||
Use the current published version from Maven Central. The snippets below use `3.0.0`; replace it
|
||||
with the version you deploy if a newer release is available.
|
||||
Radixor 4 is not yet represented by a published release in this working tree. Replace the version placeholder with the reviewed release you deploy.
|
||||
|
||||
For a Gradle project:
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
implementation("org.egothor:radixor:3.0.0")
|
||||
implementation("org.egothor:radixor:<radixor-version>")
|
||||
runtimeOnly("org.egothor:radixor-model-us-uk-default:1.0.0")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -40,17 +40,23 @@ For a Maven project:
|
||||
<dependency>
|
||||
<groupId>org.egothor</groupId>
|
||||
<artifactId>radixor</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>${radixor.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.egothor</groupId>
|
||||
<artifactId>radixor-model-us-uk-default</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
Radixor targets modern Java and has a dependency-light runtime core. The project documentation and
|
||||
benchmarks assume a current JDK; Java 21 or newer is the practical baseline for current releases.
|
||||
|
||||
## 2. Load A Bundled Dictionary
|
||||
## 2. Load An External Model Dictionary
|
||||
|
||||
The fastest path is to use a bundled dictionary through `StemmerPatchTrieLoader.Language`.
|
||||
This example uses the bundled English resource, `US_UK`.
|
||||
The fastest path is to use a registered model through `StemmerPatchTrieLoader.Language`.
|
||||
This example uses `US_UK`, whose default ID is `us-uk-default`; the runtime model dependency above must be present.
|
||||
|
||||
```java
|
||||
import java.io.IOException;
|
||||
@@ -81,12 +87,11 @@ public final class RadixorFirstStem {
|
||||
}
|
||||
```
|
||||
|
||||
The loaded `FrequencyTrie<CompiledPatchCommand>` is immutable and can be shared across request
|
||||
threads. Load it once during application startup and reuse it for indexing and query processing.
|
||||
The loaded `FrequencyTrie<CompiledPatchCommand>` has no mutating API. Load it once during application startup, publish it safely through application-owned lifecycle code, and reuse it for indexing and query processing.
|
||||
|
||||
## 3. Choose A Language Resource
|
||||
## 3. Choose a Language Default or Explicit Model
|
||||
|
||||
Bundled dictionaries are exposed as enum constants. Common examples:
|
||||
Language defaults are exposed as enum constants. Common examples:
|
||||
|
||||
| Language | Enum constant |
|
||||
| --- | --- |
|
||||
@@ -102,6 +107,8 @@ Bundled dictionaries are exposed as enum constants. Common examples:
|
||||
The full list, writing-direction notes, and benchmark links are in
|
||||
[Built-in Languages](built-in-languages.md).
|
||||
|
||||
Polish has two models. `Language.PL_PL` selects `pl-pl-unimorph`; load the alternative explicitly with `StemmerPatchTrieLoader.loadCompiled("pl-pl-polimorf", true, reductionMode)`, or retain a registry and pass `registry.require("pl-pl-polimorf")` to the descriptor overload. See [Model Selection and Loading](model-selection-and-loading.md). Full PoliMorf construction requires substantially more startup heap than ordinary models; the repository verifies it in a dedicated 6 GiB test JVM.
|
||||
|
||||
## 4. Use The Same Stemmer On Both Sides
|
||||
|
||||
For search, use the same Radixor configuration during indexing and query processing. A typical
|
||||
@@ -118,7 +125,7 @@ limited to lookup and patch application.
|
||||
|
||||
## 5. Next Step For Production
|
||||
|
||||
The fast path compiles a bundled dictionary during startup. That is convenient for evaluation and
|
||||
The fast path parses and compiles a registered model dictionary during startup. That is convenient for evaluation and
|
||||
small services. For larger deployments, compile once, persist a `.radixor.gz` artifact, and load
|
||||
that binary artifact at runtime.
|
||||
|
||||
@@ -126,5 +133,6 @@ Continue with:
|
||||
|
||||
- [Integration Deep Dive](integration-deep-dive.md) for production lifecycle guidance.
|
||||
- [Loading and Building Stemmers](programmatic-loading-and-building.md) for all loading APIs.
|
||||
- [Built-in Languages](built-in-languages.md) for bundled resources and dictionary locations.
|
||||
- [Model Selection and Loading](model-selection-and-loading.md) for model dependencies, variants, and failures.
|
||||
- [Built-in Languages](built-in-languages.md) for defaults and optional variants.
|
||||
- [Benchmarking](benchmarking.md) for speed and quality interpretation.
|
||||
|
||||
@@ -28,12 +28,26 @@ Radixor delivers:
|
||||
|
||||
Radixor is intended for teams that require consistent stemming quality at scale, while retaining the ability to evolve lexical resources after compilation and to handle ambiguous reductions with greater precision than traditional single-stem pipelines allow.
|
||||
|
||||
## Add the core and model data
|
||||
|
||||
The core `org.egothor:radixor` JAR contains no language dictionary. A minimal application adds one model; broad deployments may use the optional standard pack:
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph:1.0.0'
|
||||
}
|
||||
```
|
||||
|
||||
`StemmerPatchTrieLoader.loadCompiled(Language.PL_PL, ...)` resolves the default `pl-pl-unimorph`. `pl-pl-polimorf` is a separate optional model selected by stable model ID. Follow [Model Selection and Loading](model-selection-and-loading.md) for runnable examples or choose artifacts from the generated [model catalog](stemmer-model-catalog.md).
|
||||
|
||||
## Start here
|
||||
|
||||
- Read [Fast Track](fast-track.md) when you want the shortest path to a working bundled stemmer.
|
||||
- Use [Model Selection and Loading](model-selection-and-loading.md) for default, explicit, dual-model, and ClassLoader examples.
|
||||
- Use [Integration Deep Dive](integration-deep-dive.md) when you are wiring Radixor into a real application or search pipeline.
|
||||
- Read [Quick Start](quick-start.md) for the broader developer walkthrough after the first result works.
|
||||
- Use [Built-in Languages](built-in-languages.md) to find the bundled dictionaries exposed by Radixor.
|
||||
- Use [Built-in Languages](built-in-languages.md) to interpret language defaults and optional model variants.
|
||||
- Review [Benchmarking](benchmarking.md) and [Benchmark Results](benchmarks/index.md) for reproducible performance and quality methodology.
|
||||
- Open [CI Reports](reports.md) to inspect published build artifacts and quality metrics.
|
||||
- See the historical paper: [*Lemmatizer for Document Information Retrieval Systems in JAVA*](https://www.researchgate.net/publication/221512865_Lemmatizer_for_Document_Information_Retrieval_Systems_in_JAVA).
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Integration Deep Dive
|
||||
|
||||
This page explains how to integrate Radixor into a real Java application after the first
|
||||
fast-track experiment works. It covers dependencies, bundled dictionaries, runtime lifecycle,
|
||||
fast-track experiment works. It covers dependencies, external model artifacts, runtime lifecycle,
|
||||
deployment artifacts, and the decisions that matter in search or text-processing systems.
|
||||
|
||||
## Integration Model
|
||||
@@ -15,9 +15,10 @@ Radixor has two separate phases:
|
||||
|
||||
The practical rule is simple: compile rarely, stem often.
|
||||
|
||||
For production systems, prefer a startup-owned or dependency-injected singleton
|
||||
`FrequencyTrie<CompiledPatchCommand>` per language/configuration. The trie is immutable after
|
||||
construction and is suitable for concurrent reads.
|
||||
For production systems, prefer a startup-owned or dependency-injected
|
||||
`FrequencyTrie<CompiledPatchCommand>` per language/configuration. The compiled structure has no
|
||||
mutating API. The project does not currently publish a formal cross-thread safety guarantee, so
|
||||
applications should use normal safe-publication practices when sharing a loaded trie.
|
||||
|
||||
## Dependency Coordinates
|
||||
|
||||
@@ -31,7 +32,8 @@ Gradle:
|
||||
|
||||
```kotlin
|
||||
dependencies {
|
||||
implementation("org.egothor:radixor:3.0.0")
|
||||
implementation("org.egothor:radixor:<radixor-version>")
|
||||
runtimeOnly("org.egothor:radixor-models-standard:<catalog-version>")
|
||||
}
|
||||
```
|
||||
|
||||
@@ -41,11 +43,17 @@ Maven:
|
||||
<dependency>
|
||||
<groupId>org.egothor</groupId>
|
||||
<artifactId>radixor</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>${radixor.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.egothor</groupId>
|
||||
<artifactId>radixor-models-standard</artifactId>
|
||||
<version>${model.catalog.version}</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
Replace `3.0.0` with the current release selected for your deployment.
|
||||
Replace the example versions with the independently selected core and catalog releases for your deployment.
|
||||
|
||||
The core Java module is:
|
||||
|
||||
@@ -61,30 +69,15 @@ module example.search {
|
||||
}
|
||||
```
|
||||
|
||||
## Bundled Dictionaries
|
||||
## Runtime Model Artifacts
|
||||
|
||||
Radixor ships bundled dictionaries inside the library artifact. The public API exposes them through:
|
||||
The core ships no language dictionary. Add one or more `radixor-model-<model-id>` artifacts, or the optional metadata-only standard pack. Each model JAR contains an indexed descriptor and a namespaced GZip dictionary. `StemmerPatchTrieLoader.Language` represents language properties and a stable default model ID; it does not own embedded data.
|
||||
|
||||
```java
|
||||
StemmerPatchTrieLoader.Language
|
||||
```
|
||||
The standard option is specifically a POM-only runtime dependency aggregate, not an all-model binary JAR. It resolves one default model JAR per language and excludes optional PoliMorf. The separate POM-only `radixor-models-bom` manages recommended versions without adding runtime artifacts. Repository tests and JMH attach individual model projects directly to non-production configurations, so neither path changes the root publication's dependency graph.
|
||||
|
||||
The physical resources are packaged as compressed UTF-8 dictionaries under resource directories
|
||||
such as:
|
||||
For minimal deployments choose only required model artifacts. For multiple Polish variants add both `pl-pl-unimorph` and `pl-pl-polimorf`, retain UniMorph as the language default, and request PoliMorf explicitly. See [Model Selection and Loading](model-selection-and-loading.md) for complete dependencies and [Built-in Languages](built-in-languages.md) for mappings.
|
||||
|
||||
```text
|
||||
us_uk/stemmer.gz
|
||||
de_de/stemmer.gz
|
||||
fr_fr/stemmer.gz
|
||||
pl_pl/stemmer.gz
|
||||
```
|
||||
|
||||
Treat those resource paths as implementation details. Application code should load bundled
|
||||
dictionaries through `StemmerPatchTrieLoader.Language`, because the enum also carries the language
|
||||
metadata needed for correct traversal.
|
||||
|
||||
See [Built-in Languages](built-in-languages.md) for the complete language list, writing-direction
|
||||
notes, and links to per-language benchmark pages.
|
||||
Use `loadCompiled("pl-pl-polimorf", true, reductionMode)` for direct exact selection, or discover once and call `loadCompiled(descriptor, true, reductionMode)`. Neither form caches the trie. Complete PoliMorf startup is memory-intensive and is verified with a dedicated 6 GiB heap; construct it once during application initialization and retain the immutable result.
|
||||
|
||||
## Minimal Service Wrapper
|
||||
|
||||
@@ -126,7 +119,7 @@ searchable.
|
||||
|
||||
For a controlled deployment, compile once and deploy the binary artifact:
|
||||
|
||||
1. choose a bundled or custom dictionary,
|
||||
1. choose a registered model resource or caller-owned custom dictionary,
|
||||
2. optionally extend it with domain vocabulary,
|
||||
3. compile a contracted trie,
|
||||
4. persist it as `.radixor.gz`,
|
||||
@@ -173,9 +166,9 @@ Use Radixor consistently across indexing and querying:
|
||||
For multilingual content, do not run every token through every language. Route text by field,
|
||||
document metadata, or language detection before stemming.
|
||||
|
||||
## Choosing Bundled Versus Custom Dictionaries
|
||||
## Choosing Registered Versus Custom Dictionaries
|
||||
|
||||
Start with bundled dictionaries when:
|
||||
Start with registered model artifacts when:
|
||||
|
||||
- the language is supported,
|
||||
- the application needs a strong baseline quickly,
|
||||
@@ -218,7 +211,7 @@ use [Benchmark Results](benchmarks/index.md) for the detailed reference tree.
|
||||
Before production rollout:
|
||||
|
||||
- dependency version is pinned,
|
||||
- language resource and reduction mode are documented,
|
||||
- language, model ID, model artifact version, checksum, and reduction mode are documented,
|
||||
- indexing and query pipelines use the same stemming configuration,
|
||||
- custom artifacts are versioned and reproducible,
|
||||
- fallback behavior for unknown tokens is explicit,
|
||||
@@ -231,5 +224,6 @@ Before production rollout:
|
||||
- [Quick Start](quick-start.md)
|
||||
- [Built-in Languages](built-in-languages.md)
|
||||
- [Programmatic Usage](programmatic-usage.md)
|
||||
- [Model Selection and Loading](model-selection-and-loading.md)
|
||||
- [CLI Compilation](cli-compilation.md)
|
||||
- [Benchmarking](benchmarking.md)
|
||||
|
||||
@@ -1,6 +1,149 @@
|
||||
# Migration and Backward Compatibility
|
||||
|
||||
This page describes the migration from repeated serialized patch-command application to compiled patch commands.
|
||||
## Radixor 3.x to 4.x architecture migration
|
||||
|
||||
Radixor 3.x published algorithm classes and language dictionaries together as `org.egothor:radixor`. Radixor 4 keeps that established coordinate for the algorithmic core but removes every dictionary from the core JAR. Applications must now choose independently versioned model artifacts. This is deliberately source-compatible where practical and deliberately different at runtime.
|
||||
|
||||
### Before and after: dependencies
|
||||
|
||||
| Deployment | 3.x | 4.x |
|
||||
|---|---|---|
|
||||
| Core | `org.egothor:radixor:<3.x-version>` included dictionaries | `org.egothor:radixor:<radixor-version>` contains code only |
|
||||
| Minimal Polish | No separate data dependency | Add `radixor-model-pl-pl-unimorph:1.0.0` |
|
||||
| All defaults | Implicitly embedded | Add optional `radixor-models-standard:<catalog-version>` |
|
||||
| Optional Polish variant | Not independently selectable | Add and explicitly select `radixor-model-pl-pl-polimorf:1.0.0` |
|
||||
|
||||
Gradle, preserving the previous Polish default:
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph:1.0.0'
|
||||
}
|
||||
```
|
||||
|
||||
Gradle, broad default coverage:
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-models-standard:<catalog-version>'
|
||||
}
|
||||
```
|
||||
|
||||
Maven, preserving the Polish default:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.egothor</groupId>
|
||||
<artifactId>radixor</artifactId>
|
||||
<version>${radixor.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.egothor</groupId>
|
||||
<artifactId>radixor-model-pl-pl-unimorph</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Before and after: API behavior
|
||||
|
||||
Language-oriented calls remain source-compatible:
|
||||
|
||||
```java
|
||||
final FrequencyTrie<CompiledPatchCommand> polish =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
StemmerPatchTrieLoader.Language.PL_PL,
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
```
|
||||
|
||||
In 4.x this call creates a registry and resolves `Language.PL_PL.defaultModelId()`, which is `pl-pl-unimorph`. Source compatibility does not imply runtime classpath compatibility: the call fails with `StemmerModelNotFoundException` unless that model is visible.
|
||||
|
||||
Explicit selection enables multiple variants:
|
||||
|
||||
```java
|
||||
final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader();
|
||||
final StemmerModelDescriptor polimorf = registry.require("pl-pl-polimorf");
|
||||
final FrequencyTrie<CompiledPatchCommand> trie =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
polimorf,
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
```
|
||||
|
||||
The existing `load(String, ...)` overload means a filesystem path. The compiled `loadCompiled(String, boolean, ReductionMode)` overload now means a stable model ID; use the `Path` overload for a filesystem dictionary. Descriptor-based compiled loading avoids rediscovery when an application retains a registry. See [Model Selection and Loading](model-selection-and-loading.md) for complete examples.
|
||||
|
||||
### Polish migration scenarios
|
||||
|
||||
1. **Preserve previous default behavior:** add `radixor-model-pl-pl-unimorph` and keep using `Language.PL_PL`.
|
||||
2. **Use PoliMorf:** add `radixor-model-pl-pl-polimorf` and call `registry.require("pl-pl-polimorf")`.
|
||||
3. **Deploy both:** add both runtime artifacts and load each descriptor by ID. They are not merged.
|
||||
4. **Verify selection:** compare `registry.requireDefault(Language.PL_PL).id()` with `pl-pl-unimorph` through normal application control flow or a JUnit assertion, and inspect `registry.findByLanguage(Language.PL_PL)`.
|
||||
5. **Diagnose absence:** read the exact `StemmerModelNotFoundException` message, then inspect the production `runtimeClasspath` rather than changing dependency order.
|
||||
|
||||
UniMorph and PoliMorf are not interchangeable quality datasets. They can differ in vocabulary, provenance, licensing, and stemming outputs.
|
||||
|
||||
Model migration does not erase source obligations. Each migrated UniMorph artifact packages its
|
||||
language-specific notice with upstream attribution, Radixor modifications and contribution
|
||||
statement, ShareAlike terms, and the canonical CC BY-SA 3.0 URI. The original imports did not
|
||||
record exact UniMorph commits, so descriptors use
|
||||
`source.revision=not-recorded-in-legacy-import` and disclose that fact. Future model imports must
|
||||
record an exact upstream revision and source-archive checksum.
|
||||
|
||||
### Compatibility table
|
||||
|
||||
| Dimension | 4.x migration status |
|
||||
|---|---|
|
||||
| Source compatibility | Language-oriented loader signatures remain; external model dependencies are new |
|
||||
| Binary compatibility | Removing resources is a major-version boundary; review all deployed artifacts |
|
||||
| Runtime classpath | At least one selected model JAR is required |
|
||||
| Model format | Descriptor format `radixor-dictionary-tsv-gzip` version `1` is validated by the registry |
|
||||
| Model IDs | Stable runtime identities, independent of artifact discovery order |
|
||||
| Core Maven coordinate | Remains `org.egothor:radixor` |
|
||||
| Release versions | Core, each model, upstream source, format, and catalog versions evolve separately |
|
||||
|
||||
### Upgrade checklist
|
||||
|
||||
- Update the core dependency.
|
||||
- Choose individual model artifacts or the standard pack.
|
||||
- Put resource-only model dependencies on the production runtime classpath.
|
||||
- Verify `Language.defaultModelId()` mappings used by the application.
|
||||
- Inspect shaded, minimized, plugin, or modular packaging for indexes and resources.
|
||||
- Run application-level vocabulary and output regression tests.
|
||||
- Track model artifact versions and checksums separately from the core version.
|
||||
|
||||
### Roll back model choice
|
||||
|
||||
To return from optional PoliMorf to the default UniMorph behavior, add or retain `radixor-model-pl-pl-unimorph`, stop requesting `pl-pl-polimorf`, and load `Language.PL_PL` or explicitly request `pl-pl-unimorph`. Do not change the language constant. Remove the unused PoliMorf runtime dependency after verifying no explicit lookup still needs it.
|
||||
|
||||
Rolling the whole application back to 3.x instead requires restoring the reviewed 3.x core dependency and removing 4.x model assumptions. Do not combine 3.x embedded resources with the 4.x registry architecture.
|
||||
|
||||
Core, model, and catalog releases are independent:
|
||||
|
||||
```bash
|
||||
git tag -a "release@4.0.0" -m "Release Radixor 4.0.0"
|
||||
git tag -a "model/pl-pl-polimorf@1.0.0" -m "Release Polish PoliMorf model 1.0.0"
|
||||
git tag -a "models-catalog@2026.1" -m "Release Radixor model catalog 2026.1"
|
||||
```
|
||||
|
||||
A core tag publishes only the root `org.egothor:radixor` software artifacts, never model JARs. A model tag validates and publishes exactly its matching module, never core, standard, BOM, JMH, or the multilingual quality suite. A catalog tag publishes only BOM and standard aggregate metadata. Local model dry-run:
|
||||
|
||||
The catalog artifacts are POM-only: `radixor-models-standard` carries runtime dependencies on the 20 defaults, while `radixor-models-bom` carries dependency-management constraints for all 21 individual models. Neither publishes an empty binary, sources, or Javadoc JAR. This Maven BOM is distinct from the root CycloneDX SBOM report under `build/reports/sbom/`.
|
||||
|
||||
```bash
|
||||
./tools/parse-model-release-tag.sh "model/pl-pl-polimorf@1.0.0" .
|
||||
./gradlew --no-daemon :models:pl-pl-polimorf:check
|
||||
./gradlew --no-daemon :models:pl-pl-polimorf:validateModelRelease -PmodelReleaseVersion=1.0.0
|
||||
./gradlew --no-daemon :models:pl-pl-polimorf:packageModelReleaseCandidate -PmodelReleaseVersion=1.0.0
|
||||
```
|
||||
|
||||
Model format compatibility is descriptor-level and does not alter migrated bytes. Version 1 is `radixor-dictionary-tsv-gzip`. Model versions come from each module's `model-version.txt` or the matching explicit release property; catalog version comes from `models/catalog-version.txt`; only core uses Git-derived `release@` versioning.
|
||||
|
||||
The model catalog used by the published documentation is generated under `build/mkdocs-source/`. Neither generated Markdown nor rendered MkDocs output belongs in Git.
|
||||
|
||||
The remainder of this page describes the earlier migration from repeated serialized patch-command application to compiled patch commands.
|
||||
|
||||
## Summary
|
||||
|
||||
|
||||
277
docs/model-selection-and-loading.md
Normal file
277
docs/model-selection-and-loading.md
Normal file
@@ -0,0 +1,277 @@
|
||||
# Model Selection and Loading
|
||||
|
||||
Radixor separates executable stemming code from language data. The core artifact supplies dictionary parsing, trie construction, patch commands, lookup, and the model registry. A model artifact supplies one indexed descriptor, one GZip-compressed Radixor dictionary, and its licensing material. The core JAR contains no language dictionary.
|
||||
|
||||
```text
|
||||
Application
|
||||
-> org.egothor:radixor (algorithmic core)
|
||||
-> StemmerModelRegistry
|
||||
-> indexed model descriptor
|
||||
-> namespaced stemmer.gz resource
|
||||
-> checksum verification and dictionary parsing
|
||||
-> FrequencyTrie construction
|
||||
-> patch lookup and stemming
|
||||
```
|
||||
|
||||
## Language and model ID
|
||||
|
||||
These identifiers answer different questions:
|
||||
|
||||
| Concept | Example | Meaning |
|
||||
|---|---|---|
|
||||
| Language | `Language.PL_PL` | Polish as a linguistic identity |
|
||||
| Model ID | `pl-pl-unimorph` | One concrete Polish model configuration |
|
||||
| Model ID | `pl-pl-polimorf` | A different concrete Polish model configuration |
|
||||
| Default model | `PL_PL -> pl-pl-unimorph` | The model selected by the language convenience API |
|
||||
|
||||
One language can have several models. `Language.PL_PL` is neither UniMorph nor PoliMorf. `loadCompiled(Language.PL_PL, ...)` resolves the stable default ID declared by `Language.defaultModelId()`. An explicit lookup requests exactly one ID. Registry ordering never changes either decision.
|
||||
|
||||
Licensing follows the selected artifact. Radixor Java software is BSD-3-Clause; UniMorph-derived
|
||||
model data carries a model-specific CC BY-SA 3.0 notice, while PoliMorf carries its separate
|
||||
BSD-2-Clause license. The UniMorph notice preserves upstream attribution and identifies the
|
||||
Radixor transformations and limited protectable contributions without claiming the underlying data.
|
||||
|
||||
## Choose runtime dependencies
|
||||
|
||||
Radixor 4 is an architectural migration that is not yet represented by a published release in this working tree, so core and catalog versions below use placeholders. Every source-controlled model currently has model version `1.0.0`.
|
||||
|
||||
### Core plus the default Polish model
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph:1.0.0'
|
||||
}
|
||||
```
|
||||
|
||||
### Core plus optional PoliMorf
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-polimorf:1.0.0'
|
||||
}
|
||||
```
|
||||
|
||||
This dependency makes `pl-pl-polimorf` discoverable; it does not change the default for `PL_PL`.
|
||||
|
||||
### Both Polish models
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph:1.0.0'
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-polimorf:1.0.0'
|
||||
}
|
||||
```
|
||||
|
||||
### Standard defaults
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-models-standard:<catalog-version>'
|
||||
}
|
||||
```
|
||||
|
||||
The standard aggregate is POM-only. Its POM supplies exactly one default model per supported language as transitive runtime dependencies and excludes optional PoliMorf. It publishes no empty binary JAR.
|
||||
|
||||
### BOM-managed versions
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
implementation platform('org.egothor:radixor-models-bom:<catalog-version>')
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph'
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-polimorf'
|
||||
}
|
||||
```
|
||||
|
||||
Equivalent Maven dependencies use ordinary runtime scope:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.egothor</groupId>
|
||||
<artifactId>radixor</artifactId>
|
||||
<version>${radixor.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.egothor</groupId>
|
||||
<artifactId>radixor-model-pl-pl-unimorph</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
Use `implementation` for the core because application code imports its API. Models normally use `runtimeOnly` because they provide resources rather than Java types. Tests with a deliberately isolated model set use `testRuntimeOnly`. The repository attaches every default model and optional PoliMorf directly to `jmhRuntimeOnly`; test and quality configurations likewise use direct non-production model dependencies. No benchmark aggregate artifact exists, and no model dependency enters the root published POM.
|
||||
|
||||
## Load the documented default
|
||||
|
||||
Dependency prerequisite: core plus `radixor-model-pl-pl-unimorph` (or the standard pack).
|
||||
|
||||
```java
|
||||
import org.egothor.stemmer.CompiledPatchCommand;
|
||||
import org.egothor.stemmer.FrequencyTrie;
|
||||
import org.egothor.stemmer.ReductionMode;
|
||||
import org.egothor.stemmer.ReductionSettings;
|
||||
import org.egothor.stemmer.StemmerPatchTrieLoader;
|
||||
|
||||
final FrequencyTrie<CompiledPatchCommand> polish =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
StemmerPatchTrieLoader.Language.PL_PL,
|
||||
true,
|
||||
ReductionSettings.withDefaults(
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS));
|
||||
|
||||
final String word = "koty";
|
||||
final CompiledPatchCommand patch = polish.get(word);
|
||||
final String stem = patch == null ? word : patch.apply(word);
|
||||
```
|
||||
|
||||
The loader creates a registry from the thread context class loader, resolves `PL_PL` to `pl-pl-unimorph`, verifies the compressed resource checksum, decompresses and parses the UTF-8 dictionary, constructs the trie, and compiles its patch commands. It does not load a serialized Java object. If the default artifact is absent, `StemmerModelNotFoundException` names the missing ID and suggested Maven artifact.
|
||||
|
||||
## Load PoliMorf explicitly
|
||||
|
||||
Dependency prerequisite: core plus `radixor-model-pl-pl-polimorf`.
|
||||
|
||||
```java
|
||||
import org.egothor.stemmer.CompiledPatchCommand;
|
||||
import org.egothor.stemmer.FrequencyTrie;
|
||||
import org.egothor.stemmer.ReductionMode;
|
||||
import org.egothor.stemmer.StemmerModelDescriptor;
|
||||
import org.egothor.stemmer.StemmerModelRegistry;
|
||||
import org.egothor.stemmer.StemmerPatchTrieLoader;
|
||||
|
||||
final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader();
|
||||
final StemmerModelDescriptor descriptor = registry.require("pl-pl-polimorf");
|
||||
|
||||
final FrequencyTrie<CompiledPatchCommand> polish =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
descriptor,
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
|
||||
final String word = "koty";
|
||||
final CompiledPatchCommand patch = polish.get(word);
|
||||
final String stem = patch == null ? word : patch.apply(word);
|
||||
```
|
||||
|
||||
The equivalent direct model-ID form is:
|
||||
|
||||
```java
|
||||
final FrequencyTrie<CompiledPatchCommand> polimorf =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
"pl-pl-polimorf",
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
```
|
||||
|
||||
`require("pl-pl-polimorf")` and the direct overload are deterministic because registry keys are stable model IDs. Discovery order is sorted, duplicate IDs are rejected, and no “first Polish model on the classpath” fallback exists. Both overloads return compiled patch-command values and perform complete integrity checking, parsing, reduction, and trie construction.
|
||||
|
||||
!!! warning "PoliMorf startup memory"
|
||||
Full construction of the PoliMorf model is memory-intensive. Radixor verifies it in one isolated JVM with a task-specific maximum heap of 6 GiB. Two measured verification runs completed full construction in 23.7 seconds and 23.5 seconds, producing 358,993 canonical trie nodes; the complete Gradle processes peaked at approximately 6.23 GiB resident memory. The compressed model is only 12,624,997 bytes (68,093,680 bytes decompressed), so JAR size is not a proxy for construction-time heap. Applications loading the complete model must provision sufficient startup heap. Radixor does not currently expose a measured retained-heap value, so do not infer one from the process peak.
|
||||
|
||||
## Use both Polish models
|
||||
|
||||
Dependency prerequisite: both Polish model artifacts.
|
||||
|
||||
```java
|
||||
final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader();
|
||||
|
||||
final StemmerModelDescriptor unimorph = registry.require("pl-pl-unimorph");
|
||||
final StemmerModelDescriptor polimorf = registry.require("pl-pl-polimorf");
|
||||
final StemmerModelDescriptor defaultPolish =
|
||||
registry.requireDefault(StemmerPatchTrieLoader.Language.PL_PL);
|
||||
|
||||
if (!"pl-pl-unimorph".equals(defaultPolish.id())) {
|
||||
throw new IllegalStateException(
|
||||
"Unexpected default Polish model: " + defaultPolish.id());
|
||||
}
|
||||
|
||||
final FrequencyTrie<CompiledPatchCommand> unimorphTrie =
|
||||
StemmerPatchTrieLoader.loadCompiled(unimorph, true, reductionMode);
|
||||
final FrequencyTrie<CompiledPatchCommand> polimorfTrie =
|
||||
StemmerPatchTrieLoader.loadCompiled(polimorf, true, reductionMode);
|
||||
```
|
||||
|
||||
The descriptors and tries coexist independently. The models are not merged, and adding PoliMorf does not alter the language default. An application that compares, votes across, or merges model outputs must implement that higher-level policy explicitly.
|
||||
|
||||
## Discover available models
|
||||
|
||||
```java
|
||||
final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader();
|
||||
|
||||
for (final StemmerModelDescriptor model : registry.models()) {
|
||||
System.out.printf("%s %s %s %s/%d descriptor=%s%n",
|
||||
model.id(), model.language(), model.version(),
|
||||
model.format(), model.formatVersion(), model.source());
|
||||
}
|
||||
|
||||
final java.util.List<StemmerModelDescriptor> polishModels =
|
||||
registry.findByLanguage(StemmerPatchTrieLoader.Language.PL_PL);
|
||||
```
|
||||
|
||||
Both lists use stable model-ID order. The public descriptor API exposes ID, model artifact version, language, display name, runtime resource, default flag, format, format version, checksum, and descriptor source URL. Packaged provenance properties such as `source.name` and `source.version` are not currently exposed as typed descriptor accessors; consult the generated [model catalog](stemmer-model-catalog.md) for them.
|
||||
|
||||
## Use an explicit ClassLoader
|
||||
|
||||
```java
|
||||
final ClassLoader pluginLoader = plugin.getClass().getClassLoader();
|
||||
final StemmerModelRegistry pluginModels =
|
||||
StemmerModelRegistry.fromClassLoader(pluginLoader);
|
||||
final StemmerModelDescriptor model = pluginModels.require("pl-pl-polimorf");
|
||||
```
|
||||
|
||||
`fromContextClassLoader()` uses the current thread context loader, falling back to Radixor's defining loader when the context loader is `null`. `fromClassLoader(loader)` searches only what that loader can expose through `getResources(...)` and ordinary resource lookup. Plugin containers, application servers, and isolated tests can therefore observe different model sets. Pass a non-null loader and retain the registry associated with that deployment scope.
|
||||
|
||||
## Error handling
|
||||
|
||||
```java
|
||||
try {
|
||||
final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader();
|
||||
final StemmerModelDescriptor model = registry.require("pl-pl-polimorf");
|
||||
// Load and cache the trie during application startup.
|
||||
} catch (final StemmerModelNotFoundException exception) {
|
||||
// Missing runtime dependency or model hidden from this ClassLoader.
|
||||
throw exception;
|
||||
} catch (final DuplicateStemmerModelException exception) {
|
||||
// Conflicting artifacts or a fat JAR duplicated one stable ID.
|
||||
throw exception;
|
||||
} catch (final UnsupportedStemmerModelFormatException exception) {
|
||||
// The model format or format version is not supported by this core.
|
||||
throw exception;
|
||||
} catch (final StemmerModelIntegrityException exception) {
|
||||
// Malformed descriptor/index, missing resource, wrong language, or checksum failure.
|
||||
throw exception;
|
||||
} catch (final java.io.IOException exception) {
|
||||
// Classpath enumeration or resource I/O failed.
|
||||
throw new java.io.UncheckedIOException(exception);
|
||||
}
|
||||
```
|
||||
|
||||
Malformed metadata does not have a separate public exception: it is reported as `StemmerModelIntegrityException`. Missing explicit and default models both use `StemmerModelNotFoundException`; the default diagnostic additionally names the language and expected default ID. Never swallow these failures or choose an arbitrary model.
|
||||
|
||||
## Lifecycle and concurrency
|
||||
|
||||
`StemmerModelRegistry` copies discovered descriptors into an unmodifiable map, returns immutable list copies, and has no mutating API. `StemmerModelDescriptor` is final with final fields. These objects are safe to retain after discovery. Registry discovery is not globally cached: every call enumerates indexes and parses descriptors again. Model loading is also not cached: every call reads, hashes, decompresses, parses, and builds a new trie.
|
||||
|
||||
Compiled tries are immutable and thread-safe for concurrent reads. Load a registry and the required tries once during application startup, publish them safely, and reuse them. The loader does not cache model tries; do not repeatedly discover and compile models per token. When comparing both Polish models, account for the memory of two independent tries and avoid constructing them concurrently unless the deployment is sized for that peak.
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
| Symptom | Meaning | Action |
|
||||
|---|---|---|
|
||||
| `No default model '...' is available` | The default artifact is absent from the selected loader | Add the named model as a runtime dependency and inspect `runtimeClasspath` |
|
||||
| `No model 'pl-pl-polimorf' is available` | Explicit optional model is absent or invisible | Add `radixor-model-pl-pl-polimorf` to runtime, not only tests |
|
||||
| Duplicate model ID | Two resources declare one stable ID | Remove the duplicate artifact or fix fat-JAR resource duplication; do not reorder the classpath |
|
||||
| Checksum mismatch | Descriptor and compressed bytes differ | Replace the corrupted or incorrectly repackaged artifact |
|
||||
| Unsupported format | Core supports neither the format name nor version | Use a compatible core/model pair; do not bypass validation |
|
||||
| Works in tests, fails in production | The model is probably `testRuntimeOnly` | Inspect `./gradlew dependencies --configuration runtimeClasspath` |
|
||||
| Visible with one loader only | Class loaders expose different resources | Call `fromClassLoader(...)` with the loader that owns the model JAR |
|
||||
| PoliMorf is installed but language loading uses UniMorph | Expected default behavior | Select `pl-pl-polimorf` explicitly |
|
||||
| Dependency minimization removed the model | Resource-only dependency was treated as unused | Preserve the model JAR, index, descriptor, license, and dictionary |
|
||||
| Shaded JAR fails or reports duplicates | Indexes/resources were dropped or duplicated | Inspect with `jar tf app.jar | grep -E 'models.index|stemmer.gz'`; configure deterministic resource merging without duplicating IDs |
|
||||
|
||||
Useful Gradle diagnostics include `./gradlew dependencyInsight --dependency radixor-model --configuration runtimeClasspath` and `./gradlew dependencies --configuration testRuntimeClasspath`. Classpath order is not a remediation mechanism.
|
||||
|
||||
Continue with [Programmatic Usage](programmatic-usage.md), [Stemmer Models](stemmer-models.md), [Built-in Languages](built-in-languages.md), the generated [model catalog](stemmer-model-catalog.md), and [Architecture](architecture.md).
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
This document explains how to acquire a compiled Radixor stemmer in Java.
|
||||
|
||||
## Load a bundled language dictionary
|
||||
## Load a registered default model
|
||||
|
||||
Bundled language resources are simple to use and compile directly into a `FrequencyTrie<CompiledPatchCommand>` during loading.
|
||||
Language-oriented entry points resolve a registered default model and compile its GZip textual dictionary into a `FrequencyTrie<CompiledPatchCommand>`. The corresponding model JAR must be on the runtime classpath; the core contains no dictionary.
|
||||
|
||||
```java
|
||||
import java.io.IOException;
|
||||
@@ -14,9 +14,9 @@ import org.egothor.stemmer.FrequencyTrie;
|
||||
import org.egothor.stemmer.ReductionMode;
|
||||
import org.egothor.stemmer.StemmerPatchTrieLoader;
|
||||
|
||||
public final class BundledLanguageExample {
|
||||
public final class RegisteredLanguageModelExample {
|
||||
|
||||
private BundledLanguageExample() {
|
||||
private RegisteredLanguageModelExample() {
|
||||
throw new AssertionError("No instances.");
|
||||
}
|
||||
|
||||
@@ -31,14 +31,16 @@ public final class BundledLanguageExample {
|
||||
|
||||
The `storeOriginal` flag controls whether the canonical stem is inserted as a no-op patch entry for the stem itself.
|
||||
|
||||
Bundled `loadCompiled(...)` entry points build the runtime trie with the same contracted
|
||||
Language-oriented `loadCompiled(...)` entry points build the runtime trie with the same contracted
|
||||
representation used by the published benchmarks. During compilation, uniform preferred-command
|
||||
subtrees are collapsed into accepting leaves, so lookup can stop before consuming the entire input
|
||||
when the remaining characters cannot change the selected patch command.
|
||||
|
||||
## Load a textual dictionary
|
||||
|
||||
Loading from a dictionary file follows the same preparation model as bundled resources, but the source comes from your own file or path. The input may be plain UTF-8 text or GZip-compressed UTF-8 text; the loader detects GZip data from the stream header. The textual format is tab-separated values, meaning that columns are separated by the tab character. Each non-empty logical line starts with the stem column and may contain zero or more variant columns. Input case normalization is controlled by `CaseProcessingMode` (default: `LOWERCASE_WITH_LOCALE_ROOT`), trailing remarks introduced by `#` or `//` are ignored, and dictionary items containing embedded whitespace are currently ignored with warning-level diagnostics.
|
||||
Loading from a dictionary file follows the same trie preparation model as registered model resources, but the source comes from your own file or path and bypasses registry metadata. The input may be plain UTF-8 text or GZip-compressed UTF-8 text; the loader detects GZip data from the stream header. The textual format is tab-separated values, meaning that columns are separated by the tab character. Each non-empty logical line starts with the stem column and may contain zero or more variant columns. Input case normalization is controlled by `CaseProcessingMode` (default: `LOWERCASE_WITH_LOCALE_ROOT`), trailing remarks introduced by `#` or `//` are ignored, and dictionary items containing embedded whitespace are currently ignored with warning-level diagnostics.
|
||||
|
||||
For explicit model IDs, multiple variants, and ClassLoader control, see [Model Selection and Loading](model-selection-and-loading.md).
|
||||
|
||||
```java
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -1,80 +1,133 @@
|
||||
# Programmatic Usage
|
||||
|
||||
This document provides the programmatic entry point to **Radixor**.
|
||||
Radixor code and model data are separate runtime components. Every example on this page requires `org.egothor:radixor:<radixor-version>` as an `implementation` dependency and at least one model JAR as a runtime dependency. The core JAR contains no `stemmer.gz`.
|
||||
|
||||
Radixor follows a clear lifecycle:
|
||||
For complete dependency patterns, lifecycle guidance, and troubleshooting, use [Model Selection and Loading](model-selection-and-loading.md). The generated [model catalog](stemmer-model-catalog.md) records the current artifacts, versions, checksums, and provenance.
|
||||
|
||||
1. acquire a compiled stemmer,
|
||||
2. query it for patch commands,
|
||||
3. apply those commands to produce stems,
|
||||
4. reopen and extend the compiled structure when needed.
|
||||
## 1. Minimal use: the Polish default
|
||||
|
||||
## Conceptual model
|
||||
Dependency prerequisite:
|
||||
|
||||
Radixor is dictionary-driven, but runtime stemming does not operate by scanning raw dictionary files. A source dictionary is parsed as a sequence of canonical stems and their known variants. Each variant is converted into a compact patch command that transforms the variant into the stem, while the stem itself may optionally be stored as a canonical no-op patch. The mutable trie is then reduced into a compiled read-only structure that stores ordered values and their counts at addressed nodes.
|
||||
|
||||
Two consequences matter for developers:
|
||||
|
||||
- the quality and coverage of stemming behavior depend on dictionary richness,
|
||||
- runtime usage is based on compiled patch-command lookup rather than on direct dictionary traversal.
|
||||
|
||||
This is why Radixor can generalize beyond explicitly listed forms and why compiled artifacts are well suited for deployment.
|
||||
|
||||
## Documentation map
|
||||
|
||||
The programmatic API is easier to understand when split by developer task:
|
||||
|
||||
- [Fast Track](fast-track.md) gives the shortest dependency-to-first-stem path for a new Java project.
|
||||
- [Integration Deep Dive](integration-deep-dive.md) explains production integration, deployment artifacts, search-pipeline usage, and operational decisions.
|
||||
- [Loading and Building Stemmers](programmatic-loading-and-building.md) explains how to acquire a compiled stemmer from bundled resources, textual dictionaries, binary artifacts, or direct builder usage.
|
||||
- [Lookup Edge Optimization](lookup-edge-optimization.md) explains dense child lookup tuning and the speed/memory trade-off when materializing compiled tries.
|
||||
- [Querying and Ambiguity Handling](programmatic-querying-and-ambiguity.md) explains `get(...)`, `getAll(...)`, `getEntries(...)`, patch application, and the practical meaning of reduction modes.
|
||||
- [Extending and Persisting Compiled Tries](programmatic-extending-and-persistence.md) explains how to reopen compiled tries, add new lexical data, rebuild them, and store them as binary artifacts.
|
||||
|
||||
## Core types
|
||||
|
||||
The main types involved in programmatic usage are:
|
||||
|
||||
- `FrequencyTrie.Builder<V>` for mutable construction and extension,
|
||||
- `FrequencyTrie<V>` for the compiled read-only trie,
|
||||
- `PatchCommandEncoder` for creating serialized patch commands,
|
||||
- `CompiledPatchCommand` for repeated runtime patch application,
|
||||
- `StemmerPatchTrieLoader` for loading bundled or textual dictionaries,
|
||||
- `StemmerPatchTrieBinaryIO` for reading and writing compressed binary artifacts,
|
||||
- `FrequencyTrieBuilders` for reconstructing a mutable builder from a compiled trie,
|
||||
- `ReductionMode` and `ReductionSettings` for controlling compilation semantics.
|
||||
|
||||
## Java module system (JPMS)
|
||||
|
||||
The core artifact is published as an explicit JPMS module:
|
||||
|
||||
```java
|
||||
module org.egothor.radixor;
|
||||
```groovy
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph:1.0.0'
|
||||
```
|
||||
|
||||
A named consuming module uses:
|
||||
```java
|
||||
import org.egothor.stemmer.CompiledPatchCommand;
|
||||
import org.egothor.stemmer.FrequencyTrie;
|
||||
import org.egothor.stemmer.ReductionMode;
|
||||
import org.egothor.stemmer.StemmerPatchTrieLoader;
|
||||
|
||||
final FrequencyTrie<CompiledPatchCommand> trie =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
StemmerPatchTrieLoader.Language.PL_PL,
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
|
||||
final String word = "koty";
|
||||
final CompiledPatchCommand patch = trie.get(word);
|
||||
final String stem = patch == null ? word : patch.apply(word);
|
||||
```
|
||||
|
||||
`Language.PL_PL` resolves to `pl-pl-unimorph`. The loader creates the registry internally through the thread context class loader.
|
||||
|
||||
## 2. Explicit model selection
|
||||
|
||||
Dependency prerequisite: replace or supplement the default dependency with `runtimeOnly 'org.egothor:radixor-model-pl-pl-polimorf:1.0.0'`.
|
||||
|
||||
```java
|
||||
module example.consumer {
|
||||
requires org.egothor.radixor;
|
||||
final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader();
|
||||
final StemmerModelDescriptor polimorf = registry.require("pl-pl-polimorf");
|
||||
final FrequencyTrie<CompiledPatchCommand> trie =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
polimorf,
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
```
|
||||
|
||||
The stable model-ID overload performs the same exact selection without a separately retained registry:
|
||||
|
||||
```java
|
||||
final FrequencyTrie<CompiledPatchCommand> trie =
|
||||
StemmerPatchTrieLoader.loadCompiled(
|
||||
"pl-pl-polimorf",
|
||||
true,
|
||||
ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS);
|
||||
```
|
||||
|
||||
## 3. Multiple variants for one language
|
||||
|
||||
Dependency prerequisite: both `radixor-model-pl-pl-unimorph:1.0.0` and `radixor-model-pl-pl-polimorf:1.0.0` at runtime.
|
||||
|
||||
```java
|
||||
final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader();
|
||||
final StemmerModelDescriptor unimorph = registry.require("pl-pl-unimorph");
|
||||
final StemmerModelDescriptor polimorf = registry.require("pl-pl-polimorf");
|
||||
|
||||
final FrequencyTrie<CompiledPatchCommand> unimorphTrie =
|
||||
StemmerPatchTrieLoader.loadCompiled(unimorph, true, reductionMode);
|
||||
final FrequencyTrie<CompiledPatchCommand> polimorfTrie =
|
||||
StemmerPatchTrieLoader.loadCompiled(polimorf, true, reductionMode);
|
||||
|
||||
final StemmerModelDescriptor defaultPolish =
|
||||
registry.requireDefault(StemmerPatchTrieLoader.Language.PL_PL);
|
||||
if (!"pl-pl-unimorph".equals(defaultPolish.id())) {
|
||||
throw new IllegalStateException(
|
||||
"Unexpected default Polish model: " + defaultPolish.id());
|
||||
}
|
||||
```
|
||||
|
||||
The core module is standalone and can be consumed directly as a normal Java module.
|
||||
The tries remain independent. Radixor does not merge models or infer an alternative default from classpath order.
|
||||
|
||||
## Recommended reading order
|
||||
## 4. Discovery
|
||||
|
||||
For most developers, the best order is:
|
||||
Dependency prerequisite: whichever model artifacts the application intends to discover.
|
||||
|
||||
1. [Fast Track](fast-track.md)
|
||||
2. [Integration Deep Dive](integration-deep-dive.md)
|
||||
3. [Loading and Building Stemmers](programmatic-loading-and-building.md)
|
||||
4. [Querying and Ambiguity Handling](programmatic-querying-and-ambiguity.md)
|
||||
5. [Extending and Persisting Compiled Tries](programmatic-extending-and-persistence.md)
|
||||
```java
|
||||
final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader();
|
||||
|
||||
## Next steps
|
||||
for (final StemmerModelDescriptor descriptor : registry.models()) {
|
||||
System.out.printf("%s %s %s %s/%d%n",
|
||||
descriptor.id(), descriptor.language(), descriptor.version(),
|
||||
descriptor.format(), descriptor.formatVersion());
|
||||
}
|
||||
|
||||
- [Quick Start](quick-start.md)
|
||||
- [CLI compilation](cli-compilation.md)
|
||||
- [Dictionary format](dictionary-format.md)
|
||||
- [Architecture and reduction](architecture-and-reduction.md)
|
||||
final java.util.List<StemmerModelDescriptor> polish =
|
||||
registry.findByLanguage(StemmerPatchTrieLoader.Language.PL_PL);
|
||||
```
|
||||
|
||||
Results use deterministic model-ID order. See [Built-in Languages](built-in-languages.md) for default interpretation and the generated [catalog](stemmer-model-catalog.md) for provenance.
|
||||
|
||||
## 5. Advanced ClassLoader selection
|
||||
|
||||
Dependency prerequisite: the model JAR must be visible to the selected loader.
|
||||
|
||||
```java
|
||||
final ClassLoader applicationLoader = application.getClass().getClassLoader();
|
||||
final StemmerModelRegistry isolatedRegistry =
|
||||
StemmerModelRegistry.fromClassLoader(applicationLoader);
|
||||
```
|
||||
|
||||
This form is useful for plugin containers, isolated application servers, and tests. It can discover a different set from the thread context loader. See [ClassLoader troubleshooting](model-selection-and-loading.md#troubleshooting).
|
||||
|
||||
## 6. Error handling
|
||||
|
||||
Dependency prerequisite: none beyond core; this example demonstrates an absent optional model.
|
||||
|
||||
```java
|
||||
try {
|
||||
StemmerModelRegistry.fromContextClassLoader().require("pl-pl-polimorf");
|
||||
} catch (final StemmerModelNotFoundException exception) {
|
||||
System.err.println(exception.getMessage());
|
||||
}
|
||||
```
|
||||
|
||||
Missing models never produce an empty trie or arbitrary fallback. Duplicate IDs, unsupported formats, malformed descriptors, missing resources, and checksum mismatches are also fatal. The full exception mapping and remediation table are in [Model Selection and Loading](model-selection-and-loading.md#error-handling).
|
||||
|
||||
## Continue into the trie API
|
||||
|
||||
- [Loading and Building Stemmers](programmatic-loading-and-building.md)
|
||||
- [Querying and Ambiguity Handling](programmatic-querying-and-ambiguity.md)
|
||||
- [Extending and Persisting Compiled Tries](programmatic-extending-and-persistence.md)
|
||||
- [Architecture](architecture.md)
|
||||
|
||||
@@ -4,10 +4,23 @@ This guide introduces the fastest practical path to using **Radixor**.
|
||||
|
||||
If you are new to Radixor and want the shortest possible path to a first working stem, start with
|
||||
[Fast Track](fast-track.md). This Quick Start is a broader developer walkthrough: it introduces the
|
||||
main loading options, query methods, artifact workflow, and metadata model.
|
||||
main loading options, query methods, artifact workflow, and metadata model. For model-ID selection and failures, use [Model Selection and Loading](model-selection-and-loading.md).
|
||||
|
||||
Radixor separates preparation from runtime usage. Source dictionaries are used to derive patch commands and reduce them into a compact read-only trie. Runtime stemming then operates on that compiled structure rather than on the original dictionary text. A richer dictionary usually improves the quality and coverage of inferred transformations, including transformations that are applicable to words not explicitly present in the source material. The reduction step also removes a large amount of redundant lexical information, which is why very large dictionaries can still produce compact runtime artifacts. These artifacts can be persisted and loaded directly when needed.
|
||||
|
||||
From version 4 onward, the core and models are explicit dependencies:
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
implementation 'org.egothor:radixor:<radixor-version>'
|
||||
runtimeOnly 'org.egothor:radixor-models-standard:<catalog-version>'
|
||||
}
|
||||
```
|
||||
|
||||
The core JAR contains no dictionary. Replace the standard pack with `runtimeOnly 'org.egothor:radixor-model-us-uk-default:1.0.0'` for the minimal English example below. For Polish, `Language.PL_PL` resolves `pl-pl-unimorph`; installing optional `pl-pl-polimorf` does not select it automatically.
|
||||
|
||||
Explicit PoliMorf loading uses `StemmerPatchTrieLoader.loadCompiled("pl-pl-polimorf", true, reductionMode)`. Its complete dictionary is supported, but construction is exceptional enough that repository verification runs it separately with a 6 GiB maximum heap. See [Model Selection and Loading](model-selection-and-loading.md#load-polimorf-explicitly) for the complete dependency and Java example.
|
||||
|
||||
A practical workflow usually consists of two independent phases:
|
||||
|
||||
1. obtain a compiled stemmer,
|
||||
@@ -17,9 +30,9 @@ A practical workflow usually consists of two independent phases:
|
||||
|
||||
A compiled stemmer can be obtained in three common ways.
|
||||
|
||||
### Use a bundled language dictionary
|
||||
### Use an external language model
|
||||
|
||||
Radixor ships with bundled dictionaries for a set of supported languages. These resources are line-oriented dictionaries stored with the library and compiled into a `FrequencyTrie<CompiledPatchCommand>` when loaded through the runtime API. The loader can also store the canonical stem itself as a no-op patch command. Compiled trie artifacts now persist self-describing metadata, including the traversal direction and compilation reduction settings used to build the artifact.
|
||||
Language dictionaries are independently versioned model JARs discovered by `StemmerModelRegistry`. The root `org.egothor:radixor` JAR contains no dictionary bytes. The loader compiles a selected model into a `FrequencyTrie<CompiledPatchCommand>`; compiled trie artifacts retain self-describing traversal and reduction metadata.
|
||||
|
||||
```java
|
||||
import java.io.IOException;
|
||||
@@ -29,9 +42,9 @@ import org.egothor.stemmer.FrequencyTrie;
|
||||
import org.egothor.stemmer.ReductionMode;
|
||||
import org.egothor.stemmer.StemmerPatchTrieLoader;
|
||||
|
||||
public final class BundledStemmerExample {
|
||||
public final class RegisteredModelExample {
|
||||
|
||||
private BundledStemmerExample() {
|
||||
private RegisteredModelExample() {
|
||||
throw new AssertionError("No instances.");
|
||||
}
|
||||
|
||||
@@ -251,3 +264,5 @@ Dictionary compilation is usually a one-time preparation step and is generally f
|
||||
Every compiled trie artifact stores a `TrieMetadata` descriptor together with the immutable trie payload. That metadata currently records the binary format version, the `WordTraversalDirection`, the `ReductionSettings` used during compilation, the declared `DiacriticProcessingMode`, and the selected `CaseProcessingMode`. Traversal, case processing, and diacritic processing are applied during runtime lookup (`get`, `getAll`), and case/diacritic processing are also applied during dictionary insertion when a trie is built.
|
||||
|
||||
`DiacriticProcessingMode.AS_IS` keeps dictionary keys and lookup keys unchanged. `DiacriticProcessingMode.REMOVE` strips diacritics from dictionary keys and lookup keys (for Czech diacritics and broad European Latin-script variants). `DiacriticProcessingMode.AS_IS_AND_STRIPPED_FALLBACK` is currently not supported and raises an `UnsupportedOperationException`.
|
||||
!!! note "Radixor 4 model artifacts"
|
||||
Language dictionaries are independently versioned runtime model artifacts, not resources embedded in `radixor`. Language-based APIs resolve deterministic defaults through `StemmerModelRegistry`; see [Stemmer Models](stemmer-models.md).
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
Radixor publishes durable build outputs to GitHub Pages from qualifying runs of `.github/workflows/pages.yml`.
|
||||
|
||||
The workflow builds maintained MkDocs documentation and the generated model catalog from the staged source tree under `build/mkdocs-source/`. It then merges the rendered site into the separate `gh-pages` publication worktree while preserving `builds/`. The main branch stores neither generated Markdown nor rendered site output. The publication retains the ten newest numbered report sets and maintains `builds/latest/` as a stable alias.
|
||||
|
||||
This page is the central entry point for published project artifacts, including build summaries, API documentation, test and quality reports, benchmark outputs, and software composition materials. It is intended both for routine project inspection and for linking stable report surfaces from external references such as the README, release notes, or development workflows.
|
||||
|
||||
## Stable entry points
|
||||
|
||||
192
docs/stemmer-models.md
Normal file
192
docs/stemmer-models.md
Normal file
@@ -0,0 +1,192 @@
|
||||
# Stemmer Models
|
||||
|
||||
This page defines the model artifact and its maintenance lifecycle. Application developers should begin with [Model Selection and Loading](model-selection-and-loading.md); the generated [model catalog](stemmer-model-catalog.md) is the detailed inventory.
|
||||
|
||||
## Terminology
|
||||
|
||||
| Term | Definition |
|
||||
|---|---|
|
||||
| Radixor core | Java parsing, patch-command, trie, registry, descriptor, and loader code in `org.egothor:radixor` |
|
||||
| Language | Locale-level identity such as `PL_PL`; not a dictionary or model |
|
||||
| Model ID | Stable identity of one concrete model, such as `pl-pl-unimorph` |
|
||||
| Model artifact | Independently versioned JAR containing one descriptor, one runtime dictionary, and licensing material |
|
||||
| Source dictionary | Upstream lexical or morphological source recorded in provenance |
|
||||
| Runtime dictionary | GZip-compressed UTF-8 Radixor tab-separated data consumed during trie construction |
|
||||
| Compiled trie | In-memory lookup structure built by the loader; not the `stemmer.gz` resource |
|
||||
| Default model | Stable ID selected by a language-oriented loader call |
|
||||
| Optional model | Discoverable only when installed and selected explicitly; PoliMorf is optional for Polish |
|
||||
|
||||
Core version, model artifact version, catalog version, source dictionary version, and model format version are separate compatibility axes. Updating Java code need not republish unchanged model bytes; updating one model need not release core or every other model.
|
||||
|
||||
## Model artifact identity and layout
|
||||
|
||||
A module named `models/<model-id>` publishes:
|
||||
|
||||
```text
|
||||
org.egothor:radixor-model-<model-id>:<model-version>
|
||||
```
|
||||
|
||||
The built PoliMorf JAR has this effective tree:
|
||||
|
||||
```text
|
||||
META-INF/
|
||||
LICENSES/PoliMorf-BSD-2-Clause.txt
|
||||
MANIFEST.MF
|
||||
radixor/
|
||||
models.index
|
||||
models/pl-pl-polimorf.properties
|
||||
org/egothor/stemmer/models/pl-pl-polimorf/stemmer.gz
|
||||
```
|
||||
|
||||
Each UniMorph-derived model instead contains one model-specific
|
||||
`META-INF/NOTICE/<model-id>-data.txt`. That notice records the upstream attribution, the Radixor
|
||||
transformations and contribution statement, the ShareAlike distribution terms, and the canonical
|
||||
CC BY-SA 3.0 URI. The repository has no root CC license directory because CC BY-SA applies to
|
||||
these model-data artifacts, not to the BSD-3-Clause Radixor Java software. PoliMorf retains only
|
||||
its BSD-2-Clause data license.
|
||||
|
||||
`models.index` contains the descriptor path. The descriptor contains the exact resource path. No Java provider class is required, and model modules do not compile against a core API.
|
||||
|
||||
## Discovery and integrity
|
||||
|
||||
`StemmerModelRegistry` asks the selected `ClassLoader` for every `META-INF/radixor/models.index`. It sorts index URLs, validates each non-comment entry, loads the named descriptors, sorts descriptors by model ID, and rejects duplicate IDs. It does not scan arbitrary JAR entries.
|
||||
|
||||
Descriptor parsing verifies:
|
||||
|
||||
- the model-ID syntax;
|
||||
- required nonblank runtime properties;
|
||||
- a known `Language` enum name;
|
||||
- format `radixor-dictionary-tsv-gzip` and format version `1`;
|
||||
- the exact namespaced resource path;
|
||||
- presence of the runtime resource;
|
||||
- a lowercase 64-character SHA-256 value.
|
||||
|
||||
Loading then reads the compressed resource bytes through the descriptor's discovering class loader, compares their SHA-256 digest, opens GZip, parses UTF-8 Radixor dictionary rows, and constructs a trie. Duplicate-ID and checksum checks make selection independent of classpath order.
|
||||
|
||||
## Descriptor fields
|
||||
|
||||
The convention plugin generates these fields:
|
||||
|
||||
| Property | Role | Meaning |
|
||||
|---|---|---|
|
||||
| `model.id` | Authoritative runtime identity | Stable model ID |
|
||||
| `model.version` | Authoritative artifact identity | Independently managed model version |
|
||||
| `model.language` | Authoritative selection metadata | Existing `Language` enum value |
|
||||
| `model.displayName` | Display metadata | Human-readable name |
|
||||
| `model.resource` | Authoritative loading metadata | Namespaced GZip resource |
|
||||
| `model.default` | Catalog/build declaration | Whether the module declares itself a default; runtime language selection uses `Language.defaultModelId()` |
|
||||
| `model.format` | Authoritative compatibility metadata | `radixor-dictionary-tsv-gzip` |
|
||||
| `model.formatVersion` | Authoritative compatibility metadata | Currently `1` |
|
||||
| `model.sha256` | Authoritative integrity metadata | Digest of the compressed source bytes |
|
||||
| `model.rightToLeft` | Processing metadata | Language direction recorded by the build |
|
||||
| `model.caseProcessing` | Processing metadata | `LOWERCASE_WITH_LOCALE_ROOT` |
|
||||
| `model.diacriticProcessing` | Processing metadata | `AS_IS` |
|
||||
| `model.storeOriginal` | Processing metadata | Currently `true` |
|
||||
| `source.name` | Provenance | Source dictionary name |
|
||||
| `source.version` | Provenance | Upstream version or the legacy-import sentinel |
|
||||
| `source.project` | Provenance | Upstream project |
|
||||
| `source.repository` | Provenance | Official language repository |
|
||||
| `source.dataset` | Provenance | Upstream dataset and lexical-source identity |
|
||||
| `source.revision` | Provenance | Exact revision or `not-recorded-in-legacy-import` |
|
||||
| `source.revisionStatus` | Provenance | `recorded` or `not-recorded-in-legacy-import` |
|
||||
| `source.license` | Provenance | SPDX or project license reference |
|
||||
| `source.licenseUri` | Provenance | Canonical license URI |
|
||||
| `source.attribution` | Provenance | Attribution supplied by the official source |
|
||||
| `source.verificationDate` | Provenance | Date the maintained upstream information was checked |
|
||||
| `transformations.summary` | Provenance | Material Radixor conversion operations |
|
||||
| `compiler.radixorVersion` | Provenance | Compiler lineage recorded by the plugin |
|
||||
| `compiler.radixorCommit` | Provenance | Commit when available; currently `unavailable` |
|
||||
| `statistics.groups` | Provenance/statistics | Currently `unavailable` |
|
||||
| `statistics.forms` | Provenance/statistics | Currently `unavailable` |
|
||||
|
||||
The current registry consumes the authoritative `model.*` identity, format, resource, and checksum fields. Processing and provenance fields remain packaged for audit and catalog generation but are not all exposed as typed `StemmerModelDescriptor` accessors. The generated catalog is the supported documentation view of source name, version, license, checksum, and size.
|
||||
|
||||
## Immutable input to runtime model
|
||||
|
||||
The packaging sequence is:
|
||||
|
||||
```text
|
||||
models/<id>/src/modelInput/stemmer.gz
|
||||
-> validate GZip, strict UTF-8, rows, metadata, version, and license
|
||||
-> copy identical bytes into build/generated/modelResources
|
||||
-> generate descriptor, index, and packaged license
|
||||
-> package radixor-model-<id>-<version>.jar
|
||||
-> discover from the application's runtime classpath
|
||||
-> verify checksum, parse dictionary, and build a trie
|
||||
```
|
||||
|
||||
Application runtime never reads `src/modelInput` from a source checkout.
|
||||
|
||||
For PoliMorf, the immutable input is exactly:
|
||||
|
||||
`models/pl-pl-polimorf/src/modelInput/stemmer.gz`
|
||||
|
||||
Its required upstream license is:
|
||||
|
||||
`models/pl-pl-polimorf/src/modelInput/LICENSE-BSD-2-Clause.txt`
|
||||
|
||||
The final runtime resource is exactly:
|
||||
|
||||
`org/egothor/stemmer/models/pl-pl-polimorf/stemmer.gz`
|
||||
|
||||
## Aggregate projects
|
||||
|
||||
| Project | Published coordinate | Contents and purpose |
|
||||
|---|---|---|
|
||||
| `models/standard` | `org.egothor:radixor-models-standard:<catalog-version>` | POM-only aggregate with one transitive runtime default per language; excludes PoliMorf |
|
||||
| `models/bom` | `org.egothor:radixor-models-bom:<catalog-version>` | POM-only Maven dependency-management constraints for all individual published model versions |
|
||||
|
||||
Neither catalog artifact publishes a binary, sources, or Javadoc JAR. The standard aggregate resolves model JARs because its POM contains runtime dependencies. Importing the BOM only manages versions and resolves no model by itself. JMH, tests, and quality evaluation depend directly on individual model projects through non-production Gradle configurations.
|
||||
|
||||
The Maven dependency BOM is not a software bill of materials. The root `cyclonedxDirectBom` task generates the project-wide CycloneDX SBOM under `build/reports/sbom/`; it does not write into `models/bom/build/`.
|
||||
|
||||
`models/build/` is an ignored Gradle output directory for the implicit lifecycle parent `:models`, not a source module. CycloneDX direct tasks exposed on subprojects by the root plugin are disabled, so the supported build does not write an SBOM there. Aggregate model reports are owned by the root project under `build/reports/models/`; individual model reports and publication files stay under `models/<model-id>/build/`.
|
||||
|
||||
## Create or update a model module
|
||||
|
||||
1. Choose a stable lowercase model ID matching the module directory.
|
||||
2. Add `models/<id>/model-version.txt`; do not derive it from core.
|
||||
3. Apply `org.egothor.radixor.model` in the module build script.
|
||||
4. Declare `modelId`, `language`, `displayName`, `defaultModel`, repository, dataset, revision and status, license URI, attribution, verification date, and transformations.
|
||||
5. Put immutable `stemmer.gz` and a model-specific `NOTICE-model-data.txt` under `src/modelInput/`. The notice must identify the applicable data license and canonical URI, upstream attribution, transformations, and derived-data contributions without implying that the core software uses that license.
|
||||
6. Add the module ID and its `default` or `optional` build-topology role to `models/model-projects.properties`. `settings.gradle`, verification, standard membership, BOM constraints, tests, and JMH all consume that list; descriptor metadata remains authoritative for model identity and language properties.
|
||||
7. Run:
|
||||
|
||||
```bash
|
||||
./gradlew --no-daemon :models:<model-id>:validateModelInput
|
||||
./gradlew --no-daemon :models:<model-id>:prepareModelResources
|
||||
./gradlew --no-daemon :models:<model-id>:verifyModelDescriptor
|
||||
./gradlew --no-daemon :models:<model-id>:verifyModelJar
|
||||
./gradlew --no-daemon :models:<model-id>:check
|
||||
./gradlew --no-daemon runtimeModelIntegrationTest -PmodelId=<model-id>
|
||||
```
|
||||
|
||||
Validation fails for missing inputs, notices, attribution, repository, revision status, Radixor contribution and transformation disclosures, ShareAlike and no-endorsement statements, notice byte identity, unsafe or mismatched ID, invalid semantic version, invalid GZip/UTF-8, invalid dictionary rows, checksum mismatch, wrong packaged path, duplicate dictionaries, or dictionaries in sources/Javadoc artifacts. The explicit legacy revision sentinel is valid; an absent revision or status is not. The PoliMorf module separately validates its complete BSD-2-Clause license and attribution.
|
||||
|
||||
Copying an arbitrary `stemmer.gz` into an application is insufficient: registry discovery requires an index, a valid descriptor, namespaced resource, checksum, version, language, format declaration, and licensing material.
|
||||
|
||||
## Release boundaries
|
||||
|
||||
| Tag | Publishes | Does not publish |
|
||||
|---|---|---|
|
||||
| `release@<core-version>` | Root `org.egothor:radixor` software artifacts | Model JARs, standard pack, or BOM |
|
||||
| `model/<model-id>@<model-version>` | Exactly the matching independently versioned model | Core, other models, standard pack, BOM, JMH, or full quality suite |
|
||||
| `models-catalog@<catalog-version>` | Standard aggregate and models BOM | Individual model JARs or core |
|
||||
|
||||
Local validation for PoliMorf 1.0.0 is:
|
||||
|
||||
```bash
|
||||
./tools/parse-model-release-tag.sh "model/pl-pl-polimorf@1.0.0" .
|
||||
./gradlew --no-daemon :models:pl-pl-polimorf:check
|
||||
./gradlew --no-daemon runtimeModelIntegrationTest -PmodelId=pl-pl-polimorf
|
||||
./gradlew --no-daemon :models:pl-pl-polimorf:validateModelRelease \
|
||||
-PmodelReleaseVersion=1.0.0
|
||||
./gradlew --no-daemon :models:pl-pl-polimorf:packageModelReleaseCandidate \
|
||||
-PmodelReleaseVersion=1.0.0
|
||||
```
|
||||
|
||||
`runtimeModelIntegrationTest` uses an isolated JVM, defaults to a 6 GiB maximum heap, and can be overridden with `-PradixorLargeModelMaxHeap=10g`. For PoliMorf, `validateModelRelease` depends on this complete runtime construction and real stemming smoke verification in addition to descriptor, checksum, license, and package validation. The generic release workflow still selects and publishes only the requested model. The commands above are local validation only; repository owners control tags and publication.
|
||||
|
||||
## Documentation and troubleshooting
|
||||
|
||||
`prepareMkDocsSource` generates the catalog only at `build/mkdocs-source/stemmer-model-catalog.md`; generated Markdown and rendered site content are not tracked. For runtime failures, dependency inspection, ClassLoader isolation, and fat-JAR guidance, see [Model Selection and Loading](model-selection-and-loading.md#troubleshooting).
|
||||
@@ -1,12 +1,16 @@
|
||||
# Stemming quality evaluation
|
||||
|
||||
The explicit `stemmingQuality` analysis measures agreement between stemmer outputs and gold-standard equivalence classes represented by bundled multilingual dictionary rows. Dictionary text remains unchanged; reports and diagnostics use English.
|
||||
The explicit `stemmingQuality` analysis measures agreement between stemmer outputs and gold-standard equivalence classes represented by registered multilingual model dictionary rows. Dictionary text remains unchanged; reports and diagnostics use English.
|
||||
|
||||
JMH adapters, registries, third-party versions, language mappings, and preparation remain in `src/jmh`. The evaluator, reports, audits, and tests reside in the standard `src/test` source set. The former `src/stemmingQualityTest` source set was removed, and neither analytical nor JMH classes enter the production JAR.
|
||||
|
||||
## Language and adapter coverage
|
||||
|
||||
The authoritative Radixor universe is the validated one-to-one reconciliation of `src/main/resources/*/stemmer.gz` and every `StemmerPatchTrieLoader.Language` value. All 20 current values have exactly one resource; no sentinel or alias is excluded. Radixor is evaluated for all 20 languages, independently of third-party support. Third-party combinations come only from explicit JMH adapter metadata. Unsupported combinations are documented and never fabricated as zero-valued rows.
|
||||
The authoritative Radixor universe is the validated one-to-one reconciliation of every `StemmerPatchTrieLoader.Language` value with its registered default model descriptor. All 20 current values have exactly one documented default. Optional comparison models, including `pl-pl-polimorf`, are identified separately and never replace default benchmark rows. Third-party combinations come only from explicit JMH adapter metadata.
|
||||
|
||||
Default Polish evaluation is therefore `Radixor` with model `pl-pl-unimorph`. A future PoliMorf evaluation is a distinct `Radixor` / `pl-pl-polimorf` row. Evaluation classpaths receive individual models through direct non-production Gradle dependencies; ordinary applications inherit none of them from the core.
|
||||
|
||||
Complete PoliMorf trie construction and deterministic stemming smoke fixtures are runtime-verified separately. That functional verification is not a linguistic-quality measurement and does not justify rewriting the historical quality snapshot.
|
||||
|
||||
The expected matrix is constructed before evaluation from stemmer, language, dictionary mode, and supported output policy. Generation fails on missing, duplicate, unexpected, or stale keys.
|
||||
|
||||
@@ -80,3 +84,4 @@ Generated files under `build/reports/stemming-quality/` include `stemming-qualit
|
||||
## Limitations
|
||||
|
||||
These measurements evaluate agreement with the available dictionary grouping. They do not capture every semantic, morphological, downstream, or dataset-specific property. `ANY_CANDIDATE` is optimistic and may not be globally realizable. `ALL_CANDIDATES` measures an overlap graph rather than a partition. Language coverage must remain visible in cross-stemmer comparisons. No single published metric establishes universal superiority; multiple metrics and their correlations are provided for transparent scientific assessment.
|
||||
Historical checked-in quality results retain their original inputs and claims. The optional PoliMorf model is not attributed to snapshots that predate it. See [Model Selection and Loading](model-selection-and-loading.md) and the generated [model catalog](stemmer-model-catalog.md).
|
||||
|
||||
Reference in New Issue
Block a user