diff --git a/.gitattributes b/.gitattributes index f91f646..5c563d9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9,4 +9,4 @@ # Binary files should be left untouched *.jar binary - +*.gz binary diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index fdf18c2..2252957 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -10,6 +10,8 @@ on: paths: - 'src/main/**' - 'src/jmh/**' + - 'models/**' + - 'build-logic/**' - 'build.gradle' - 'gradle.properties' - 'gradle.lockfile' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index eb5a5b6..c422995 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -51,7 +51,7 @@ jobs: test -f gradle/verification-metadata.xml - name: Execute build, tests, PMD, coverage, Javadoc, distribution packaging, and SBOM generation - run: ./gradlew --no-daemon clean ciRelease distZip pmdMain javadoc jacocoCiReleaseReport cyclonedxBom + run: ./gradlew --no-daemon clean ciRelease distZip pmdMain javadoc jacocoCiReleaseReport :cyclonedxDirectBom - name: Upload SBOM if: always() @@ -156,11 +156,14 @@ jobs: test -f gradle.properties test -f gradle/verification-metadata.xml + - name: Validate exact core release tag + run: ./tools/parse-model-release-tag.sh "${GITHUB_REF_NAME}" . + - name: Build release inputs, signed Maven bundle, and SBOM env: SIGNING_KEY: ${{ secrets.SIGNING_KEY }} SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} - run: ./gradlew --no-daemon clean ciRelease distZip pmdMain javadoc jacocoCiReleaseReport cyclonedxBom centralBundle + run: ./gradlew --no-daemon clean ciRelease distZip pmdMain javadoc jacocoCiReleaseReport :cyclonedxDirectBom centralBundle - name: Generate release changelog shell: bash @@ -177,24 +180,7 @@ jobs: shell: bash env: CENTRAL_BEARER_TOKEN: ${{ secrets.CENTRAL_BEARER_TOKEN }} - run: | - set -euo pipefail - echo "::add-mask::$CENTRAL_BEARER_TOKEN" - - BUNDLE="$(ls build/central-bundle/*.zip)" - HEADER_FILE="$(mktemp)" - trap 'rm -f "$HEADER_FILE"' EXIT - printf 'Authorization: Bearer %s\n' "$CENTRAL_BEARER_TOKEN" > "$HEADER_FILE" - - curl \ - --fail \ - --silent \ - --show-error \ - --request POST \ - --header @"$HEADER_FILE" \ - --form "bundle=@${BUNDLE}" \ - --form "name=org.egothor:radixor:${GITHUB_REF_NAME#release@}" \ - "https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC" + run: ./tools/publish-central-bundle.sh "$(ls build/central-bundle/*.zip)" "org.egothor:radixor:${GITHUB_REF_NAME#release@}" - name: Publish GitHub release assets uses: softprops/action-gh-release@v2 diff --git a/.github/workflows/catalog-release.yml b/.github/workflows/catalog-release.yml new file mode 100644 index 0000000..2028bc4 --- /dev/null +++ b/.github/workflows/catalog-release.yml @@ -0,0 +1,37 @@ +name: Model Catalog Release + +on: + push: + tags: + - 'models-catalog@*' + +permissions: + contents: read + +concurrency: + group: model-catalog-${{ github.ref_name }} + cancel-in-progress: false + +jobs: + catalog: + runs-on: ubuntu-latest + environment: maven-central + steps: + - uses: actions/checkout@v4 + - uses: gradle/actions/wrapper-validation@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + - uses: gradle/actions/setup-gradle@v4 + - name: Validate catalog tag + run: ./tools/parse-model-release-tag.sh "${GITHUB_REF_NAME}" . + - name: Build only signed catalog metadata + env: + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + run: ./gradlew --no-daemon verifyModelCatalogReleaseCandidate + - name: Publish only catalog metadata + env: + CENTRAL_BEARER_TOKEN: ${{ secrets.CENTRAL_BEARER_TOKEN }} + run: ./tools/publish-central-bundle.sh "build/model-catalog-release-candidate/radixor-models-catalog-${GITHUB_REF_NAME#models-catalog@}-central-bundle.zip" "org.egothor:radixor-models-catalog:${GITHUB_REF_NAME#models-catalog@}" diff --git a/.github/workflows/model-release.yml b/.github/workflows/model-release.yml new file mode 100644 index 0000000..7bfdf19 --- /dev/null +++ b/.github/workflows/model-release.yml @@ -0,0 +1,147 @@ +name: Model Release + +on: + push: + tags: + - 'model/*@*' + workflow_dispatch: + inputs: + tag: + description: Model tag to validate without publishing + required: true + type: string + +permissions: + contents: read + +concurrency: + group: model-release-${{ github.event_name == 'push' && github.ref_name || inputs.tag }} + cancel-in-progress: false + +jobs: + validate: + name: Validate selected model + runs-on: ubuntu-latest + outputs: + model_id: ${{ steps.release.outputs.MODEL_ID }} + model_version: ${{ steps.release.outputs.MODEL_VERSION }} + gradle_project: ${{ steps.release.outputs.GRADLE_PROJECT }} + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v4 + + - name: Set up Temurin JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + + - name: Set up Gradle caching and instrumentation + uses: gradle/actions/setup-gradle@v4 + + - name: Verify reproducibility inputs + shell: bash + run: | + set -euo pipefail + test -f gradle.lockfile + test -f gradle.properties + test -f gradle/verification-metadata.xml + + - name: Validate and select exactly one model + id: release + shell: bash + env: + REQUESTED_TAG: ${{ inputs.tag }} + run: | + set -euo pipefail + + if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then + tag="${GITHUB_REF_NAME}" + else + tag="${REQUESTED_TAG}" + fi + + ./tools/parse-model-release-tag.sh "${tag}" . >> "${GITHUB_OUTPUT}" + git merge-base --is-ancestor "${GITHUB_SHA}" origin/main + + - name: Validate one model + shell: bash + run: | + set -euo pipefail + + project="${{ steps.release.outputs.GRADLE_PROJECT }}" + version="${{ steps.release.outputs.MODEL_VERSION }}" + + ./gradlew --no-daemon "${project}:clean" + ./gradlew --no-daemon "${project}:check" + ./gradlew --no-daemon \ + "${project}:validateModelRelease" \ + -PmodelReleaseVersion="${version}" + + publish: + name: Publish selected model + if: github.event_name == 'push' + needs: validate + runs-on: ubuntu-latest + environment: maven-central + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Validate Gradle wrapper + uses: gradle/actions/wrapper-validation@v4 + + - name: Set up Temurin JDK 21 + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + + - name: Set up Gradle caching and instrumentation + uses: gradle/actions/setup-gradle@v4 + + - name: Verify reproducibility inputs + shell: bash + run: | + set -euo pipefail + test -f gradle.lockfile + test -f gradle.properties + test -f gradle/verification-metadata.xml + + - name: Build signed model release candidate + shell: bash + env: + SIGNING_KEY: ${{ secrets.SIGNING_KEY }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }} + run: | + set -euo pipefail + + project="${{ needs.validate.outputs.gradle_project }}" + version="${{ needs.validate.outputs.model_version }}" + + ./gradlew --no-daemon \ + "${project}:packageModelReleaseCandidate" \ + -PmodelReleaseVersion="${version}" + + - name: Publish one model + shell: bash + env: + CENTRAL_BEARER_TOKEN: ${{ secrets.CENTRAL_BEARER_TOKEN }} + run: | + set -euo pipefail + + model_id="${{ needs.validate.outputs.model_id }}" + version="${{ needs.validate.outputs.model_version }}" + + ./tools/publish-central-bundle.sh \ + "models/${model_id}/build/model-release-candidate/central-bundle.zip" \ + "org.egothor:radixor-model-${model_id}:${version}" diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index ea67c07..51bd56e 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -10,6 +10,8 @@ on: - 'src/main/**' - 'src/test/**' - 'src/jmh/**' + - 'models/**' + - 'build-logic/**' - 'build.gradle' - 'gradle.properties' - 'gradle.lockfile' @@ -70,7 +72,7 @@ jobs: test -f gradle/verification-metadata.xml - name: Build reports for publication - run: ./gradlew --no-daemon clean ciRelease pmdMain javadoc jacocoCiReleaseReport pitest jmh -Pjmh.includes='.*EnglishStemmerComparisonBenchmark.*' cyclonedxBom + run: ./gradlew --no-daemon clean ciRelease pmdMain javadoc jacocoCiReleaseReport pitest jmh -Pjmh.includes='.*EnglishStemmerComparisonBenchmark.*' :cyclonedxDirectBom - name: Prepare gh-pages worktree shell: bash @@ -88,6 +90,9 @@ jobs: cd .. fi + - name: Prepare staged MkDocs source + run: ./gradlew --no-daemon prepareMkDocsSource verifyModelCatalogDocumentation + - name: Stage published reports shell: bash run: | @@ -246,7 +251,7 @@ jobs: cp "${RUN_DIR}/index.html" "${LATEST_DIR}/index.html" - cat > docs/reports.md < build/mkdocs-source/reports.md < docs/builds.md + } > build/mkdocs-source/builds.md - name: Build documentation site (MkDocs Material) shell: bash run: | set -euo pipefail - mkdocs build --strict --site-dir .mkdocs-site - rsync -a --delete --exclude '.git' --exclude '.git/' --exclude 'builds/' .mkdocs-site/ .gh-pages/ + mkdocs build --strict --config-file build/mkdocs/mkdocs.yml + rsync -a --delete --exclude '.git' --exclude '.git/' --exclude 'builds/' build/mkdocs-site/ .gh-pages/ mkdir -p .gh-pages/builds - cp .mkdocs-site/builds/index.html .gh-pages/builds/index.html + cp build/mkdocs-site/builds/index.html .gh-pages/builds/index.html cat > .gh-pages/.nojekyll <' + runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph:1.0.0' + // Or: runtimeOnly 'org.egothor:radixor-models-standard:' +} +``` + +```java +final FrequencyTrie polish = + StemmerPatchTrieLoader.loadCompiled( + StemmerPatchTrieLoader.Language.PL_PL, + true, + ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS); +``` + +`Language.PL_PL` selects the documented default `pl-pl-unimorph`. The optional `pl-pl-polimorf` model requires its own runtime artifact and explicit selection; adding it does not change the default. See [Model Selection and Loading](docs/model-selection-and-loading.md) for complete executable examples and [Stemmer Models](docs/stemmer-models.md) for artifact concepts. + +`radixor-models-standard` is a POM-only runtime aggregate: it brings the 20 default model JARs transitively but publishes no empty aggregate JAR. `radixor-models-bom` is the separate POM-only Maven dependency BOM for version management; importing it alone adds no model. The root CycloneDX SBOM report is unrelated to that dependency BOM. + +```java +final FrequencyTrie polimorf = + StemmerPatchTrieLoader.loadCompiled( + "pl-pl-polimorf", + true, + ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS); +``` + +Complete PoliMorf construction is supported but unusually memory-intensive: the dedicated verification task uses a 6 GiB maximum heap. Applications should load and retain the resulting immutable trie during startup rather than rebuilding it per request. + ## Table of Contents - [Why Radixor](#why-radixor) @@ -138,7 +172,7 @@ Compared with the historical baseline, Radixor emphasizes: - Compressed binary persistence - Programmatic compilation and loading - CLI compilation tool -- Bundled language resources +- Independently versioned language-model resources - Support for extending compiled stemmer tables - Reproducible and auditable engineering posture @@ -149,16 +183,16 @@ The repository keeps the front page concise and places detailed documentation un ### Getting Started - [Fast Track](docs/fast-track.md) - The shortest path from adding the dependency to getting a first stem from a bundled dictionary. + The shortest path from adding core plus a model artifact to getting a first stem. - [Quick Start](docs/quick-start.md) A broader developer walkthrough covering loading options, querying, extension, persistence, and metadata. - [Integration Deep Dive](docs/integration-deep-dive.md) - Dependency setup, bundled dictionary selection, production lifecycle, search-pipeline guidance, and operational checklist. + Dependency setup, model selection, production lifecycle, search-pipeline guidance, and operational checklist. - [Built-in Languages](docs/built-in-languages.md) - Overview of bundled language resources such as `US_UK`. + Language enum values, default model IDs, artifacts, and optional variants. - [Dictionary Format](docs/dictionary-format.md) How to write and normalize stemming dictionaries. @@ -171,6 +205,9 @@ The repository keeps the front page concise and places detailed documentation un - [Programmatic Usage Overview](docs/programmatic-usage.md) Entry point to the Java API and the overall usage model. +- [Model Selection and Loading](docs/model-selection-and-loading.md) + Default, explicit, dual-model, ClassLoader, dependency, and troubleshooting examples. + - [Loading and Building Stemmers](docs/programmatic-loading-and-building.md) Loading bundled resources, textual dictionaries, binary artifacts, and direct builder usage. @@ -245,3 +282,19 @@ The goal is to keep the Egothor/Stempel lineage useful as a serious contemporary ## Historical note Egothor showed that stemming could be both algorithmic and compact. Stempel proved that the approach was practical enough to survive inside major search ecosystems. Radixor continues that tradition with a modernized implementation focused on production use, maintainability, and controlled evolution. +# Radixor 4 artifact architecture + +The established `org.egothor:radixor` artifact remains the algorithmic core and contains no language-model data. From version 4 onward, applications explicitly add individual `org.egothor:radixor-model-` runtime artifacts or the optional metadata-only `org.egothor:radixor-models-standard` aggregate. Polish defaults to `pl-pl-unimorph`; `pl-pl-polimorf` is opt-in. See [Stemmer Models](docs/stemmer-models.md) and [Migration and Backward Compatibility](docs/migration-and-backward-compatibility.md). + +Radixor Java software remains licensed under BSD-3-Clause. UniMorph-derived model data is +distributed under CC BY-SA 3.0, with upstream attribution, the canonical license URI, Radixor +transformations, and Leo Galambos's limited contribution notice carried by each model artifact. +PoliMorf model data retains its separate BSD-2-Clause license. There is no project-wide CC license +directory because the root artifact contains no model data. + +```groovy +dependencies { + implementation 'org.egothor:radixor:4.0.0' + runtimeOnly 'org.egothor:radixor-model-pl-pl-polimorf:1.0.0' +} +``` diff --git a/build-logic/build.gradle b/build-logic/build.gradle new file mode 100644 index 0000000..5bb158f --- /dev/null +++ b/build-logic/build.gradle @@ -0,0 +1,25 @@ +plugins { + id 'groovy-gradle-plugin' +} + +dependencies { + testImplementation 'org.junit.jupiter:junit-jupiter:5.14.3' + testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.14.3' +} + +tasks.named('test') { + useJUnitPlatform() +} + +gradlePlugin { + plugins { + radixorModel { + id = 'org.egothor.radixor.model' + implementationClass = 'org.egothor.radixor.RadixorModelPlugin' + } + radixorBuildSupport { + id = 'org.egothor.radixor.build-support' + implementationClass = 'org.egothor.radixor.RadixorBuildSupportPlugin' + } + } +} diff --git a/build-logic/settings.gradle b/build-logic/settings.gradle new file mode 100644 index 0000000..42b57b6 --- /dev/null +++ b/build-logic/settings.gradle @@ -0,0 +1,8 @@ +rootProject.name = 'radixor-build-logic' + +dependencyResolutionManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } +} diff --git a/build-logic/src/main/groovy/org/egothor/radixor/MockitoAgentArgumentProvider.groovy b/build-logic/src/main/groovy/org/egothor/radixor/MockitoAgentArgumentProvider.groovy new file mode 100644 index 0000000..c453899 --- /dev/null +++ b/build-logic/src/main/groovy/org/egothor/radixor/MockitoAgentArgumentProvider.groovy @@ -0,0 +1,21 @@ +package org.egothor.radixor + +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.tasks.Classpath +import org.gradle.process.CommandLineArgumentProvider + +import javax.inject.Inject + +abstract class MockitoAgentArgumentProvider implements CommandLineArgumentProvider { + @Classpath + abstract ConfigurableFileCollection getAgentClasspath() + + @Inject + MockitoAgentArgumentProvider() { + } + + @Override + Iterable asArguments() { + return ["-javaagent:${agentClasspath.singleFile.absolutePath}"] + } +} diff --git a/build-logic/src/main/groovy/org/egothor/radixor/PrepareModelConsumerRepositoryTask.groovy b/build-logic/src/main/groovy/org/egothor/radixor/PrepareModelConsumerRepositoryTask.groovy new file mode 100644 index 0000000..d8b62cb --- /dev/null +++ b/build-logic/src/main/groovy/org/egothor/radixor/PrepareModelConsumerRepositoryTask.groovy @@ -0,0 +1,105 @@ +package org.egothor.radixor + +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.file.ConfigurableFileCollection +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.InputFiles +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.TaskAction + +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardCopyOption +import java.util.stream.Stream + +/** Builds the isolated Maven-layout repository used by consumer resolution tests. */ +abstract class PrepareModelConsumerRepositoryTask extends DefaultTask { + @Input abstract Property getCoreVersion() + @Input abstract Property getCatalogVersion() + @Input abstract MapProperty getModelVersions() + + @InputFile @PathSensitive(PathSensitivity.RELATIVE) + abstract RegularFileProperty getCorePom() + + @InputFile @PathSensitive(PathSensitivity.RELATIVE) + abstract RegularFileProperty getCoreJar() + + @InputFiles @PathSensitive(PathSensitivity.RELATIVE) + abstract ConfigurableFileCollection getModelPoms() + + @InputFiles @PathSensitive(PathSensitivity.RELATIVE) + abstract ConfigurableFileCollection getModelJars() + + @InputFile @PathSensitive(PathSensitivity.RELATIVE) + abstract RegularFileProperty getStandardPom() + + @InputFile @PathSensitive(PathSensitivity.RELATIVE) + abstract RegularFileProperty getBomPom() + + @OutputDirectory + abstract DirectoryProperty getRepositoryDirectory() + + /** Creates the repository using only declared task state and Java file APIs. */ + @TaskAction + void prepareRepository() { + final Path repository = repositoryDirectory.get().asFile.toPath() + deleteTree(repository) + Files.createDirectories(repository) + install(repository, 'radixor', coreVersion.get(), corePom.get().asFile.toPath(), coreJar.get().asFile.toPath()) + + final Map pomsByModel = indexModelFiles(modelPoms.files) + final Map jarsByModel = indexModelFiles(modelJars.files) + modelVersions.get().toSorted().each { String modelId, String modelVersion -> + final Path pom = pomsByModel.get(modelId) + final Path jar = jarsByModel.get(modelId) + if (pom == null || jar == null) { + throw new GradleException("Missing generated publication input for model ${modelId}.") + } + PrepareModelConsumerRepositoryTask.install( + repository, "radixor-model-${modelId}", modelVersion, pom, jar) + } + install(repository, 'radixor-models-standard', catalogVersion.get(), standardPom.get().asFile.toPath(), null) + install(repository, 'radixor-models-bom', catalogVersion.get(), bomPom.get().asFile.toPath(), null) + } + + private static Map indexModelFiles(final Set files) { + final Map indexed = [:] + files.each { File file -> + Path cursor = file.toPath().toAbsolutePath().parent + while (cursor != null && cursor.fileName.toString() != 'build') cursor = cursor.parent + if (cursor == null || cursor.parent == null) { + throw new GradleException("Cannot determine model ID from generated input ${file}.") + } + final String modelId = cursor.parent.fileName.toString() + if (indexed.put(modelId, file.toPath()) != null) { + throw new GradleException("Duplicate generated publication input for model ${modelId}.") + } + } + return indexed + } + + private static void install(final Path repository, final String artifactId, final String version, + final Path pom, final Path jar) { + final Path module = repository.resolve("org/egothor/${artifactId}/${version}") + Files.createDirectories(module) + Files.copy(pom, module.resolve("${artifactId}-${version}.pom"), StandardCopyOption.REPLACE_EXISTING) + if (jar != null) { + Files.copy(jar, module.resolve("${artifactId}-${version}.jar"), StandardCopyOption.REPLACE_EXISTING) + } + } + + private static void deleteTree(final Path directory) { + if (!Files.exists(directory)) return + Files.walk(directory).withCloseable { Stream paths -> + paths.sorted(Comparator.reverseOrder()).forEach(Files::delete) + } + } +} diff --git a/build-logic/src/main/groovy/org/egothor/radixor/PrepareModelResourcesTask.groovy b/build-logic/src/main/groovy/org/egothor/radixor/PrepareModelResourcesTask.groovy new file mode 100644 index 0000000..05cd59b --- /dev/null +++ b/build-logic/src/main/groovy/org/egothor/radixor/PrepareModelResourcesTask.groovy @@ -0,0 +1,108 @@ +package org.egothor.radixor + +import org.gradle.api.DefaultTask +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.TaskAction + +import java.nio.file.Files +import java.nio.file.Path +import java.nio.file.StandardCopyOption +import java.security.MessageDigest +import java.util.stream.Stream + +/** Generates one model's deterministic resource tree without retaining Project state. */ +abstract class PrepareModelResourcesTask extends DefaultTask { + @InputFile @PathSensitive(PathSensitivity.RELATIVE) abstract RegularFileProperty getDictionaryFile() + @InputFile @PathSensitive(PathSensitivity.RELATIVE) abstract RegularFileProperty getVersionFile() + @Optional @InputFile @PathSensitive(PathSensitivity.RELATIVE) abstract RegularFileProperty getLicenseFile() + @Optional @InputFile @PathSensitive(PathSensitivity.RELATIVE) abstract RegularFileProperty getNoticeFile() + @Input abstract Property getShareAlike() + @Input abstract MapProperty getDescriptorValues() + @OutputDirectory abstract DirectoryProperty getGeneratedDirectory() + + /** Copies bounded inputs and writes descriptor and index files. */ + @TaskAction + void prepareResources() { + final Path generated = generatedDirectory.get().asFile.toPath() + deleteTree(generated) + final Map values = descriptorValues.get() + final String id = values['model.id'] + final String resource = "org/egothor/stemmer/models/${id}/stemmer.gz" + final Path dictionaryTarget = generated.resolve(resource) + Files.createDirectories(dictionaryTarget.parent) + Files.copy(dictionaryFile.get().asFile.toPath(), dictionaryTarget, StandardCopyOption.REPLACE_EXISTING) + + final Path descriptor = generated.resolve("META-INF/radixor/models/${id}.properties") + Files.createDirectories(descriptor.parent) + Files.writeString(descriptor, descriptorText(values, + versionFile.get().asFile.getText('UTF-8').trim(), resource, sha256(dictionaryFile.get().asFile))) + final Path index = generated.resolve('META-INF/radixor/models.index') + Files.createDirectories(index.parent) + Files.writeString(index, "META-INF/radixor/models/${id}.properties\n") + + if (shareAlike.get()) { + final Path notice = generated.resolve("META-INF/NOTICE/${id}-data.txt") + Files.createDirectories(notice.parent) + Files.copy(noticeFile.get().asFile.toPath(), notice, StandardCopyOption.REPLACE_EXISTING) + } else { + final Path license = generated.resolve('META-INF/LICENSES/PoliMorf-BSD-2-Clause.txt') + Files.createDirectories(license.parent) + Files.copy(licenseFile.get().asFile.toPath(), license, StandardCopyOption.REPLACE_EXISTING) + } + } + + private static String descriptorText(final Map value, final String version, + final String resource, final String checksum) { + return """model.id=${value['model.id']} +model.version=${version} +model.language=${value['model.language']} +model.displayName=${value['model.displayName']} +model.resource=${resource} +model.default=${value['model.default']} +model.format=radixor-dictionary-tsv-gzip +model.formatVersion=1 +model.sha256=${checksum} +model.rightToLeft=${['FA_IR', 'HE_IL', 'YI'].contains(value['model.language'])} +model.caseProcessing=LOWERCASE_WITH_LOCALE_ROOT +model.diacriticProcessing=AS_IS +model.storeOriginal=true +source.name=${value['source.name']} +source.version=${value['source.version']} +source.project=${value['source.project']} +source.repository=${value['source.repository']} +source.dataset=${value['source.dataset']} +source.revision=${value['source.revision']} +source.revisionStatus=${value['source.revisionStatus']} +source.license=${value['source.license']} +source.licenseUri=${value['source.licenseUri']} +source.attribution=${value['source.attribution']} +source.verificationDate=${value['source.verificationDate']} +transformations.summary=${value['transformations.summary']} +compiler.radixorVersion=3.x +compiler.radixorCommit=unavailable +statistics.groups=unavailable +statistics.forms=unavailable +""" + } + + private static String sha256(final File file) { + return MessageDigest.getInstance('SHA-256').digest(file.bytes) + .collect { byte value -> String.format('%02x', value & 0xff) }.join() + } + + private static void deleteTree(final Path directory) { + if (!Files.exists(directory)) return + Files.walk(directory).withCloseable { Stream paths -> + paths.sorted(Comparator.reverseOrder()).forEach(Files::delete) + } + } +} diff --git a/build-logic/src/main/groovy/org/egothor/radixor/RadixorBuildSupportPlugin.groovy b/build-logic/src/main/groovy/org/egothor/radixor/RadixorBuildSupportPlugin.groovy new file mode 100644 index 0000000..78e1d00 --- /dev/null +++ b/build-logic/src/main/groovy/org/egothor/radixor/RadixorBuildSupportPlugin.groovy @@ -0,0 +1,16 @@ +package org.egothor.radixor + +import org.gradle.api.Plugin +import org.gradle.api.Project + +/** Exposes typed repository build-support tasks to the root build. */ +final class RadixorBuildSupportPlugin implements Plugin { + /** Registers build-support tasks without inspecting project state during execution. */ + @Override + void apply(final Project project) { + project.tasks.register('prepareModelConsumerTestRepository', PrepareModelConsumerRepositoryTask) { + group = 'verification' + description = 'Creates an isolated local Maven repository for model dependency-resolution integration tests.' + } + } +} diff --git a/build-logic/src/main/groovy/org/egothor/radixor/RadixorModelExtension.groovy b/build-logic/src/main/groovy/org/egothor/radixor/RadixorModelExtension.groovy new file mode 100644 index 0000000..ce04f46 --- /dev/null +++ b/build-logic/src/main/groovy/org/egothor/radixor/RadixorModelExtension.groovy @@ -0,0 +1,73 @@ +package org.egothor.radixor + +import org.gradle.api.model.ObjectFactory +import org.gradle.api.provider.Property + +import javax.inject.Inject + +/** Declarative configuration for one independently published Radixor model. */ +abstract class RadixorModelExtension { + /** Stable model identifier. */ + abstract Property getModelId() + + /** Radixor language enum constant. */ + abstract Property getLanguage() + + /** Human-readable model name. */ + abstract Property getDisplayName() + + /** Whether this is the documented default for its language. */ + abstract Property getDefaultModel() + + /** Source dictionary name. */ + abstract Property getSourceName() + + /** Source dictionary version or explicit unavailable marker. */ + abstract Property getSourceVersion() + + /** Exact upstream revision or the explicit legacy-import sentinel. */ + abstract Property getSourceRevision() + + /** Upstream source project. */ + abstract Property getSourceProject() + + /** Official upstream repository URL. */ + abstract Property getSourceRepository() + + /** Upstream dataset identity. */ + abstract Property getSourceDataset() + + /** Whether the source revision is recorded or was not recorded by a legacy import. */ + abstract Property getSourceRevisionStatus() + + /** SPDX license identifier. */ + abstract Property getSourceLicense() + + /** Canonical URI for the source-data license. */ + abstract Property getSourceLicenseUri() + + /** Upstream attribution supplied with the source data. */ + abstract Property getSourceAttribution() + + /** Date on which the upstream metadata was verified. */ + abstract Property getSourceVerificationDate() + + /** Material transformations applied by Radixor. */ + abstract Property getTransformationsSummary() + + /** Model-specific data notice input file name, when required. */ + abstract Property getNoticeFileName() + + /** License input file name. */ + abstract Property getLicenseFileName() + + /** Creates the extension. */ + @Inject + RadixorModelExtension(final ObjectFactory objects) { + defaultModel.convention(false) + sourceVersion.convention('unavailable') + sourceLicense.convention('LicenseRef-Radixor-Stemmer-Data') + licenseFileName.convention('LICENSE-stemmer-data.txt') + noticeFileName.convention('NOTICE-model-data.txt') + } +} diff --git a/build-logic/src/main/groovy/org/egothor/radixor/RadixorModelPlugin.groovy b/build-logic/src/main/groovy/org/egothor/radixor/RadixorModelPlugin.groovy new file mode 100644 index 0000000..c5bed2d --- /dev/null +++ b/build-logic/src/main/groovy/org/egothor/radixor/RadixorModelPlugin.groovy @@ -0,0 +1,505 @@ +package org.egothor.radixor + +import org.gradle.api.GradleException +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.api.file.DuplicatesStrategy +import org.gradle.api.plugins.JavaPlugin +import org.gradle.api.publish.PublishingExtension +import org.gradle.api.publish.maven.MavenPublication +import org.gradle.api.tasks.Copy +import org.gradle.api.tasks.bundling.Jar +import org.gradle.api.tasks.bundling.Zip +import org.gradle.plugins.signing.SigningExtension + +import java.nio.charset.CodingErrorAction +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.security.MessageDigest +import java.util.zip.GZIPInputStream + +/** Configures validation, generation, packaging, and publication for one model artifact. */ +final class RadixorModelPlugin implements Plugin { + /** Applies the model convention to a project. */ + @Override + void apply(final Project project) { + project.pluginManager.apply(JavaPlugin) + project.pluginManager.apply('maven-publish') + project.pluginManager.apply('signing') + project.java { + withSourcesJar() + withJavadocJar() + sourceCompatibility = org.gradle.api.JavaVersion.VERSION_21 + targetCompatibility = org.gradle.api.JavaVersion.VERSION_21 + } + final RadixorModelExtension model = project.extensions.create('radixorModel', RadixorModelExtension) + project.group = 'org.egothor' + project.version = project.providers.gradleProperty('modelReleaseVersion') + .orElse(project.providers.fileContents(project.layout.projectDirectory.file('model-version.txt')).asText.map(String::trim)) + .get() + + final File input = project.file('src/modelInput/stemmer.gz') + final File generated = project.layout.buildDirectory.dir('generated/modelResources').get().asFile + project.sourceSets.main.resources.setSrcDirs([generated]) + + final def validate = project.tasks.register('validateModelInput', ValidateModelInputTask) { + group = 'verification' + description = 'Validates the immutable source dictionary, metadata, version, and model-specific licensing material.' + dictionaryFile = project.layout.projectDirectory.file('src/modelInput/stemmer.gz') + versionFile = project.layout.projectDirectory.file('model-version.txt') + modelId = model.modelId + moduleName = project.name + shareAlike = model.sourceLicense.map { String license -> license == 'CC-BY-SA-3.0' } + metadata.put('source.project', model.sourceProject) + metadata.put('source.repository', model.sourceRepository) + metadata.put('source.dataset', model.sourceDataset) + metadata.put('source.revision', model.sourceRevision) + metadata.put('source.revisionStatus', model.sourceRevisionStatus) + metadata.put('source.license', model.sourceLicense) + metadata.put('source.licenseUri', model.sourceLicenseUri) + metadata.put('source.attribution', model.sourceAttribution) + metadata.put('source.verificationDate', model.sourceVerificationDate) + metadata.put('transformations.summary', model.transformationsSummary) + } + + final def prepare = project.tasks.register('prepareModelResources', PrepareModelResourcesTask) { + group = 'build' + description = 'Copies validated dictionary bytes and generates the immutable model descriptor and index.' + dependsOn(validate) + dictionaryFile = project.layout.projectDirectory.file('src/modelInput/stemmer.gz') + versionFile = project.layout.projectDirectory.file('model-version.txt') + shareAlike = model.sourceLicense.map { String license -> license == 'CC-BY-SA-3.0' } + generatedDirectory = project.layout.buildDirectory.dir('generated/modelResources') + descriptorValues.put('model.id', model.modelId) + descriptorValues.put('model.language', model.language) + descriptorValues.put('model.displayName', model.displayName) + descriptorValues.put('model.default', model.defaultModel.map(String::valueOf)) + descriptorValues.put('source.name', model.sourceName) + descriptorValues.put('source.version', model.sourceVersion) + descriptorValues.put('source.project', model.sourceProject) + descriptorValues.put('source.repository', model.sourceRepository) + descriptorValues.put('source.dataset', model.sourceDataset) + descriptorValues.put('source.revision', model.sourceRevision) + descriptorValues.put('source.revisionStatus', model.sourceRevisionStatus) + descriptorValues.put('source.license', model.sourceLicense) + descriptorValues.put('source.licenseUri', model.sourceLicenseUri) + descriptorValues.put('source.attribution', model.sourceAttribution) + descriptorValues.put('source.verificationDate', model.sourceVerificationDate) + descriptorValues.put('transformations.summary', model.transformationsSummary) + } + project.afterEvaluate { + final boolean shareAlike = model.sourceLicense.get() == 'CC-BY-SA-3.0' + if (shareAlike) { + final def notice = project.layout.projectDirectory.file("src/modelInput/${model.noticeFileName.get()}") + validate.configure { noticeFile = notice } + prepare.configure { noticeFile = notice } + } else { + final def license = project.layout.projectDirectory.file("src/modelInput/${model.licenseFileName.get()}") + validate.configure { licenseFile = license } + prepare.configure { licenseFile = license } + } + } + project.tasks.named('processResources', Copy).configure { dependsOn(prepare); duplicatesStrategy = DuplicatesStrategy.FAIL } + project.tasks.named('sourcesJar', Jar).configure { dependsOn(prepare); exclude('**/stemmer.gz') } + project.tasks.named('javadocJar', Jar).configure { exclude('**/stemmer.gz') } + project.tasks.named('jar', Jar).configure { + archiveBaseName.set("radixor-model-${project.name}") + preserveFileTimestamps = false + reproducibleFileOrder = true + } + final def verifyDescriptor = project.tasks.register('verifyModelDescriptor') { + group = 'verification'; description = 'Verifies generated descriptor identity and checksum.'; dependsOn(prepare) + doLast { + final Properties properties = new Properties() + new File(generated, "META-INF/radixor/models/${model.modelId.get()}.properties").withInputStream(properties::load) + if (properties.getProperty('model.sha256') != sha256(input)) { + throw new GradleException('Generated descriptor checksum does not match the immutable source input.') + } + } + } + final def verifyJar = project.tasks.register('verifyModelJar') { + group = 'verification'; description = 'Verifies the model JAR checksum, layout, metadata, and dictionary-free documentation artifacts.' + dependsOn(project.tasks.named('jar'), project.tasks.named('sourcesJar'), project.tasks.named('javadocJar')) + doLast { + final File archive = project.tasks.named('jar', Jar).get().archiveFile.get().asFile + final List names = [] + final String resource = "org/egothor/stemmer/models/${model.modelId.get()}/stemmer.gz" + final boolean shareAlike = model.sourceLicense.get() == 'CC-BY-SA-3.0' + final String licenseResource = 'META-INF/LICENSES/PoliMorf-BSD-2-Clause.txt' + final File sourceLicense = shareAlike ? null : project.file("src/modelInput/${model.licenseFileName.get()}") + final File sourceNotice = shareAlike + ? project.file("src/modelInput/${model.noticeFileName.get()}") : null + final String noticeResource = "META-INF/NOTICE/${model.modelId.get()}-data.txt" + String packagedChecksum + String packagedLicenseChecksum + String packagedNoticeChecksum + new java.util.zip.ZipFile(archive).withCloseable { zip -> + zip.entries().each { names.add(it.name) } + final def entry = zip.getEntry(resource) + if (entry != null) { + packagedChecksum = sha256(zip.getInputStream(entry).bytes) + } + final def licenseEntry = zip.getEntry(licenseResource) + if (licenseEntry != null) { + packagedLicenseChecksum = sha256(zip.getInputStream(licenseEntry).bytes) + } + final def noticeEntry = zip.getEntry(noticeResource) + if (noticeEntry != null) { + packagedNoticeChecksum = sha256(zip.getInputStream(noticeEntry).bytes) + } + } + if (names.count { String name -> name.endsWith('/stemmer.gz') } != 1 || !names.contains(resource)) { + throw new GradleException("Model JAR must contain exactly one dictionary at ${resource}.") + } + if (packagedChecksum != sha256(input)) { + throw new GradleException("Packaged dictionary checksum does not match the immutable source input at ${resource}.") + } + if (shareAlike) { + requireMatchingChecksum('notice', noticeResource, sha256(sourceNotice), packagedNoticeChecksum) + validateUniMorphJarContents(names) + } else { + requireMatchingChecksum('license', licenseResource, sha256(sourceLicense), packagedLicenseChecksum) + validatePoliMorfJarContents(names) + } + ['META-INF/radixor/models.index', "META-INF/radixor/models/${model.modelId.get()}.properties"].each { String name -> + if (!names.contains(name)) throw new GradleException("Model JAR is missing ${name}.") + } + [project.tasks.named('sourcesJar', Jar).get(), project.tasks.named('javadocJar', Jar).get()].each { Jar task -> + final File documentationArchive = task.archiveFile.get().asFile + new java.util.zip.ZipFile(documentationArchive).withCloseable { zip -> + if (zip.entries().any { entry -> entry.name.endsWith('/stemmer.gz') || entry.name == 'stemmer.gz' }) { + throw new GradleException("Documentation artifact ${documentationArchive.name} must not contain a model dictionary.") + } + } + } + } + } + project.tasks.register('validateModelRelease') { + group = 'verification'; description = 'Validates a tag-supplied model release version.'; dependsOn(verifyDescriptor, verifyJar) + doLast { + if (!project.hasProperty('modelReleaseVersion')) throw new GradleException('Model release validation requires -PmodelReleaseVersion=.') + final String recorded = project.file('model-version.txt').text.trim() + if (project.property('modelReleaseVersion').toString() != recorded) throw new GradleException("Release version does not match model-version.txt: ${recorded}") + } + } + project.tasks.named('check').configure { dependsOn(verifyDescriptor, verifyJar) } + project.extensions.configure(PublishingExtension) { PublishingExtension publishing -> + publishing.publications.create('model', MavenPublication) { MavenPublication publication -> + publication.from(project.components.java) + publication.artifactId = "radixor-model-${project.name}" + publication.pom { + name.set("Radixor model ${project.name}") + description.set(model.displayName.zip(model.sourceLicense) { String displayName, String licenseId -> + final String material = licenseId == 'CC-BY-SA-3.0' + ? 'See the packaged model-specific notice.' + : 'See the packaged model-data license.' + return "${displayName}. This artifact contains Radixor-derived model data licensed under ${licenseId}; " + .concat("Radixor software is licensed separately under BSD-3-Clause. ${material}") + }) + url.set('https://github.com/leogalambos/Radixor') + licenses { + license { + name.set(model.sourceLicense) + url.set(model.sourceLicenseUri) + distribution.set('repo') + } + } + developers { + developer { + id.set('egothor') + name.set('Leo Galambos') + email.set('egothor@gmail.com') + } + } + scm { + url.set('https://github.com/leogalambos/Radixor') + connection.set('scm:git:https://github.com/leogalambos/Radixor.git') + developerConnection.set('scm:git:ssh://git@github.com/leogalambos/Radixor.git') + } + } + } + publishing.repositories.maven { + name = 'modelStaging' + url = project.layout.buildDirectory.dir('model-staging-repository').get().asFile.toURI() + } + } + + final String signingKey = project.providers.environmentVariable('SIGNING_KEY').orNull + final String signingPassword = project.providers.environmentVariable('SIGNING_PASSWORD').orNull + project.extensions.configure(SigningExtension) { SigningExtension signing -> + signing.required = { + project.providers.environmentVariable('GITHUB_REF_TYPE').orNull == 'tag' + } + if (signingKey != null && !signingKey.isBlank()) { + signing.useInMemoryPgpKeys(signingKey, signingPassword) + signing.sign(project.extensions.getByType(PublishingExtension).publications.getByName('model')) + } + } + + final def checksums = project.tasks.register('createModelCentralChecksums') { + group = 'publishing' + description = 'Creates Maven Central checksums for this model staging repository.' + dependsOn(project.tasks.named('publishModelPublicationToModelStagingRepository')) + doLast { + final File repository = project.layout.buildDirectory.dir('model-staging-repository').get().asFile + repository.eachFileRecurse { File artifact -> + if (artifact.isFile() && !['.md5', '.sha1', '.sha256', '.sha512'].any { + String extension -> artifact.name.endsWith(extension) + }) { + new File(artifact.absolutePath + '.md5').setText(sha256WithAlgorithm(artifact, 'MD5'), 'US-ASCII') + new File(artifact.absolutePath + '.sha1').setText(sha256WithAlgorithm(artifact, 'SHA-1'), 'US-ASCII') + } + } + } + } + project.tasks.register('packageModelReleaseCandidate', Zip) { + group = 'distribution' + description = 'Packages only this model publication as a Maven-layout local release candidate.' + dependsOn(checksums) + from(project.layout.buildDirectory.dir('model-staging-repository')) { + exclude('**/maven-metadata*.xml*') + } + destinationDirectory.set(project.layout.buildDirectory.dir('model-release-candidate')) + archiveFileName.set('central-bundle.zip') + doFirst { + if (project.providers.environmentVariable('GITHUB_REF_TYPE').orNull == 'tag' + && (signingKey == null || signingKey.isBlank() + || signingPassword == null || signingPassword.isBlank())) { + throw new GradleException('A tagged model release requires SIGNING_KEY and SIGNING_PASSWORD.') + } + } + } + } + + /** Ensures a required file exists. */ + static void requireFile(final File file, final String diagnostic) { + if (!file.isFile()) throw new GradleException(diagnostic) + } + + /** Rejects a missing or byte-different packaged licensing resource. */ + static void requireMatchingChecksum(final String kind, final String resource, + final String sourceChecksum, final String packagedChecksum) { + if (packagedChecksum != sourceChecksum) { + throw new GradleException("Packaged ${kind} does not match the source ${kind} at ${resource}.") + } + } + + /** Validates complete source, licensing, attribution, revision-status, and transformation metadata. */ + private static void validateMetadata(final RadixorModelExtension model) { + final Map required = [ + 'source.project': model.sourceProject.orNull, + 'source.repository': model.sourceRepository.orNull, + 'source.dataset': model.sourceDataset.orNull, + 'source.revision': model.sourceRevision.orNull, + 'source.revisionStatus': model.sourceRevisionStatus.orNull, + 'source.license': model.sourceLicense.orNull, + 'source.licenseUri': model.sourceLicenseUri.orNull, + 'source.attribution': model.sourceAttribution.orNull, + 'source.verificationDate': model.sourceVerificationDate.orNull, + 'transformations.summary': model.transformationsSummary.orNull] + required.each { String key, String value -> + if (value == null || value.isBlank()) { + throw new GradleException("Required model metadata is missing: ${key}") + } + } + validateRevisionMetadata(model.sourceRevision.get(), model.sourceRevisionStatus.get()) + } + + /** Accepts an exact recorded revision or the explicit legacy-import sentinel, but never an absent status. */ + static void validateRevisionMetadata(final String revision, final String status) { + if (revision == null || revision.isBlank()) { + throw new GradleException('Required model metadata is missing: source.revision') + } + if (status == null || status.isBlank()) { + throw new GradleException('Required model metadata is missing: source.revisionStatus') + } + final String sentinel = 'not-recorded-in-legacy-import' + if (revision == sentinel && status != sentinel) { + throw new GradleException('The legacy revision sentinel requires source.revisionStatus=not-recorded-in-legacy-import.') + } + if (revision != sentinel && status != 'recorded') { + throw new GradleException('An exact source revision requires source.revisionStatus=recorded.') + } + } + + /** Validates the model-specific attribution and ShareAlike notice. */ + static void validateShareAlikeNotice(final File notice, final RadixorModelExtension model) { + validateShareAlikeNoticeText(notice.getText('UTF-8'), notice.toString(), model.modelId.get(), + model.sourceRepository.get(), model.sourceLicenseUri.get(), model.sourceRevision.get(), + model.sourceRevisionStatus.get()) + } + + /** Validates required content in one UniMorph model-data notice. */ + static void validateShareAlikeNoticeText(final String text, final String noticeName, + final String modelId, final String repository, final String licenseUri, + final String revision, final String revisionStatus) { + final List required = [ + "Model ID: ${modelId}", + "Official repository: ${repository}", + 'Attribution:', + 'License:\nCreative Commons Attribution-ShareAlike 3.0 Unported', + "Canonical license URI: ${licenseUri}", + 'Radixor modifications:', + "Revision status: ${revisionStatus}", + 'Copyright (C) 2026, Leo Galambos.', + 'Radixor-specific selection, verification, cleaning, normalization,', + 'to the extent protected by applicable law.', + 'The underlying morphological data remains attributed to UniMorph and', + "This derived model data, including Radixor's protectable contributions,", + 'is distributed under Creative Commons Attribution-ShareAlike 3.0', + 'Neither UniMorph nor any upstream contributor endorses Radixor.'] + if (revision == 'not-recorded-in-legacy-import') { + required.add('The exact UniMorph commit used for the original Radixor import was not recorded.') + } + final List missing = required.findAll { String value -> !text.contains(value) } + if (!missing.isEmpty()) { + throw new GradleException("Model notice ${noticeName} is missing required content: ${missing.join(', ')}") + } + } + + /** Rejects generic license files and foreign notices in a UniMorph model artifact. */ + static void validateUniMorphJarContents(final List names) { + if (names.any { String name -> name.startsWith('META-INF/LICENSES/') }) { + throw new GradleException('A UniMorph model artifact must use only its model-specific notice for data licensing.') + } + if (names.count { String name -> name.startsWith('META-INF/NOTICE/') && !name.endsWith('/') } != 1) { + throw new GradleException('A UniMorph model artifact must contain exactly one model-specific notice.') + } + } + + /** Rejects UniMorph licensing material in the separately licensed PoliMorf artifact. */ + static void validatePoliMorfJarContents(final List names) { + if (names.any { String name -> name.startsWith('META-INF/NOTICE/') + || name.contains('CC-BY-SA') }) { + throw new GradleException('The PoliMorf artifact must not contain UniMorph CC BY-SA material.') + } + } + + /** Memory-bounded validation statistics for one dictionary input. */ + static final class DictionaryValidationResult { + final long acceptedGroupCount + final long acceptedFormCount + final long ignoredEmptyVariantCount + + DictionaryValidationResult(final long acceptedGroupCount, final long acceptedFormCount, + final long ignoredEmptyVariantCount) { + this.acceptedGroupCount = acceptedGroupCount + this.acceptedFormCount = acceptedFormCount + this.ignoredEmptyVariantCount = ignoredEmptyVariantCount + } + } + + /** Validates GZip, strict UTF-8, and dictionary rows without retaining decompressed input. */ + static DictionaryValidationResult validateDictionary(final File file) { + long acceptedGroups = 0L + long acceptedForms = 0L + long ignoredEmptyVariants = 0L + try { + final def decoder = StandardCharsets.UTF_8.newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .onUnmappableCharacter(CodingErrorAction.REPORT) + Files.newInputStream(file.toPath()).withCloseable { InputStream source -> + new BufferedInputStream(source).withCloseable { BufferedInputStream bufferedInput -> + new GZIPInputStream(bufferedInput).withCloseable { GZIPInputStream gzipInput -> + new BufferedReader(new InputStreamReader(gzipInput, decoder)).withCloseable { BufferedReader reader -> + String line + long lineNumber = 0L + while ((line = reader.readLine()) != null) { + lineNumber++ + final String trimmed = line.trim() + if (trimmed && !trimmed.startsWith('#') && !trimmed.startsWith('//')) { + final String[] columns = line.split('\\t', -1) + if (columns[0].isEmpty()) { + throw new GradleException("Invalid Radixor dictionary row ${lineNumber} in ${file}.") + } + if (containsUnicodeWhitespace(columns[0])) continue + long acceptedRowForms = 1L + for (int index = 1; index < columns.length; index++) { + final String variant = columns[index] + if (variant.isEmpty()) { + ignoredEmptyVariants++ + } else if (!containsUnicodeWhitespace(variant)) { + acceptedRowForms++ + } + } + acceptedGroups++ + acceptedForms += acceptedRowForms + } + } + } + } + } + } + } catch (GradleException exception) { + throw exception + } catch (Exception exception) { + throw new GradleException("Invalid GZip or UTF-8 model input: ${file}", exception) + } + if (acceptedGroups == 0L) throw new GradleException("Model dictionary contains no valid rows: ${file}") + if (ignoredEmptyVariants > 0L) { + println("Model validation warning: " + file + " contains " + ignoredEmptyVariants + + " empty variant columns; the production parser intentionally ignores empty variants.") + } + return new DictionaryValidationResult(acceptedGroups, acceptedForms, ignoredEmptyVariants) + } + + /** Detects Unicode whitespace in one bounded dictionary field. */ + private static boolean containsUnicodeWhitespace(final String value) { + for (int index = 0; index < value.length(); index++) { + if (Character.isWhitespace(value.charAt(index))) return true + } + return false + } + + /** Builds deterministic descriptor text. */ + private static String descriptorText(final RadixorModelExtension model, final String version, + final String resource, final String checksum) { + return """model.id=${model.modelId.get()} +model.version=${version} +model.language=${model.language.get()} +model.displayName=${model.displayName.get()} +model.resource=${resource} +model.default=${model.defaultModel.get()} +model.format=radixor-dictionary-tsv-gzip +model.formatVersion=1 +model.sha256=${checksum} +model.rightToLeft=${['FA_IR', 'HE_IL', 'YI'].contains(model.language.get())} +model.caseProcessing=LOWERCASE_WITH_LOCALE_ROOT +model.diacriticProcessing=AS_IS +model.storeOriginal=true +source.name=${model.sourceName.get()} +source.version=${model.sourceVersion.get()} +source.project=${model.sourceProject.get()} +source.repository=${model.sourceRepository.get()} +source.dataset=${model.sourceDataset.get()} +source.revision=${model.sourceRevision.get()} +source.revisionStatus=${model.sourceRevisionStatus.get()} +source.license=${model.sourceLicense.get()} +source.licenseUri=${model.sourceLicenseUri.get()} +source.attribution=${model.sourceAttribution.get()} +source.verificationDate=${model.sourceVerificationDate.get()} +transformations.summary=${model.transformationsSummary.get()} +compiler.radixorVersion=3.x +compiler.radixorCommit=unavailable +statistics.groups=unavailable +statistics.forms=unavailable +""" + } + + /** Calculates the lowercase hexadecimal SHA-256 digest. */ + private static String sha256(final File file) { + return sha256(file.bytes) + } + + /** Calculates the lowercase hexadecimal SHA-256 digest of bytes. */ + private static String sha256(final byte[] bytes) { + return MessageDigest.getInstance('SHA-256').digest(bytes).collect { byte value -> String.format('%02x', value & 0xff) }.join() + } + + /** Calculates a lowercase hexadecimal digest using the requested algorithm. */ + private static String sha256WithAlgorithm(final File file, final String algorithm) { + return MessageDigest.getInstance(algorithm).digest(file.bytes) + .collect { byte value -> String.format('%02x', value & 0xff) }.join() + } + +} diff --git a/build-logic/src/main/groovy/org/egothor/radixor/ValidateModelInputTask.groovy b/build-logic/src/main/groovy/org/egothor/radixor/ValidateModelInputTask.groovy new file mode 100644 index 0000000..870c6d0 --- /dev/null +++ b/build-logic/src/main/groovy/org/egothor/radixor/ValidateModelInputTask.groovy @@ -0,0 +1,57 @@ +package org.egothor.radixor + +import org.gradle.api.DefaultTask +import org.gradle.api.GradleException +import org.gradle.api.file.RegularFileProperty +import org.gradle.api.provider.MapProperty +import org.gradle.api.provider.Property +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.PathSensitive +import org.gradle.api.tasks.PathSensitivity +import org.gradle.api.tasks.TaskAction + +/** Validates one immutable model input without retaining Project state. */ +abstract class ValidateModelInputTask extends DefaultTask { + @InputFile @PathSensitive(PathSensitivity.RELATIVE) abstract RegularFileProperty getDictionaryFile() + @InputFile @PathSensitive(PathSensitivity.RELATIVE) abstract RegularFileProperty getVersionFile() + @Optional @InputFile @PathSensitive(PathSensitivity.RELATIVE) abstract RegularFileProperty getLicenseFile() + @Optional @InputFile @PathSensitive(PathSensitivity.RELATIVE) abstract RegularFileProperty getNoticeFile() + @Input abstract Property getModelId() + @Input abstract Property getModuleName() + @Input abstract Property getShareAlike() + @Input abstract MapProperty getMetadata() + + /** Performs deterministic metadata, licensing, and streaming dictionary validation. */ + @TaskAction + void validateInput() { + final File dictionary = dictionaryFile.get().asFile + final String id = modelId.get() + final String version = versionFile.get().asFile.getText('UTF-8').trim() + if (id != moduleName.get() || !(id ==~ /[a-z]{2}(?:-[a-z]{2})?-[a-z0-9]+(?:-[a-z0-9]+)*/)) { + throw new GradleException("Model ID '${id}' must equal module '${moduleName.get()}' and use the safe model-ID syntax.") + } + if (!(version ==~ /[0-9]+\.[0-9]+\.[0-9]+(?:[-+][0-9A-Za-z.-]+)?/)) { + throw new GradleException("Invalid semantic model version '${version}'.") + } + final Map values = metadata.get() + values.each { String key, String value -> + if (value == null || value.isBlank()) throw new GradleException("Required model metadata is missing: ${key}") + } + RadixorModelPlugin.validateRevisionMetadata(values['source.revision'], values['source.revisionStatus']) + if (shareAlike.get()) { + final File notice = noticeFile.get().asFile + RadixorModelPlugin.validateShareAlikeNoticeText(notice.getText('UTF-8'), notice.toString(), id, + values['source.repository'], values['source.licenseUri'], values['source.revision'], + values['source.revisionStatus']) + } else { + final String text = licenseFile.get().asFile.getText('UTF-8') + if (!text.contains('SPDX-License-Identifier: BSD-2-Clause') + || !text.contains('Copyright (c) 2016, Marcin Miłkowski')) { + throw new GradleException('The PoliMorf license must contain the complete BSD-2-Clause text and upstream attribution.') + } + } + RadixorModelPlugin.validateDictionary(dictionary) + } +} diff --git a/build-logic/src/test/groovy/org/egothor/radixor/RadixorModelPluginTest.groovy b/build-logic/src/test/groovy/org/egothor/radixor/RadixorModelPluginTest.groovy new file mode 100644 index 0000000..8d9c4c1 --- /dev/null +++ b/build-logic/src/test/groovy/org/egothor/radixor/RadixorModelPluginTest.groovy @@ -0,0 +1,205 @@ +package org.egothor.radixor + +import org.gradle.api.GradleException +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.io.TempDir + +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import java.nio.file.Path +import java.util.zip.GZIPOutputStream + +import static org.junit.jupiter.api.Assertions.assertEquals +import static org.junit.jupiter.api.Assertions.assertThrows +import static org.junit.jupiter.api.Assertions.assertTrue + +/** Tests model licensing metadata and packaged-resource validation boundaries. */ +final class RadixorModelPluginTest { + @TempDir + Path temporaryDirectory + + /** Accepts a known exact source revision. */ + @Test + void acceptsKnownExactRevision() { + RadixorModelPlugin.validateRevisionMetadata('6e63b53', 'recorded') + } + + /** Accepts the explicit legacy-import sentinel without fabricating a revision. */ + @Test + void acceptsUnknownLegacyRevision() { + RadixorModelPlugin.validateRevisionMetadata( + 'not-recorded-in-legacy-import', 'not-recorded-in-legacy-import') + } + + /** Rejects a missing revision-status declaration. */ + @Test + void rejectsMissingRevisionStatus() { + assertThrows(GradleException) { + RadixorModelPlugin.validateRevisionMetadata('6e63b53', '') + } + } + + /** Rejects a missing model-specific notice input. */ + @Test + void rejectsMissingLicensingInputs() { + File missing = new File('build/nonexistent-model-licensing-input') + assertThrows(GradleException) { + RadixorModelPlugin.requireFile(missing, 'Required model notice is missing') + } + } + + /** Accepts a complete model-specific UniMorph notice. */ + @Test + void acceptsCompleteUniMorphNotice() { + validateNotice(validNotice()) + } + + /** Rejects each independently required notice statement. */ + @Test + void rejectsIncompleteUniMorphNotices() { + [ + 'Copyright (C) 2026, Leo Galambos.', + 'Attribution:', + 'Creative Commons Attribution-ShareAlike 3.0 Unported', + 'Canonical license URI:', + "This derived model data, including Radixor's protectable contributions,", + 'Radixor modifications:', + 'Revision status:', + 'Neither UniMorph nor any upstream contributor endorses Radixor.' + ].each { String required -> + assertThrows(GradleException) { + validateNotice(validNotice().replace(required, 'omitted')) + } + } + } + + /** Rejects packaged notice bytes that differ from their model-module source. */ + @Test + void rejectsIncorrectPackagedNotice() { + assertThrows(GradleException) { + RadixorModelPlugin.requireMatchingChecksum( + 'notice', 'META-INF/NOTICE/test-model-data.txt', 'source', 'different') + } + } + + /** Rejects UniMorph CC material in the separately licensed PoliMorf artifact. */ + @Test + void rejectsUniMorphMaterialInPoliMorf() { + assertThrows(GradleException) { + RadixorModelPlugin.validatePoliMorfJarContents( + ['META-INF/LICENSES/PoliMorf-BSD-2-Clause.txt', 'META-INF/NOTICE/test-data.txt']) + } + assertThrows(GradleException) { + RadixorModelPlugin.validatePoliMorfJarContents( + ['META-INF/LICENSES/PoliMorf-BSD-2-Clause.txt', 'META-INF/LICENSES/CC-BY-SA-3.0.txt']) + } + } + + /** Streams a large dictionary while retaining only aggregate counters and the current row. */ + @Test + void validatesLargeDictionaryWithBoundedState() { + final int groups = 250_000 + final File dictionary = temporaryDirectory.resolve('large.gz').toFile() + writeGzip(dictionary) { BufferedWriter writer -> + for (int index = 0; index < groups; index++) { + writer.write("stem${index}\tvariant${index}\t\n") + } + } + + final RadixorModelPlugin.DictionaryValidationResult result = + RadixorModelPlugin.validateDictionary(dictionary) + + assertEquals(groups, result.acceptedGroupCount) + assertEquals(groups * 2L, result.acceptedFormCount) + assertEquals(groups, result.ignoredEmptyVariantCount) + } + + /** Rejects a source that is not a GZip stream. */ + @Test + void rejectsInvalidGzip() { + final File dictionary = temporaryDirectory.resolve('invalid.gz').toFile() + Files.writeString(dictionary.toPath(), 'not gzip', StandardCharsets.UTF_8) + assertThrows(GradleException) { RadixorModelPlugin.validateDictionary(dictionary) } + } + + /** Rejects malformed UTF-8 through the strict incremental decoder. */ + @Test + void rejectsMalformedUtf8() { + final File dictionary = temporaryDirectory.resolve('malformed-utf8.gz').toFile() + new GZIPOutputStream(Files.newOutputStream(dictionary.toPath())).withCloseable { OutputStream output -> + output.write([0x73, 0x74, 0x65, 0x6d, 0x09, 0xc3, 0x28, 0x0a] as byte[]) + } + assertThrows(GradleException) { RadixorModelPlugin.validateDictionary(dictionary) } + } + + /** Rejects structurally invalid rows with an empty stem. */ + @Test + void rejectsInvalidRows() { + final File dictionary = temporaryDirectory.resolve('invalid-row.gz').toFile() + writeGzip(dictionary) { BufferedWriter writer -> writer.write("\tvariant\n") } + assertThrows(GradleException) { RadixorModelPlugin.validateDictionary(dictionary) } + } + + /** Preserves the production parser policy for Unicode-whitespace items. */ + @Test + void rejectsUnicodeWhitespaceItemsWithoutRejectingTheSource() { + final File dictionary = temporaryDirectory.resolve('whitespace-items.gz').toFile() + writeGzip(dictionary) { BufferedWriter writer -> + writer.write("invalid stem\tvariant\n") + writer.write("valid\taccepted\tinvalid variant\n") + } + final RadixorModelPlugin.DictionaryValidationResult result = + RadixorModelPlugin.validateDictionary(dictionary) + assertEquals(1L, result.acceptedGroupCount) + assertEquals(2L, result.acceptedFormCount) + } + + /** Streams the complete maintained PoliMorf model input successfully. */ + @Test + void validatesFullPoliMorfInput() { + final List candidates = [ + new File('models/pl-pl-polimorf/src/modelInput/stemmer.gz'), + new File('../models/pl-pl-polimorf/src/modelInput/stemmer.gz')] + final File dictionary = candidates.find { File candidate -> candidate.isFile() } + assertTrue(dictionary != null, 'The complete PoliMorf model input must be available to build-logic tests.') + + final RadixorModelPlugin.DictionaryValidationResult result = + RadixorModelPlugin.validateDictionary(dictionary) + assertTrue(result.acceptedGroupCount > 0L) + assertTrue(result.acceptedFormCount > result.acceptedGroupCount) + } + + private static void writeGzip(final File target, final Closure content) { + new GZIPOutputStream(Files.newOutputStream(target.toPath())).withCloseable { OutputStream gzip -> + new BufferedWriter(new OutputStreamWriter(gzip, StandardCharsets.UTF_8)).withCloseable { + BufferedWriter writer -> content.call(writer) + } + } + } + + private static void validateNotice(final String text) { + RadixorModelPlugin.validateShareAlikeNoticeText(text, 'test notice', 'test-model', + 'https://github.com/unimorph/test', 'https://creativecommons.org/licenses/by-sa/3.0/', + 'not-recorded-in-legacy-import', 'not-recorded-in-legacy-import') + } + + private static String validNotice() { + return '''Model ID: test-model +Official repository: https://github.com/unimorph/test +Attribution: UniMorph and upstream contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Radixor modifications: Cleaning and packaging. +Revision status: not-recorded-in-legacy-import +The exact UniMorph commit used for the original Radixor import was not recorded. +Copyright (C) 2026, Leo Galambos. +Radixor-specific selection, verification, cleaning, normalization, +to the extent protected by applicable law. +The underlying morphological data remains attributed to UniMorph and +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Neither UniMorph nor any upstream contributor endorses Radixor. +''' + } +} diff --git a/build.gradle b/build.gradle index dd76299..83cf961 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,5 @@ plugins { + id 'org.egothor.radixor.build-support' id 'java' id 'eclipse' id 'application' @@ -7,9 +8,9 @@ plugins { id 'pmd' id 'jacoco' id 'info.solidsoft.pitest' version '1.19.0' - id 'me.champeau.jmh' version '0.7.2' + id 'me.champeau.jmh' version '0.7.3' id 'org.owasp.dependencycheck' version '12.2.1' - id 'org.cyclonedx.bom' version '3.2.4' + id 'org.cyclonedx.bom' version '3.3.0' id 'com.palantir.git-version' version '4.0.0' } @@ -45,6 +46,10 @@ java { targetCompatibility = JavaVersion.VERSION_21 } +tasks.withType(JavaCompile).configureEach { + options.compilerArgs.addAll(['-Xlint:deprecation', '-Xlint:unchecked']) +} + tasks.withType(AbstractArchiveTask).configureEach { preserveFileTimestamps = false reproducibleFileOrder = true @@ -70,6 +75,11 @@ dependencyLocking { dependencies { jmhImplementation sourceSets.main.output + modelProjects().each { Project modelProject -> + testRuntimeOnly project(modelProject.path) + jmhRuntimeOnly project(modelProject.path) + } + testImplementation platform(libs.junit.bom) testImplementation libs.junit.jupiter testRuntimeOnly libs.junit.platform.launcher @@ -77,12 +87,45 @@ dependencies { testImplementation libs.mockito.core testImplementation libs.mockito.junit.jupiter testImplementation libs.jqwik + testImplementation gradleTestKit() mockitoAgent(libs.mockito.core) { transitive = false } } +def modelProjects() { + Properties topology = new Properties() + rootProject.file('models/model-projects.properties').withInputStream { InputStream input -> + topology.load(input) + } + return topology.stringPropertyNames().toList().sort().collect { String modelId -> + project(":models:${modelId}") + } +} + +def defaultModelProjects() { + Properties topology = new Properties() + rootProject.file('models/model-projects.properties').withInputStream { InputStream input -> + topology.load(input) + } + return topology.stringPropertyNames().findAll { String modelId -> + topology.getProperty(modelId) == 'default' + }.sort().collect { String modelId -> project(":models:${modelId}") } +} + +tasks.named('projects') { + actions.clear() + doLast { + logger.lifecycle('Root project \'{}\'', rootProject.name) + rootProject.allprojects.findAll { Project candidate -> candidate != rootProject } + .sort { Project left, Project right -> left.path <=> right.path } + .each { Project candidate -> logger.lifecycle('+--- Project \'{}\'', candidate.path) } + gradle.includedBuilds.toList().sort { left, right -> left.name <=> right.name } + .each { includedBuild -> logger.lifecycle('Included build \'{}\'', includedBuild.name) } + } +} + sourceSets.jmh.compileClasspath = sourceSets.jmh.compileClasspath - sourceSets.test.output sourceSets.jmh.runtimeClasspath = sourceSets.jmh.runtimeClasspath - sourceSets.test.output sourceSets.test.compileClasspath += sourceSets.jmh.output + configurations.jmhCompileClasspath @@ -138,9 +181,10 @@ def splitTagExpression = { String tagsExpr -> } tasks.withType(Test).configureEach { - doFirst { - jvmArgs "-javaagent:${configurations.mockitoAgent.singleFile}" - } + final def mockitoAgentArguments = objects.newInstance( + org.egothor.radixor.MockitoAgentArgumentProvider) + mockitoAgentArguments.agentClasspath.from(configurations.mockitoAgent) + jvmArgumentProviders.add(mockitoAgentArguments) /* * Bundled dictionary integration tests compile and reload large real-world @@ -156,6 +200,30 @@ tasks.withType(Test).configureEach { } } +tasks.named('test', Test) { + dependsOn('prepareModelConsumerTestRepository') + systemProperty('radixor.consumer.repository', + layout.buildDirectory.dir('model-consumer-repository').get().asFile.absolutePath) + systemProperty('radixor.core.version', version.toString()) + systemProperty('radixor.catalog.version', project(':models:standard').version.toString()) +} + +tasks.register('modelDependencyResolutionTest', Test) { + group = 'verification' + description = 'Verifies that published model coordinates resolve from the generated consumer repository.' + dependsOn(tasks.named('prepareModelConsumerTestRepository')) + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.runtimeClasspath + useJUnitPlatform() + filter { + includeTestsMatching('org.egothor.stemmer.ModelDependencyResolutionTest') + } + systemProperty('radixor.consumer.repository', + layout.buildDirectory.dir('model-consumer-repository').get().asFile.absolutePath) + systemProperty('radixor.core.version', version.toString()) + systemProperty('radixor.catalog.version', project(':models:standard').version.toString()) +} + def configureJUnitPlatformTags = { Test task, String includeTagsExpr, String excludeTagsExpr -> task.useJUnitPlatform { final def includes = splitTagExpression(includeTagsExpr) @@ -173,11 +241,47 @@ def configureJUnitPlatformTags = { Test task, String includeTagsExpr, String exc tasks.named('test', Test) { final def requestedIncludes = splitTagExpression(cliIncludeTags) final boolean slowExplicitlyIncluded = requestedIncludes.contains('slow') - final String defaultExcludeTags = cliExcludeTags ?: (slowExplicitlyIncluded ? null : 'slow') + final String defaultExcludeTags = cliExcludeTags ?: (slowExplicitlyIncluded ? 'large-model' : 'slow,large-model') configureJUnitPlatformTags(it, cliIncludeTags, defaultExcludeTags) finalizedBy(tasks.named('jacocoTestReport')) } +def largeModelMaxHeap = providers.gradleProperty('radixorLargeModelMaxHeap').orElse('6g') +def runtimeModelId = providers.gradleProperty('modelId').orElse('pl-pl-polimorf') +def runtimeModelClasspath = configurations.testRuntimeClasspath.incoming.artifactView { + componentFilter { componentIdentifier -> + if (!(componentIdentifier instanceof org.gradle.api.artifacts.component.ProjectComponentIdentifier)) { + return true + } + final String projectPath = componentIdentifier.projectPath + return !projectPath.startsWith(':models:') || projectPath == ":models:${runtimeModelId.get()}" + } +}.files + +tasks.register('runtimeModelIntegrationTest', Test) { + group = 'verification' + description = 'Constructs one complete selected runtime model in an isolated, memory-sized JVM.' + testClassesDirs = sourceSets.test.output.classesDirs + classpath = sourceSets.test.output + sourceSets.main.output + sourceSets.jmh.output + runtimeModelClasspath + dependsOn(tasks.named('compileTestJava')) + useJUnitPlatform { + includeTags('large-model') + } + systemProperty('radixor.test.modelId', runtimeModelId.get()) + minHeapSize = '1g' + maxHeapSize = largeModelMaxHeap.get() + maxParallelForks = 1 + forkEvery = 1 + reports { + junitXml.required = true + html.required = true + } + doFirst { + logger.lifecycle("Runtime model integration uses model '{}' with maximum heap {}.", + systemProperties.get('radixor.test.modelId'), maxHeapSize) + } +} + def configureTaggedTestProfile = { String taskName, String includeTagsExpr, String excludeTagsExpr = null, String taskDescription = null, String testNameExcludePatterns = null -> tasks.register(taskName, Test) { @@ -189,10 +293,6 @@ def configureTaggedTestProfile = { String taskName, String includeTagsExpr, Stri classpath = sourceSets.test.runtimeClasspath dependsOn(tasks.named('compileTestJava')) - doFirst { - jvmArgs "-javaagent:${configurations.mockitoAgent.singleFile}" - } - if (testNameExcludePatterns != null && !testNameExcludePatterns.isBlank()) { filter { testNameExcludePatterns.split(',').each { String pattern -> @@ -253,11 +353,19 @@ configureTaggedTestProfile( configureTaggedTestProfile( 'ciRelease', null, - 'slow', + 'slow,large-model', 'Release-profile validation of all non-slow tests.', 'org.egothor.stemmer.CompileIntegrationTest*,org.egothor.stemmer.StemmerPatchTrieLoaderTest$BundledDictionaryTests*' ) +tasks.named('ciRelease', Test) { + dependsOn('prepareModelConsumerTestRepository') + systemProperty('radixor.consumer.repository', + layout.buildDirectory.dir('model-consumer-repository').get().asFile.absolutePath) + systemProperty('radixor.core.version', version.toString()) + systemProperty('radixor.catalog.version', project(':models:standard').version.toString()) +} + configureTaggedTestProfile( 'ciNightly', 'fuzz', @@ -333,25 +441,393 @@ tasks.named('check') { // no-default, only on-demand: dependsOn(tasks.named('dependencyCheckAnalyze')) } -allprojects { - tasks.matching { it.name == 'cyclonedxDirectBom' }.configureEach { - includeConfigs = ['runtimeClasspath', 'compileClasspath'] - skipConfigs = ['testRuntimeClasspath', 'testCompileClasspath', 'jmh.*', 'mockitoAgent'] - includeBomSerialNumber = true - includeLicenseText = false - includeMetadataResolution = true - includeBuildSystem = true +tasks.register('verifyCoreJarExcludesModels') { + group = 'verification' + description = 'Verifies that the root Radixor JAR contains no language dictionary bytes.' + dependsOn(tasks.named('jar')) + doLast { + File archive = tasks.named('jar', Jar).get().archiveFile.get().asFile + List dictionaries = [] + new java.util.zip.ZipFile(archive).withCloseable { zip -> + zip.entries().each { entry -> if (entry.name.endsWith('/stemmer.gz')) dictionaries.add(entry.name) } + } + if (!dictionaries.isEmpty()) { + throw new GradleException('The org.egothor:radixor JAR must not contain model data: ' + dictionaries) + } } } -tasks.named('cyclonedxBom') { +tasks.register('verifyJavaLicenseHeaders') { + group = 'verification' + description = 'Verifies deterministic license classification for every maintained Java source file.' + inputs.file(layout.projectDirectory.file('gradle/java-license-header.txt')) + inputs.files(fileTree('src/main/java') { include '**/*.java' }) + inputs.files(fileTree('src/test/java') { include '**/*.java' }) + inputs.files(fileTree('src/jmh/java') { include '**/*.java' }) + outputs.file(layout.buildDirectory.file('reports/license/java-license-headers.txt')) + doLast { + String canonicalHeader = layout.projectDirectory.file('gradle/java-license-header.txt') + .asFile.getText('UTF-8') + File canonicalSource = file('src/main/java/org/egothor/stemmer/CaseProcessingMode.java') + if (!canonicalSource.getText('UTF-8').startsWith(canonicalHeader)) { + throw new GradleException('CaseProcessingMode.java does not begin with the canonical Radixor license template.') + } + + List maintainedSources = files( + fileTree('src/main/java') { include '**/*.java' }, + fileTree('src/test/java') { include '**/*.java' }, + fileTree('src/jmh/java') { include '**/*.java' }) + .files.toList().sort { File left, File right -> + relativePath(left) <=> relativePath(right) + } + List classifications = [] + List failures = [] + maintainedSources.each { File sourceFile -> + String relative = relativePath(sourceFile) + String content = sourceFile.getText('UTF-8') + if (content.startsWith(canonicalHeader)) { + classifications.add("RADIXOR_CANONICAL_HEADER ${relative}") + return + } + + String leadingNotice = '' + if (content.startsWith('/*')) { + int closingIndex = content.indexOf('*/') + if (closingIndex >= 0) { + leadingNotice = content.substring(0, closingIndex + 2) + } + } else if (content.startsWith('//')) { + leadingNotice = content.readLines().takeWhile { String line -> + line.startsWith('//') || line.isBlank() + }.join('\n') + } + String remainder = content.substring(leadingNotice.length()).stripLeading() + boolean duplicateNotice = !leadingNotice.isEmpty() + && (remainder.startsWith('/*') || remainder.startsWith('//')) + boolean historicalRadixor = leadingNotice =~ /(?s)Copyright \(C\) \d{4}(?:-\d{4})?, Leo Galambos/ + && leadingNotice.contains('All rights reserved.') + && leadingNotice.contains('Redistribution and use in source and binary forms') + && leadingNotice.contains('THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS') + boolean thirdPartyOrProvenance = leadingNotice =~ /(?is)(SPDX-License-Identifier|Licensed under|MIT License|Apache License|Permission is hereby granted|Original source|Adapted from|Ported from|Source:\s*\S)/ + if (duplicateNotice) { + classifications.add("AMBIGUOUS_AUTHORSHIP ${relative}") + failures.add("${relative}: duplicate leading comment blocks") + } else if (historicalRadixor) { + classifications.add("RADIXOR_HISTORICAL_HEADER ${relative}") + } else if (thirdPartyOrProvenance) { + classifications.add("THIRD_PARTY_OR_PROVENANCE_HEADER ${relative}") + } else { + classifications.add("AMBIGUOUS_AUTHORSHIP ${relative}") + failures.add("${relative}: no recognized governing license or provenance header") + } + } + + File report = layout.buildDirectory.file('reports/license/java-license-headers.txt').get().asFile + report.parentFile.mkdirs() + report.setText(classifications.join('\n') + '\n', 'UTF-8') + if (!failures.isEmpty()) { + throw new GradleException('Maintained Java license verification failed: ' + + failures.sort().join(', ')) + } + } +} + +tasks.register('verifyAllDefaultModels') { + group = 'verification' + description = 'Verifies that every language default model project is configured.' + dependsOn(defaultModelProjects().collect { Project modelProject -> + modelProject.path + ':verifyModelDescriptor' + }) +} + +tasks.register('verifyAllModels') { + group = 'verification' + description = 'Runs complete validation and artifact verification for every independently versioned model module.' + dependsOn(modelProjects().collect { Project modelProject -> modelProject.tasks.named('check') }) +} + +tasks.register('verifyJmhModelClasspath') { + group = 'verification' + description = 'Verifies that JMH receives each individual model JAR exactly once and embeds no dictionary.' + dependsOn(tasks.named('jmhJar')) + dependsOn(modelProjects().collect { Project modelProject -> modelProject.tasks.named('jar') }) + outputs.file(layout.buildDirectory.file('reports/models/jmh-model-classpath.txt')) + doLast { + List modelJars = configurations.jmhRuntimeClasspath.files.findAll { File dependency -> + dependency.name.startsWith('radixor-model-') && dependency.name.endsWith('.jar') + }.sort { File left, File right -> left.name <=> right.name } + List expectedPrefixes = modelProjects().collect { Project modelProject -> + "radixor-model-${modelProject.name}-" + } + expectedPrefixes.each { String prefix -> + List matches = modelJars.findAll { File dependency -> dependency.name.startsWith(prefix) } + if (matches.size() != 1) { + throw new GradleException("JMH must resolve exactly one model JAR with prefix ${prefix}; resolved ${matches}.") + } + } + if (modelJars.any { File dependency -> dependency.name.contains('benchmark-pack') }) { + throw new GradleException('JMH must not resolve a benchmark-pack artifact.') + } + File executable = tasks.named('jmhJar', Jar).get().archiveFile.get().asFile + if (!zipTree(executable).matching { include '**/stemmer.gz' }.isEmpty()) { + throw new GradleException('The JMH executable JAR must not embed model dictionaries.') + } + File report = layout.buildDirectory.file('reports/models/jmh-model-classpath.txt').get().asFile + report.parentFile.mkdirs() + report.setText(modelJars.collect { File dependency -> dependency.name }.join('\n') + '\n', 'UTF-8') + } +} + +tasks.named('prepareModelConsumerTestRepository') { + coreVersion = version.toString() + catalogVersion = project(':models:standard').version.toString() + modelVersions = modelProjects().collectEntries { Project modelProject -> + final String modelVersion = providers.gradleProperty('modelReleaseVersion') + .orElse(providers.fileContents(modelProject.layout.projectDirectory.file('model-version.txt')) + .asText.map(String::trim)) + .get() + [(modelProject.name): modelVersion] + } + corePom = layout.file(tasks.named('generatePomFileForMavenJavaPublication').map { it.destination }) + coreJar = tasks.named('jar', Jar).flatMap { it.archiveFile } + modelPoms.from(modelProjects().collect { Project modelProject -> + modelProject.tasks.named('generatePomFileForModelPublication').map { it.destination } + }) + modelJars.from(modelProjects().collect { Project modelProject -> + modelProject.tasks.named('jar', Jar).flatMap { it.archiveFile } + }) + standardPom = layout.file(project(':models:standard').tasks.named('generatePomFileForStandardPublication') + .map { it.destination }) + bomPom = layout.file(project(':models:bom').tasks.named('generatePomFileForBomPublication') + .map { it.destination }) + repositoryDirectory = layout.buildDirectory.dir('model-consumer-repository') +} + +def cleanModelCatalogStaging = tasks.register('cleanModelCatalogStaging') { + group = 'publishing' + description = 'Cleans the isolated model catalog Maven staging repository.' + doLast { + project.delete(layout.buildDirectory.dir('model-catalog-staging-repository')) + } +} + +gradle.projectsEvaluated { + project(':models:standard').tasks.named('publishStandardPublicationToCatalogStagingRepository') { + dependsOn(cleanModelCatalogStaging) + } + project(':models:bom').tasks.named('publishBomPublicationToCatalogStagingRepository') { + dependsOn(cleanModelCatalogStaging) + } +} + +tasks.register('prepareModelCatalogReleaseCandidate') { + group = 'publishing' + description = 'Stages the POM-only standard aggregate and model BOM with Central checksums.' + dependsOn(project(':models:standard').tasks.named('check')) + dependsOn(project(':models:bom').tasks.named('check')) + dependsOn(':models:standard:publishStandardPublicationToCatalogStagingRepository') + dependsOn(':models:bom:publishBomPublicationToCatalogStagingRepository') + outputs.dir(layout.buildDirectory.dir('model-catalog-staging-repository')) + doLast { + File repository = layout.buildDirectory.dir('model-catalog-staging-repository').get().asFile + repository.eachFileRecurse { File artifact -> + if (artifact.isFile() && !['.md5', '.sha1', '.sha256', '.sha512'].any { + String extension -> artifact.name.endsWith(extension) + }) { + ['MD5': 'md5', 'SHA-1': 'sha1'].each { String algorithm, String extension -> + String digest = java.security.MessageDigest.getInstance(algorithm) + .digest(artifact.bytes).encodeHex().toString() + new File(artifact.absolutePath + ".${extension}").setText(digest, 'US-ASCII') + } + } + } + } +} + +tasks.register('modelCatalogCentralBundle', Zip) { + group = 'publishing' + description = 'Builds the local POM-only model catalog bundle without remote publication.' + dependsOn(tasks.named('prepareModelCatalogReleaseCandidate')) + from(layout.buildDirectory.dir('model-catalog-staging-repository')) { + exclude('**/maven-metadata*.xml*', '**/*.module*') + } + destinationDirectory = layout.buildDirectory.dir('model-catalog-release-candidate') + archiveFileName = "radixor-models-catalog-${project(':models:standard').version}-central-bundle.zip" + doFirst { + if (providers.environmentVariable('GITHUB_REF_TYPE').orNull == 'tag' + && (providers.environmentVariable('SIGNING_KEY').orNull?.isBlank() != false + || providers.environmentVariable('SIGNING_PASSWORD').orNull?.isBlank() != false)) { + throw new GradleException('A tagged model catalog release requires SIGNING_KEY and SIGNING_PASSWORD.') + } + } +} + +tasks.register('verifyModelCatalogReleaseCandidate') { + group = 'verification' + description = 'Verifies that the local catalog bundle contains only two POM publications, signatures when configured, and checksums.' + dependsOn(tasks.named('modelCatalogCentralBundle')) + outputs.file(layout.buildDirectory.file('reports/models/catalog-release-candidate.txt')) + doLast { + File bundle = tasks.named('modelCatalogCentralBundle', Zip).get().archiveFile.get().asFile + List entries = [] + new java.util.zip.ZipFile(bundle).withCloseable { java.util.zip.ZipFile archive -> + archive.entries().each { java.util.zip.ZipEntry entry -> + if (!entry.directory) entries.add(entry.name) + } + } + entries.sort() + List poms = entries.findAll { String entry -> entry.endsWith('.pom') } + if (poms.size() != 2 || entries.any { String entry -> + entry.endsWith('.jar') || entry.endsWith('/stemmer.gz') || entry.contains('benchmark-pack') + }) { + throw new GradleException('The model catalog bundle must contain only the standard and BOM POM publications.') + } + List unsupported = entries.findAll { String entry -> + !(entry.endsWith('.pom') || entry.endsWith('.pom.md5') || entry.endsWith('.pom.sha1') + || entry.endsWith('.pom.sha256') || entry.endsWith('.pom.sha512') + || entry.endsWith('.pom.asc') || entry.endsWith('.pom.asc.md5') + || entry.endsWith('.pom.asc.sha1') || entry.endsWith('.pom.asc.sha256') + || entry.endsWith('.pom.asc.sha512')) + } + if (!unsupported.isEmpty()) { + throw new GradleException("The model catalog bundle contains unsupported files: ${unsupported}.") + } + poms.each { String pom -> + if (!entries.contains(pom + '.md5') || !entries.contains(pom + '.sha1')) { + throw new GradleException("The model catalog POM is missing Central checksums: ${pom}.") + } + } + File report = layout.buildDirectory.file('reports/models/catalog-release-candidate.txt').get().asFile + report.parentFile.mkdirs() + report.setText("Bundle: ${bundle.name}\nBytes: ${bundle.length()}\n" + entries.join('\n') + '\n', 'UTF-8') + } +} + +tasks.register('verifyArtifactSizes') { + group = 'verification' + description = 'Reports artifact sizes and rejects dictionary bytes in core.' + dependsOn(tasks.named('verifyCoreJarExcludesModels')) + doLast { + File archive = tasks.named('jar', Jar).get().archiveFile.get().asFile + println('org.egothor:radixor:' + version + ' ' + archive.length() + ' bytes') + } +} + +tasks.named('check') { + dependsOn(tasks.named('verifyCoreJarExcludesModels')) + dependsOn(tasks.named('verifyAllDefaultModels')) + dependsOn(tasks.named('verifyJmhModelClasspath')) + dependsOn(tasks.named('verifyJavaLicenseHeaders')) +} + +def modelCatalogText = providers.provider { + StringBuilder output = new StringBuilder() + output.append('| Model ID | Language | Default | Coordinates | Version | Source | Repository | Source version | Revision | Revision status | License | Attribution | SHA-256 | Bytes |\n') + output.append('|---|---|---:|---|---:|---|---|---|---|---|---|---|---|---:|\n') + modelProjects().each { Project modelProject -> + String script = modelProject.file('build.gradle').getText('UTF-8') + def value = { String key -> + def matcher = script =~ /(?m)^\s*${key}\s*=\s*(?:'([^']+)'|([^\s]+))\s*$/ + if (!matcher.find()) return 'unavailable' + return matcher.group(1) != null ? matcher.group(1) : matcher.group(2) + } + File input = modelProject.file('src/modelInput/stemmer.gz') + String checksum = java.security.MessageDigest.getInstance('SHA-256').digest(input.bytes).encodeHex().toString() + output.append('| ').append(modelProject.name) + .append(' | ').append(value('language')) + .append(' | ').append(value('defaultModel')) + .append(' | org.egothor:radixor-model-').append(modelProject.name) + .append(' | ').append(modelProject.file('model-version.txt').text.trim()) + .append(' | ').append(value('sourceName')) + .append(' | ').append(value('sourceRepository')) + .append(' | ').append(value('sourceVersion')) + .append(' | ').append(value('sourceRevision')) + .append(' | ').append(value('sourceRevisionStatus')) + .append(' | ').append(value('sourceLicense')) + .append(' | ').append(value('sourceAttribution')) + .append(' | ').append(checksum) + .append(' | ').append(input.length()).append(' |\n') + } + return output.toString() +} + +tasks.register('generateModelCatalogDocumentation') { + group = 'documentation' + description = 'Generates the deterministic model catalog in the build documentation staging tree.' + outputs.file(layout.buildDirectory.file('mkdocs-source/stemmer-model-catalog.md')) + doLast { + File catalog = layout.buildDirectory.file('mkdocs-source/stemmer-model-catalog.md').get().asFile + catalog.parentFile.mkdirs() + catalog.setText('# Published Stemmer Model Catalog\n\n' + modelCatalogText.get(), 'UTF-8') + } +} + +tasks.register('prepareMkDocsSource', Sync) { + group = 'documentation' + description = 'Stages maintained documentation, generated catalog, and MkDocs configuration under build/.' + dependsOn(modelProjects().collect { Project modelProject -> modelProject.path + ':verifyModelDescriptor' }) + into(layout.buildDirectory.dir('mkdocs-source')) + from(layout.projectDirectory.dir('docs')) + doLast { + File catalog = layout.buildDirectory.file('mkdocs-source/stemmer-model-catalog.md').get().asFile + catalog.setText('# Published Stemmer Model Catalog\n\n' + modelCatalogText.get(), 'UTF-8') + File buildsPage = layout.buildDirectory.file('mkdocs-source/builds.md').get().asFile + buildsPage.setText('# Historical Builds\n\nThe Pages publication workflow replaces this staging placeholder with the retained build index.\n', 'UTF-8') + File configuration = layout.buildDirectory.file('mkdocs/mkdocs.yml').get().asFile + configuration.parentFile.mkdirs() + configuration.setText(layout.projectDirectory.file('mkdocs.yml').asFile.getText('UTF-8') + + '\ndocs_dir: ../mkdocs-source\nsite_dir: ../mkdocs-site\n', 'UTF-8') + } +} + +tasks.register('verifyModelCatalogDocumentation') { + group = 'verification' + description = 'Validates model metadata and the generated build-directory MkDocs catalog.' + dependsOn(tasks.named('prepareMkDocsSource')) + dependsOn(tasks.named('verifyAllDefaultModels')) + doLast { + File catalog = layout.buildDirectory.file('mkdocs-source/stemmer-model-catalog.md').get().asFile + String expected = '# Published Stemmer Model Catalog\n\n' + modelCatalogText.get() + if (!catalog.isFile() || catalog.getText('UTF-8') != expected) { + throw new GradleException('The staged model catalog is missing or nondeterministic.') + } + List identifiers = modelProjects().collect { Project modelProject -> modelProject.name } + if (identifiers != identifiers.sort()) { + throw new GradleException('Published model projects are not in deterministic model-ID order.') + } + identifiers.each { String identifier -> + if (!expected.contains('org.egothor:radixor-model-' + identifier)) { + throw new GradleException('The staged model catalog omits published model ' + identifier + '.') + } + } + if (!layout.buildDirectory.file('mkdocs/mkdocs.yml').get().asFile.isFile()) { + throw new GradleException('The staged MkDocs configuration is missing.') + } + } +} + +tasks.named('check') { + dependsOn(tasks.named('verifyModelCatalogDocumentation')) +} + +tasks.named('cyclonedxDirectBom') { + includeConfigs = ['runtimeClasspath', 'compileClasspath'] + skipConfigs = ['testRuntimeClasspath', 'testCompileClasspath', 'jmh.*', 'mockitoAgent'] includeBomSerialNumber = true includeLicenseText = false + includeMetadataResolution = true includeBuildSystem = true jsonOutput.set(sbomReportsDirectory.map { it.file('radixor-sbom.json') }) xmlOutput.set(sbomReportsDirectory.map { it.file('radixor-sbom.xml') }) } +subprojects { + tasks.matching { Task candidate -> candidate.name == 'cyclonedxDirectBom' }.configureEach { + enabled = false + description = 'Disabled because the root project exclusively owns CycloneDX SBOM generation.' + } +} + pitest { pitestVersion = '1.22.1' junit5PluginVersion = '1.2.3' @@ -461,6 +937,13 @@ tasks.named('jmh') { description = 'Runs JMH benchmarks for the Radixor algorithmic core and external stemmer comparison suites.' } +tasks.named('jmhJar', Jar) { + exclude 'META-INF/radixor/models.index' + exclude 'META-INF/radixor/models/**' + exclude 'org/egothor/stemmer/models/**' + exclude 'META-INF/LICENSES/**' +} + apply from: 'gradle/lucene-benchmarks.gradle' tasks.register('regressionArtifactGenerator', JavaExec) { @@ -486,13 +969,14 @@ tasks.register('regressionArtifactGenerator', JavaExec) { tasks.register('stemmingQuality', JavaExec) { group = 'verification' - description = 'Evaluates pairwise over-stemming and under-stemming against bundled dictionary groups.' + description = 'Evaluates pairwise over-stemming and under-stemming against registered model dictionary groups.' dependsOn(tasks.named('testClasses')) dependsOn(tasks.named('jmhClasses')) + dependsOn(tasks.named('prepareBenchmarkModelInputs')) classpath = files(sourceSets.test.runtimeClasspath, configurations.stemmingQualityJmhRuntime) mainClass = 'org.egothor.stemmer.benchmark.quality.StemmingQualityApplication' args layout.buildDirectory.dir('reports/stemming-quality').get().asFile.absolutePath, - layout.projectDirectory.dir('src/main/resources').asFile.absolutePath, + layout.buildDirectory.dir('generated/benchmark-model-inputs').get().asFile.absolutePath, providers.gradleProperty('stemmingQualityLanguage').getOrElse(''), providers.gradleProperty('stemmingQualityStemmer').getOrElse(''), providers.gradleProperty('stemmingQualityMode').getOrElse(''), @@ -503,6 +987,20 @@ tasks.register('stemmingQuality', JavaExec) { maxHeapSize = '6g' } +tasks.register('prepareBenchmarkModelInputs', Sync) { + group = 'verification' + description = 'Prepares default model inputs for JMH and quality evaluation without changing source data.' + into(layout.buildDirectory.dir('generated/benchmark-model-inputs')) + defaultModelProjects().each { Project modelProject -> + String languageDirectory = modelProject.name == 'pl-pl-unimorph' + ? 'pl_pl' + : modelProject.name.replace('-default', '').replace('-', '_') + from(modelProject.file('src/modelInput/stemmer.gz')) { + into(languageDirectory) + } + } +} + tasks.register('publishStemmingQualityDocumentation', JavaExec) { group = 'documentation' description = 'Publishes validated complete stemming-quality results on the language benchmark pages.' diff --git a/docs/architecture-and-reduction.md b/docs/architecture-and-reduction.md index 807c69a..09e45d4 100644 --- a/docs/architecture-and-reduction.md +++ b/docs/architecture-and-reduction.md @@ -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) diff --git a/docs/architecture.md b/docs/architecture.md index 7ae5866..4829bb0 100644 --- a/docs/architecture.md +++ b/docs/architecture.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:`. + +### 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//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//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=` and verifies transformation of a packaged resource into `FrequencyTrie`; 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@` | Root `org.egothor:radixor` artifacts only; never model JARs | +| `model/@` | Exactly one matching model; never core, catalog, or other models | +| `models-catalog@` | 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) diff --git a/docs/benchmarking.md b/docs/benchmarking.md index c2b665f..69d3596 100644 --- a/docs/benchmarking.md +++ b/docs/benchmarking.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). diff --git a/docs/benchmarks/reference/linguistic-quality.md b/docs/benchmarks/reference/linguistic-quality.md index 6b25d58..c5b76a7 100644 --- a/docs/benchmarks/reference/linguistic-quality.md +++ b/docs/benchmarks/reference/linguistic-quality.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. diff --git a/docs/benchmarks/reference/methodology.md b/docs/benchmarks/reference/methodology.md index a0b2013..cf994c1 100644 --- a/docs/benchmarks/reference/methodology.md +++ b/docs/benchmarks/reference/methodology.md @@ -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). diff --git a/docs/benchmarks/reference/reproducibility.md b/docs/benchmarks/reference/reproducibility.md index d6d3d72..a89298a 100644 --- a/docs/benchmarks/reference/reproducibility.md +++ b/docs/benchmarks/reference/reproducibility.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. diff --git a/docs/benchmarks/reference/tested-stemmers.md b/docs/benchmarks/reference/tested-stemmers.md index 26f0799..a10c2fe 100644 --- a/docs/benchmarks/reference/tested-stemmers.md +++ b/docs/benchmarks/reference/tested-stemmers.md @@ -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). diff --git a/docs/built-in-languages.md b/docs/built-in-languages.md index 0bed705..3d6b261 100644 --- a/docs/built-in-languages.md +++ b/docs/built-in-languages.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` 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 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:' + 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 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:' + runtimeOnly 'org.egothor:radixor-models-standard:' } ``` -`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 base = StemmerPatchTrieLoader.load( +final FrequencyTrie trie = + StemmerPatchTrieLoader.loadCompiled( StemmerPatchTrieLoader.Language.US_UK, true, ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS); - - final FrequencyTrie.Builder 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 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). diff --git a/docs/cli-compilation.md b/docs/cli-compilation.md index 04a4188..29c7ab0 100644 --- a/docs/cli-compilation.md +++ b/docs/cli-compilation.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/`, 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=`. 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). diff --git a/docs/compatibility-and-guarantees.md b/docs/compatibility-and-guarantees.md index d64af19..70c2bad 100644 --- a/docs/compatibility-and-guarantees.md +++ b/docs/compatibility-and-guarantees.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. diff --git a/docs/contributing-dictionaries.md b/docs/contributing-dictionaries.md index ed20b6f..626b746 100644 --- a/docs/contributing-dictionaries.md +++ b/docs/contributing-dictionaries.md @@ -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: diff --git a/docs/dictionary-format.md b/docs/dictionary-format.md index eb0aa11..af707b8 100644 --- a/docs/dictionary-format.md +++ b/docs/dictionary-format.md @@ -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//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). diff --git a/docs/fast-track.md b/docs/fast-track.md index e17f1f6..49a1d87 100644 --- a/docs/fast-track.md +++ b/docs/fast-track.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:") + runtimeOnly("org.egothor:radixor-model-us-uk-default:1.0.0") } ``` @@ -40,17 +40,23 @@ For a Maven project: org.egothor radixor - 3.0.0 + ${radixor.version} + + + org.egothor + radixor-model-us-uk-default + 1.0.0 + runtime ``` 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` 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` 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. diff --git a/docs/index.md b/docs/index.md index 2388f2e..dd7d4e9 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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:' + 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). diff --git a/docs/integration-deep-dive.md b/docs/integration-deep-dive.md index 71aa6cb..69efb5f 100644 --- a/docs/integration-deep-dive.md +++ b/docs/integration-deep-dive.md @@ -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` 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` 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:") + runtimeOnly("org.egothor:radixor-models-standard:") } ``` @@ -41,11 +43,17 @@ Maven: org.egothor radixor - 3.0.0 + ${radixor.version} + + + org.egothor + radixor-models-standard + ${model.catalog.version} + runtime ``` -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-` 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) diff --git a/docs/migration-and-backward-compatibility.md b/docs/migration-and-backward-compatibility.md index b5f514b..7afb9de 100644 --- a/docs/migration-and-backward-compatibility.md +++ b/docs/migration-and-backward-compatibility.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:` 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:` | +| 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:' + runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph:1.0.0' +} +``` + +Gradle, broad default coverage: + +```groovy +dependencies { + implementation 'org.egothor:radixor:' + runtimeOnly 'org.egothor:radixor-models-standard:' +} +``` + +Maven, preserving the Polish default: + +```xml + + org.egothor + radixor + ${radixor.version} + + + org.egothor + radixor-model-pl-pl-unimorph + 1.0.0 + runtime + +``` + +### Before and after: API behavior + +Language-oriented calls remain source-compatible: + +```java +final FrequencyTrie 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 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 diff --git a/docs/model-selection-and-loading.md b/docs/model-selection-and-loading.md new file mode 100644 index 0000000..6fbb203 --- /dev/null +++ b/docs/model-selection-and-loading.md @@ -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:' + runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph:1.0.0' +} +``` + +### Core plus optional PoliMorf + +```groovy +dependencies { + implementation 'org.egothor:radixor:' + 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:' + 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:' + runtimeOnly 'org.egothor:radixor-models-standard:' +} +``` + +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:' + implementation platform('org.egothor:radixor-models-bom:') + runtimeOnly 'org.egothor:radixor-model-pl-pl-unimorph' + runtimeOnly 'org.egothor:radixor-model-pl-pl-polimorf' +} +``` + +Equivalent Maven dependencies use ordinary runtime scope: + +```xml + + org.egothor + radixor + ${radixor.version} + + + org.egothor + radixor-model-pl-pl-unimorph + 1.0.0 + runtime + +``` + +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 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 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 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 unimorphTrie = + StemmerPatchTrieLoader.loadCompiled(unimorph, true, reductionMode); +final FrequencyTrie 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 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). diff --git a/docs/programmatic-loading-and-building.md b/docs/programmatic-loading-and-building.md index 9dbefae..e500479 100644 --- a/docs/programmatic-loading-and-building.md +++ b/docs/programmatic-loading-and-building.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` during loading. +Language-oriented entry points resolve a registered default model and compile its GZip textual dictionary into a `FrequencyTrie`. 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; diff --git a/docs/programmatic-usage.md b/docs/programmatic-usage.md index fe109d8..f2c23ae 100644 --- a/docs/programmatic-usage.md +++ b/docs/programmatic-usage.md @@ -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:` 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` for mutable construction and extension, -- `FrequencyTrie` 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:' +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 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 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 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 unimorphTrie = + StemmerPatchTrieLoader.loadCompiled(unimorph, true, reductionMode); +final FrequencyTrie 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 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) diff --git a/docs/quick-start.md b/docs/quick-start.md index 294409a..2d88258 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.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:' + runtimeOnly 'org.egothor:radixor-models-standard:' +} +``` + +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` 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`; 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). diff --git a/docs/reports.md b/docs/reports.md index 3516178..d76405e 100644 --- a/docs/reports.md +++ b/docs/reports.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 diff --git a/docs/stemmer-models.md b/docs/stemmer-models.md new file mode 100644 index 0000000..3e29d53 --- /dev/null +++ b/docs/stemmer-models.md @@ -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/` publishes: + +```text +org.egothor:radixor-model-: +``` + +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/-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//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--.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:` | POM-only aggregate with one transitive runtime default per language; excludes PoliMorf | +| `models/bom` | `org.egothor:radixor-models-bom:` | 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//build/`. + +## Create or update a model module + +1. Choose a stable lowercase model ID matching the module directory. +2. Add `models//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::validateModelInput +./gradlew --no-daemon :models::prepareModelResources +./gradlew --no-daemon :models::verifyModelDescriptor +./gradlew --no-daemon :models::verifyModelJar +./gradlew --no-daemon :models::check +./gradlew --no-daemon runtimeModelIntegrationTest -PmodelId= +``` + +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@` | Root `org.egothor:radixor` software artifacts | Model JARs, standard pack, or BOM | +| `model/@` | Exactly the matching independently versioned model | Core, other models, standard pack, BOM, JMH, or full quality suite | +| `models-catalog@` | 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). diff --git a/docs/stemming-quality.md b/docs/stemming-quality.md index 0cc7144..4e05a14 100644 --- a/docs/stemming-quality.md +++ b/docs/stemming-quality.md @@ -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). diff --git a/gradle/java-license-header.txt b/gradle/java-license-header.txt new file mode 100644 index 0000000..9bd8404 --- /dev/null +++ b/gradle/java-license-header.txt @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ diff --git a/gradle/maven-pom.gradle b/gradle/maven-pom.gradle index c7a8801..049fd57 100644 --- a/gradle/maven-pom.gradle +++ b/gradle/maven-pom.gradle @@ -51,11 +51,6 @@ publishing { url = pomLicenseUrl distribution = pomLicenseDistribution } - license { - name = pomStemmerDataLicenseName - url = pomStemmerDataLicenseUrl - distribution = pomLicenseDistribution - } } developers { @@ -104,8 +99,6 @@ tasks.register('validateReleaseMetadata') { if (pomScmDeveloperConnection == null || pomScmDeveloperConnection.isBlank()) missing.add('pomScmDeveloperConnection') if (pomLicenseName == null || pomLicenseName.isBlank()) missing.add('pomLicenseName') if (pomLicenseUrl == null || pomLicenseUrl.isBlank()) missing.add('pomLicenseUrl') - if (pomStemmerDataLicenseName == null || pomStemmerDataLicenseName.isBlank()) missing.add('pomStemmerDataLicenseName') - if (pomStemmerDataLicenseUrl == null || pomStemmerDataLicenseUrl.isBlank()) missing.add('pomStemmerDataLicenseUrl') if (signingKey == null || signingKey.isBlank()) missing.add('pomSigningKey / SIGNING_KEY') if (signingPassword == null || signingPassword.isBlank()) missing.add('pomSigningPassword / SIGNING_PASSWORD') diff --git a/gradle/paicehusk-benchmarks.gradle b/gradle/paicehusk-benchmarks.gradle index b21c903..7a6d3bc 100644 --- a/gradle/paicehusk-benchmarks.gradle +++ b/gradle/paicehusk-benchmarks.gradle @@ -120,6 +120,11 @@ def transformPaiceHuskSource = { final File sourceFile, final File rulesFile, fi transformedText = 'package org.egothor.stemmer.benchmark;' + '\n\n' + transformedText transformedText = transformedText.replaceFirst(/(?m)^\s*class\s+PaiceHusk\s*\{/, 'public final class PaiceHuskLancasterStemmer {') + transformedText = transformedText.replace('new Character(rule.letter)', 'Character.valueOf(rule.letter)') + transformedText = transformedText.replace('new Character(stem.charAt(stem.length() - 1))', + 'Character.valueOf(stem.charAt(stem.length() - 1))') + transformedText = transformedText.replaceFirst(/(?m)^(\s*)static HashMap loadRules\(/, + '$1@SuppressWarnings("unchecked")\n$1static HashMap loadRules(') final int packageEnd = transformedText.indexOf('\n', transformedText.indexOf('package org.egothor.stemmer.benchmark;')) if (packageEnd >= 0) { diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 974560c..00ab5ab 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -248,11 +248,24 @@ + + + + + + + + + + + + + @@ -274,6 +287,14 @@ + + + + + + + + @@ -294,6 +315,11 @@ + + + + + @@ -524,11 +550,24 @@ + + + + + + + + + + + + + @@ -725,6 +764,11 @@ + + + + + @@ -995,6 +1039,11 @@ + + + + + @@ -1003,6 +1052,14 @@ + + + + + + + + @@ -1011,6 +1068,14 @@ + + + + + + + + @@ -1019,6 +1084,14 @@ + + + + + + + + @@ -1027,6 +1100,14 @@ + + + + + + + + @@ -1035,6 +1116,14 @@ + + + + + + + + @@ -1045,6 +1134,11 @@ + + + + + @@ -1053,6 +1147,14 @@ + + + + + + + + @@ -1061,6 +1163,14 @@ + + + + + + + + @@ -1069,6 +1179,14 @@ + + + + + + + + @@ -1077,6 +1195,14 @@ + + + + + + + + @@ -1085,6 +1211,14 @@ + + + + + + + + @@ -1244,6 +1378,11 @@ + + + + + @@ -1257,6 +1396,14 @@ + + + + + + + + @@ -1302,6 +1449,14 @@ + + + + + + + + @@ -1326,11 +1481,24 @@ + + + + + + + + + + + + + @@ -1558,6 +1726,14 @@ + + + + + + + + diff --git a/mkdocs.yml b/mkdocs.yml index 445b394..9920fe1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -45,6 +45,7 @@ nav: - Integration: - Overview: programmatic-usage.md + - Model Selection and Loading: model-selection-and-loading.md - 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 @@ -52,6 +53,8 @@ nav: - CLI Compilation: cli-compilation.md - Dictionaries and Languages: + - Stemmer Models: stemmer-models.md + - Published Model Catalog: stemmer-model-catalog.md - Built-in Languages: built-in-languages.md - Dictionary Format: dictionary-format.md - Contributing Dictionaries: contributing-dictionaries.md @@ -101,4 +104,5 @@ nav: - Quality and Operations: quality-and-operations.md - Stemming Quality: stemming-quality.md - Reports: reports.md + - Historical Builds: builds.md - Test taxonomy and execution filtering: test-taxonomy-and-filtering.md diff --git a/models/bom/build.gradle b/models/bom/build.gradle new file mode 100644 index 0000000..9a32782 --- /dev/null +++ b/models/bom/build.gradle @@ -0,0 +1,101 @@ +import groovy.xml.XmlParser + +plugins { + id 'java-platform' + id 'maven-publish' + id 'signing' +} + +group = 'org.egothor' +version = providers.fileContents(rootProject.layout.projectDirectory.file('models/catalog-version.txt')) + .asText.map(String::trim).get() + +Properties modelTopology = new Properties() +rootProject.file('models/model-projects.properties').withInputStream { InputStream input -> + modelTopology.load(input) +} +List modelIds = modelTopology.stringPropertyNames().toList().sort() + +dependencies { + constraints { + modelIds.each { String modelId -> + api project(":models:${modelId}") + } + } +} + +publishing { + publications { + bom(MavenPublication) { + from components.javaPlatform + artifactId = 'radixor-models-bom' + pom { + name = 'Radixor Stemmer Models BOM' + description = 'Maven dependency-management BOM containing recommended versions for published Radixor models.' + packaging = 'pom' + url = 'https://github.com/leogalambos/Radixor' + licenses { + license { + name = 'BSD-3-Clause' + url = 'https://spdx.org/licenses/BSD-3-Clause.html' + distribution = 'repo' + } + } + developers { + developer { + id = 'egothor' + name = 'Leo Galambos' + email = 'egothor@gmail.com' + } + } + scm { + url = 'https://github.com/leogalambos/Radixor' + connection = 'scm:git:https://github.com/leogalambos/Radixor.git' + developerConnection = 'scm:git:ssh://git@github.com/leogalambos/Radixor.git' + } + } + } + } + repositories { + maven { + name = 'catalogStaging' + url = rootProject.layout.buildDirectory.dir('model-catalog-staging-repository').get().asFile.toURI() + } + } +} + +String signingKey = providers.environmentVariable('SIGNING_KEY').orNull +String signingPassword = providers.environmentVariable('SIGNING_PASSWORD').orNull +signing { + required = { providers.environmentVariable('GITHUB_REF_TYPE').orNull == 'tag' } + if (signingKey != null && !signingKey.isBlank()) { + useInMemoryPgpKeys(signingKey, signingPassword) + sign publishing.publications.bom + } +} + +tasks.register('verifyPomOnlyPlatform') { + group = 'verification' + description = 'Verifies the POM-only model dependency-management platform.' + dependsOn(tasks.named('generatePomFileForBomPublication')) + doLast { + File pomFile = layout.buildDirectory.file('publications/bom/pom-default.xml').get().asFile + Node pom = new XmlParser().parse(pomFile) + List constraints = pom.dependencyManagement.dependencies.dependency as List + List artifactIds = constraints.collect { Node dependency -> dependency.artifactId.text() } + List expected = modelIds.collect { String modelId -> "radixor-model-${modelId}" } + if (pom.packaging.text() != 'pom' || artifactIds != expected) { + throw new GradleException('radixor-models-bom must publish exactly the ordered model constraints as Maven packaging pom.') + } + if (!pom.dependencies.isEmpty()) { + throw new GradleException('radixor-models-bom must not introduce runtime model dependencies.') + } + if (!tasks.withType(Jar).isEmpty()) { + throw new GradleException('radixor-models-bom must not create binary, sources, or Javadoc JARs.') + } + } +} + +tasks.named('check') { + dependsOn(tasks.named('verifyPomOnlyPlatform')) +} diff --git a/models/catalog-version.txt b/models/catalog-version.txt new file mode 100644 index 0000000..6033ed8 --- /dev/null +++ b/models/catalog-version.txt @@ -0,0 +1 @@ +2026.1 diff --git a/models/cs-cz-default/build.gradle b/models/cs-cz-default/build.gradle new file mode 100644 index 0000000..887efad --- /dev/null +++ b/models/cs-cz-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'cs-cz-default' + language = 'CS_CZ' + displayName = 'Czech default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/ces' + sourceDataset = 'UniMorph Czech morphological dataset (`ces`); repository also documents non-distributed MorfFlex-CZ data' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph; Witold Kieraś is credited for the separate MorfFlex-CZ conversion' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/cs-cz-default/model-version.txt b/models/cs-cz-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/cs-cz-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/cs-cz-default/src/modelInput/NOTICE-model-data.txt b/models/cs-cz-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..5a0bd31 --- /dev/null +++ b/models/cs-cz-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: cs-cz-default +Radixor language: CS_CZ +Source project: UniMorph +Official repository: https://github.com/unimorph/ces +Upstream dataset: UniMorph Czech morphological dataset (`ces`); repository also documents non-distributed MorfFlex-CZ data +Upstream lexical source: Wiktionary; the CC BY-NC-SA MorfFlex-CZ dataset is excluded +Attribution: UniMorph; Witold Kieraś is credited for the separate MorfFlex-CZ conversion +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/cs_cz/stemmer.gz b/models/cs-cz-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/cs_cz/stemmer.gz rename to models/cs-cz-default/src/modelInput/stemmer.gz diff --git a/models/da-dk-default/build.gradle b/models/da-dk-default/build.gradle new file mode 100644 index 0000000..8b57e87 --- /dev/null +++ b/models/da-dk-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'da-dk-default' + language = 'DA_DK' + displayName = 'Danish default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/dan' + sourceDataset = 'UniMorph Danish morphological dataset (`dan`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/da-dk-default/model-version.txt b/models/da-dk-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/da-dk-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/da-dk-default/src/modelInput/NOTICE-model-data.txt b/models/da-dk-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..2467700 --- /dev/null +++ b/models/da-dk-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: da-dk-default +Radixor language: DA_DK +Source project: UniMorph +Official repository: https://github.com/unimorph/dan +Upstream dataset: UniMorph Danish morphological dataset (`dan`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/da_dk/stemmer.gz b/models/da-dk-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/da_dk/stemmer.gz rename to models/da-dk-default/src/modelInput/stemmer.gz diff --git a/models/de-de-default/build.gradle b/models/de-de-default/build.gradle new file mode 100644 index 0000000..4312802 --- /dev/null +++ b/models/de-de-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'de-de-default' + language = 'DE_DE' + displayName = 'German default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/deu' + sourceDataset = 'UniMorph German morphological dataset (`deu`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and English Wiktionary contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/de-de-default/model-version.txt b/models/de-de-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/de-de-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/de-de-default/src/modelInput/NOTICE-model-data.txt b/models/de-de-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..e7733f3 --- /dev/null +++ b/models/de-de-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: de-de-default +Radixor language: DE_DE +Source project: UniMorph +Official repository: https://github.com/unimorph/deu +Upstream dataset: UniMorph German morphological dataset (`deu`) +Upstream lexical source: English Wiktionary +Attribution: UniMorph and English Wiktionary contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/de_de/stemmer.gz b/models/de-de-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/de_de/stemmer.gz rename to models/de-de-default/src/modelInput/stemmer.gz diff --git a/models/es-es-default/build.gradle b/models/es-es-default/build.gradle new file mode 100644 index 0000000..657ff2e --- /dev/null +++ b/models/es-es-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'es-es-default' + language = 'ES_ES' + displayName = 'Spanish default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/spa' + sourceDataset = 'UniMorph Spanish morphological dataset (`spa`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and English Wiktionary contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/es-es-default/model-version.txt b/models/es-es-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/es-es-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/es-es-default/src/modelInput/NOTICE-model-data.txt b/models/es-es-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..5e9e1f2 --- /dev/null +++ b/models/es-es-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: es-es-default +Radixor language: ES_ES +Source project: UniMorph +Official repository: https://github.com/unimorph/spa +Upstream dataset: UniMorph Spanish morphological dataset (`spa`) +Upstream lexical source: English Wiktionary +Attribution: UniMorph and English Wiktionary contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/es_es/stemmer.gz b/models/es-es-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/es_es/stemmer.gz rename to models/es-es-default/src/modelInput/stemmer.gz diff --git a/models/fa-ir-default/build.gradle b/models/fa-ir-default/build.gradle new file mode 100644 index 0000000..e3a2a93 --- /dev/null +++ b/models/fa-ir-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'fa-ir-default' + language = 'FA_IR' + displayName = 'Persian default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/fas' + sourceDataset = 'UniMorph Persian morphological dataset (`fas`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/fa-ir-default/model-version.txt b/models/fa-ir-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/fa-ir-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/fa-ir-default/src/modelInput/NOTICE-model-data.txt b/models/fa-ir-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..92f065b --- /dev/null +++ b/models/fa-ir-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: fa-ir-default +Radixor language: FA_IR +Source project: UniMorph +Official repository: https://github.com/unimorph/fas +Upstream dataset: UniMorph Persian morphological dataset (`fas`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/fa_ir/stemmer.gz b/models/fa-ir-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/fa_ir/stemmer.gz rename to models/fa-ir-default/src/modelInput/stemmer.gz diff --git a/models/fi-fi-default/build.gradle b/models/fi-fi-default/build.gradle new file mode 100644 index 0000000..7602b05 --- /dev/null +++ b/models/fi-fi-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'fi-fi-default' + language = 'FI_FI' + displayName = 'Finnish default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/fin' + sourceDataset = 'UniMorph Finnish morphological dataset (`fin`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/fi-fi-default/model-version.txt b/models/fi-fi-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/fi-fi-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/fi-fi-default/src/modelInput/NOTICE-model-data.txt b/models/fi-fi-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..6ef855e --- /dev/null +++ b/models/fi-fi-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: fi-fi-default +Radixor language: FI_FI +Source project: UniMorph +Official repository: https://github.com/unimorph/fin +Upstream dataset: UniMorph Finnish morphological dataset (`fin`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/fi_fi/stemmer.gz b/models/fi-fi-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/fi_fi/stemmer.gz rename to models/fi-fi-default/src/modelInput/stemmer.gz diff --git a/models/fr-fr-default/build.gradle b/models/fr-fr-default/build.gradle new file mode 100644 index 0000000..55f2b4c --- /dev/null +++ b/models/fr-fr-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'fr-fr-default' + language = 'FR_FR' + displayName = 'French default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/fra' + sourceDataset = 'UniMorph French morphological dataset (`fra`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/fr-fr-default/model-version.txt b/models/fr-fr-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/fr-fr-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/fr-fr-default/src/modelInput/NOTICE-model-data.txt b/models/fr-fr-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..6591afc --- /dev/null +++ b/models/fr-fr-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: fr-fr-default +Radixor language: FR_FR +Source project: UniMorph +Official repository: https://github.com/unimorph/fra +Upstream dataset: UniMorph French morphological dataset (`fra`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/fr_fr/stemmer.gz b/models/fr-fr-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/fr_fr/stemmer.gz rename to models/fr-fr-default/src/modelInput/stemmer.gz diff --git a/models/he-il-default/build.gradle b/models/he-il-default/build.gradle new file mode 100644 index 0000000..ff0c6b3 --- /dev/null +++ b/models/he-il-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'he-il-default' + language = 'HE_IL' + displayName = 'Hebrew default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/heb' + sourceDataset = 'UniMorph Hebrew morphological dataset (`heb`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph; Omer Goldman (annotator); Wiktionary contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/he-il-default/model-version.txt b/models/he-il-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/he-il-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/he-il-default/src/modelInput/NOTICE-model-data.txt b/models/he-il-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..483c368 --- /dev/null +++ b/models/he-il-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: he-il-default +Radixor language: HE_IL +Source project: UniMorph +Official repository: https://github.com/unimorph/heb +Upstream dataset: UniMorph Hebrew morphological dataset (`heb`) +Upstream lexical source: Wiktionary +Attribution: UniMorph; Omer Goldman (annotator); Wiktionary contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/he_il/stemmer.gz b/models/he-il-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/he_il/stemmer.gz rename to models/he-il-default/src/modelInput/stemmer.gz diff --git a/models/hu-hu-default/build.gradle b/models/hu-hu-default/build.gradle new file mode 100644 index 0000000..9f96807 --- /dev/null +++ b/models/hu-hu-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'hu-hu-default' + language = 'HU_HU' + displayName = 'Hungarian default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/hun' + sourceDataset = 'UniMorph Hungarian morphological dataset (`hun`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph; Christo Kirov, Ryan Cotterell, and Khuyagbaatar Batsuren (conversion); Judit Ács and Gábor Bella (validation); English Wiktionary contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/hu-hu-default/model-version.txt b/models/hu-hu-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/hu-hu-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/hu-hu-default/src/modelInput/NOTICE-model-data.txt b/models/hu-hu-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..a0327e6 --- /dev/null +++ b/models/hu-hu-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: hu-hu-default +Radixor language: HU_HU +Source project: UniMorph +Official repository: https://github.com/unimorph/hun +Upstream dataset: UniMorph Hungarian morphological dataset (`hun`) +Upstream lexical source: English Wiktionary +Attribution: UniMorph; Christo Kirov, Ryan Cotterell, and Khuyagbaatar Batsuren (conversion); Judit Ács and Gábor Bella (validation); English Wiktionary contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/hu_hu/stemmer.gz b/models/hu-hu-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/hu_hu/stemmer.gz rename to models/hu-hu-default/src/modelInput/stemmer.gz diff --git a/models/it-it-default/build.gradle b/models/it-it-default/build.gradle new file mode 100644 index 0000000..b7776e4 --- /dev/null +++ b/models/it-it-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'it-it-default' + language = 'IT_IT' + displayName = 'Italian default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/ita' + sourceDataset = 'UniMorph Italian morphological dataset (`ita`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/it-it-default/model-version.txt b/models/it-it-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/it-it-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/it-it-default/src/modelInput/NOTICE-model-data.txt b/models/it-it-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..7ce8c6f --- /dev/null +++ b/models/it-it-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: it-it-default +Radixor language: IT_IT +Source project: UniMorph +Official repository: https://github.com/unimorph/ita +Upstream dataset: UniMorph Italian morphological dataset (`ita`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/it_it/stemmer.gz b/models/it-it-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/it_it/stemmer.gz rename to models/it-it-default/src/modelInput/stemmer.gz diff --git a/models/model-projects.properties b/models/model-projects.properties new file mode 100644 index 0000000..6511de4 --- /dev/null +++ b/models/model-projects.properties @@ -0,0 +1,22 @@ +# Build-topology membership only. Per-model metadata remains authoritative. +cs-cz-default=default +da-dk-default=default +de-de-default=default +es-es-default=default +fa-ir-default=default +fi-fi-default=default +fr-fr-default=default +he-il-default=default +hu-hu-default=default +it-it-default=default +nb-no-default=default +nl-nl-default=default +nn-no-default=default +pl-pl-polimorf=optional +pl-pl-unimorph=default +pt-pt-default=default +ru-ru-default=default +sv-se-default=default +uk-ua-default=default +us-uk-default=default +yi-default=default diff --git a/models/nb-no-default/build.gradle b/models/nb-no-default/build.gradle new file mode 100644 index 0000000..761a0dd --- /dev/null +++ b/models/nb-no-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'nb-no-default' + language = 'NB_NO' + displayName = 'Norwegian Bokmål default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/nob' + sourceDataset = 'UniMorph Norwegian Bokmål morphological dataset (`nob`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/nb-no-default/model-version.txt b/models/nb-no-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/nb-no-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/nb-no-default/src/modelInput/NOTICE-model-data.txt b/models/nb-no-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..436f4b8 --- /dev/null +++ b/models/nb-no-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: nb-no-default +Radixor language: NB_NO +Source project: UniMorph +Official repository: https://github.com/unimorph/nob +Upstream dataset: UniMorph Norwegian Bokmål morphological dataset (`nob`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/nb_no/stemmer.gz b/models/nb-no-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/nb_no/stemmer.gz rename to models/nb-no-default/src/modelInput/stemmer.gz diff --git a/models/nl-nl-default/build.gradle b/models/nl-nl-default/build.gradle new file mode 100644 index 0000000..901983b --- /dev/null +++ b/models/nl-nl-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'nl-nl-default' + language = 'NL_NL' + displayName = 'Dutch default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/nld' + sourceDataset = 'UniMorph Dutch morphological dataset (`nld`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/nl-nl-default/model-version.txt b/models/nl-nl-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/nl-nl-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/nl-nl-default/src/modelInput/NOTICE-model-data.txt b/models/nl-nl-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..42b9f7f --- /dev/null +++ b/models/nl-nl-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: nl-nl-default +Radixor language: NL_NL +Source project: UniMorph +Official repository: https://github.com/unimorph/nld +Upstream dataset: UniMorph Dutch morphological dataset (`nld`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/nl_nl/stemmer.gz b/models/nl-nl-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/nl_nl/stemmer.gz rename to models/nl-nl-default/src/modelInput/stemmer.gz diff --git a/models/nn-no-default/build.gradle b/models/nn-no-default/build.gradle new file mode 100644 index 0000000..a992d11 --- /dev/null +++ b/models/nn-no-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'nn-no-default' + language = 'NN_NO' + displayName = 'Norwegian Nynorsk default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/nno' + sourceDataset = 'UniMorph Norwegian Nynorsk morphological dataset (`nno`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/nn-no-default/model-version.txt b/models/nn-no-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/nn-no-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/nn-no-default/src/modelInput/NOTICE-model-data.txt b/models/nn-no-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..cc81eeb --- /dev/null +++ b/models/nn-no-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: nn-no-default +Radixor language: NN_NO +Source project: UniMorph +Official repository: https://github.com/unimorph/nno +Upstream dataset: UniMorph Norwegian Nynorsk morphological dataset (`nno`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/nn_no/stemmer.gz b/models/nn-no-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/nn_no/stemmer.gz rename to models/nn-no-default/src/modelInput/stemmer.gz diff --git a/models/pl-pl-polimorf/build.gradle b/models/pl-pl-polimorf/build.gradle new file mode 100644 index 0000000..df981c3 --- /dev/null +++ b/models/pl-pl-polimorf/build.gradle @@ -0,0 +1,27 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'pl-pl-polimorf' + language = 'PL_PL' + displayName = 'Polish — PoliMorf 2.1' + defaultModel = false + sourceName = 'PoliMorf 2.1' + sourceVersion = '2.1' + sourceRevision = '6e63b53' + sourceProject = 'Morfologik' + sourceRepository = 'https://github.com/morfologik/morfologik-stemming' + sourceDataset = 'PoliMorf 2.1 from org.carrot2:morfologik-polish:2.1.9' + sourceRevisionStatus = 'recorded' + sourceLicense = 'BSD-2-Clause' + sourceLicenseUri = 'https://spdx.org/licenses/BSD-2-Clause.html' + sourceAttribution = 'Copyright (c) 2016, Marcin Miłkowski' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Decoding the compiled FSA dictionary, grouping inflected forms by lemma, removing morphosyntactic tags, exact duplicate removal, deterministic sorting, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + licenseFileName = 'LICENSE-BSD-2-Clause.txt' +} + +tasks.named('validateModelRelease') { + dependsOn(rootProject.tasks.named('runtimeModelIntegrationTest')) +} diff --git a/models/pl-pl-polimorf/model-version.txt b/models/pl-pl-polimorf/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/pl-pl-polimorf/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/pl-pl-polimorf/src/modelInput/LICENSE-BSD-2-Clause.txt b/models/pl-pl-polimorf/src/modelInput/LICENSE-BSD-2-Clause.txt new file mode 100644 index 0000000..f2b10b4 --- /dev/null +++ b/models/pl-pl-polimorf/src/modelInput/LICENSE-BSD-2-Clause.txt @@ -0,0 +1,38 @@ +Upstream artifact: org.carrot2:morfologik-polish:2.1.9 +Dictionary: PoliMorf 2.1 +Upstream build date: 2016-02-13 +Upstream dictionary revision: 6e63b53 + +Changes in this version: decoding of the compiled FSA dictionary, +grouping of inflected forms by lemma, removal of morphosyntactic tags, +exact duplicate removal, deterministic sorting, and conversion to the +Radixor tab-separated dictionary format. + +Modifications copyright (c) 2026 Leo Galambos. + +SPDX-License-Identifier: BSD-2-Clause + +Copyright (c) 2016, Marcin Miłkowski +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/models/pl-pl-polimorf/src/modelInput/stemmer.gz b/models/pl-pl-polimorf/src/modelInput/stemmer.gz new file mode 100644 index 0000000..b04b1a4 Binary files /dev/null and b/models/pl-pl-polimorf/src/modelInput/stemmer.gz differ diff --git a/models/pl-pl-unimorph/build.gradle b/models/pl-pl-unimorph/build.gradle new file mode 100644 index 0000000..bfe2678 --- /dev/null +++ b/models/pl-pl-unimorph/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'pl-pl-unimorph' + language = 'PL_PL' + displayName = 'Polish — UniMorph' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/pol' + sourceDataset = 'UniMorph Polish morphological dataset (`pol`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph; SGJP authors Marcin Woliński, Zygmunt Saloni, Robert Wołosz, Włodzimierz Gruszczyński, Danuta Skowrońska, and Zbigniew Bronk; Witold Kieraś (conversion); Wiktionary contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/pl-pl-unimorph/model-version.txt b/models/pl-pl-unimorph/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/pl-pl-unimorph/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/pl-pl-unimorph/src/modelInput/NOTICE-model-data.txt b/models/pl-pl-unimorph/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..0b7610e --- /dev/null +++ b/models/pl-pl-unimorph/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: pl-pl-unimorph +Radixor language: PL_PL +Source project: UniMorph +Official repository: https://github.com/unimorph/pol +Upstream dataset: UniMorph Polish morphological dataset (`pol`) +Upstream lexical source: Wiktionary and Słownik gramatyczny języka polskiego (SGJP), as documented by the repository +Attribution: UniMorph; SGJP authors Marcin Woliński, Zygmunt Saloni, Robert Wołosz, Włodzimierz Gruszczyński, Danuta Skowrońska, and Zbigniew Bronk; Witold Kieraś (conversion); Wiktionary contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/pl_pl/stemmer.gz b/models/pl-pl-unimorph/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/pl_pl/stemmer.gz rename to models/pl-pl-unimorph/src/modelInput/stemmer.gz diff --git a/models/pt-pt-default/build.gradle b/models/pt-pt-default/build.gradle new file mode 100644 index 0000000..13fe21f --- /dev/null +++ b/models/pt-pt-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'pt-pt-default' + language = 'PT_PT' + displayName = 'Portuguese default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/por' + sourceDataset = 'UniMorph Portuguese morphological dataset (`por`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/pt-pt-default/model-version.txt b/models/pt-pt-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/pt-pt-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/pt-pt-default/src/modelInput/NOTICE-model-data.txt b/models/pt-pt-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..544a5f1 --- /dev/null +++ b/models/pt-pt-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: pt-pt-default +Radixor language: PT_PT +Source project: UniMorph +Official repository: https://github.com/unimorph/por +Upstream dataset: UniMorph Portuguese morphological dataset (`por`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/pt_pt/stemmer.gz b/models/pt-pt-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/pt_pt/stemmer.gz rename to models/pt-pt-default/src/modelInput/stemmer.gz diff --git a/models/ru-ru-default/build.gradle b/models/ru-ru-default/build.gradle new file mode 100644 index 0000000..6595522 --- /dev/null +++ b/models/ru-ru-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'ru-ru-default' + language = 'RU_RU' + displayName = 'Russian default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/rus' + sourceDataset = 'UniMorph Russian morphological dataset (`rus`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/ru-ru-default/model-version.txt b/models/ru-ru-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/ru-ru-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/ru-ru-default/src/modelInput/NOTICE-model-data.txt b/models/ru-ru-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..7f25ee7 --- /dev/null +++ b/models/ru-ru-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: ru-ru-default +Radixor language: RU_RU +Source project: UniMorph +Official repository: https://github.com/unimorph/rus +Upstream dataset: UniMorph Russian morphological dataset (`rus`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/ru_ru/stemmer.gz b/models/ru-ru-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/ru_ru/stemmer.gz rename to models/ru-ru-default/src/modelInput/stemmer.gz diff --git a/models/standard/build.gradle b/models/standard/build.gradle new file mode 100644 index 0000000..ba69894 --- /dev/null +++ b/models/standard/build.gradle @@ -0,0 +1,117 @@ +import groovy.xml.XmlParser + +plugins { + id 'base' + id 'maven-publish' + id 'signing' +} + +group = 'org.egothor' +version = providers.fileContents(rootProject.layout.projectDirectory.file('models/catalog-version.txt')) + .asText.map(String::trim).get() + +Properties modelTopology = new Properties() +rootProject.file('models/model-projects.properties').withInputStream { InputStream input -> + modelTopology.load(input) +} +List defaultModelIds = modelTopology.stringPropertyNames().findAll { String modelId -> + modelTopology.getProperty(modelId) == 'default' +}.sort() +Map defaultModelVersions = defaultModelIds.collectEntries { String modelId -> + final Project modelProject = project(":models:${modelId}") + final String modelVersion = providers.gradleProperty('modelReleaseVersion') + .orElse(providers.fileContents(modelProject.layout.projectDirectory.file('model-version.txt')) + .asText.map(String::trim)) + .get() + [(modelId): modelVersion] +} + +publishing { + publications { + standard(MavenPublication) { + artifactId = 'radixor-models-standard' + pom { + name = 'Radixor Standard Stemmer Models' + description = 'POM-only runtime aggregate containing one default model for every supported language.' + packaging = 'pom' + url = 'https://github.com/leogalambos/Radixor' + licenses { + license { + name = 'BSD-3-Clause' + url = 'https://spdx.org/licenses/BSD-3-Clause.html' + distribution = 'repo' + } + } + developers { + developer { + id = 'egothor' + name = 'Leo Galambos' + email = 'egothor@gmail.com' + } + } + scm { + url = 'https://github.com/leogalambos/Radixor' + connection = 'scm:git:https://github.com/leogalambos/Radixor.git' + developerConnection = 'scm:git:ssh://git@github.com/leogalambos/Radixor.git' + } + } + pom.withXml { + Node dependenciesNode = asNode().appendNode('dependencies') + defaultModelIds.each { String modelId -> + Node dependencyNode = dependenciesNode.appendNode('dependency') + dependencyNode.appendNode('groupId', 'org.egothor') + dependencyNode.appendNode('artifactId', "radixor-model-${modelId}") + dependencyNode.appendNode('version', defaultModelVersions.get(modelId)) + dependencyNode.appendNode('scope', 'runtime') + } + } + } + } + repositories { + maven { + name = 'catalogStaging' + url = rootProject.layout.buildDirectory.dir('model-catalog-staging-repository').get().asFile.toURI() + } + } +} + +String signingKey = providers.environmentVariable('SIGNING_KEY').orNull +String signingPassword = providers.environmentVariable('SIGNING_PASSWORD').orNull +signing { + required = { providers.environmentVariable('GITHUB_REF_TYPE').orNull == 'tag' } + if (signingKey != null && !signingKey.isBlank()) { + useInMemoryPgpKeys(signingKey, signingPassword) + sign publishing.publications.standard + } +} + +tasks.register('verifyPomOnlyAggregate') { + group = 'verification' + description = 'Verifies the standard POM-only aggregate and its runtime model dependencies.' + dependsOn(tasks.named('generatePomFileForStandardPublication')) + doLast { + File pomFile = layout.buildDirectory.file('publications/standard/pom-default.xml').get().asFile + Node pom = new XmlParser().parse(pomFile) + List dependencies = pom.dependencies.dependency as List + List artifactIds = dependencies.collect { Node dependency -> + dependency.artifactId.text() + } + List expected = defaultModelIds.collect { String modelId -> "radixor-model-${modelId}" } + if (pom.packaging.text() != 'pom') { + throw new GradleException('radixor-models-standard must publish Maven packaging pom.') + } + if (artifactIds != expected || dependencies.any { Node dependency -> dependency.scope.text() != 'runtime' }) { + throw new GradleException('radixor-models-standard must contain exactly the ordered default model runtime dependencies.') + } + if (artifactIds.contains('radixor-model-pl-pl-polimorf')) { + throw new GradleException('radixor-models-standard must exclude the optional PoliMorf model.') + } + if (!tasks.withType(Jar).isEmpty()) { + throw new GradleException('radixor-models-standard must not create binary, sources, or Javadoc JARs.') + } + } +} + +tasks.named('check') { + dependsOn(tasks.named('verifyPomOnlyAggregate')) +} diff --git a/models/sv-se-default/build.gradle b/models/sv-se-default/build.gradle new file mode 100644 index 0000000..4f97f52 --- /dev/null +++ b/models/sv-se-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'sv-se-default' + language = 'SV_SE' + displayName = 'Swedish default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/swe' + sourceDataset = 'UniMorph Swedish morphological dataset (`swe`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and English Wiktionary contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/sv-se-default/model-version.txt b/models/sv-se-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/sv-se-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/sv-se-default/src/modelInput/NOTICE-model-data.txt b/models/sv-se-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..e6dc079 --- /dev/null +++ b/models/sv-se-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: sv-se-default +Radixor language: SV_SE +Source project: UniMorph +Official repository: https://github.com/unimorph/swe +Upstream dataset: UniMorph Swedish morphological dataset (`swe`) +Upstream lexical source: English Wiktionary +Attribution: UniMorph and English Wiktionary contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/sv_se/stemmer.gz b/models/sv-se-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/sv_se/stemmer.gz rename to models/sv-se-default/src/modelInput/stemmer.gz diff --git a/models/uk-ua-default/build.gradle b/models/uk-ua-default/build.gradle new file mode 100644 index 0000000..8b575c7 --- /dev/null +++ b/models/uk-ua-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'uk-ua-default' + language = 'UK_UA' + displayName = 'Ukrainian default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/ukr' + sourceDataset = 'UniMorph Ukrainian morphological dataset (`ukr`); repository also documents non-distributed VESUM data' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph; Witold Kieraś and Maria Shvedova are credited for the separate VESUM conversion; Wiktionary contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/uk-ua-default/model-version.txt b/models/uk-ua-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/uk-ua-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/uk-ua-default/src/modelInput/NOTICE-model-data.txt b/models/uk-ua-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..d8f01a7 --- /dev/null +++ b/models/uk-ua-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: uk-ua-default +Radixor language: UK_UA +Source project: UniMorph +Official repository: https://github.com/unimorph/ukr +Upstream dataset: UniMorph Ukrainian morphological dataset (`ukr`); repository also documents non-distributed VESUM data +Upstream lexical source: Wiktionary; the CC BY-NC-SA VESUM dataset is excluded +Attribution: UniMorph; Witold Kieraś and Maria Shvedova are credited for the separate VESUM conversion; Wiktionary contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/uk_ua/stemmer.gz b/models/uk-ua-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/uk_ua/stemmer.gz rename to models/uk-ua-default/src/modelInput/stemmer.gz diff --git a/models/us-uk-default/build.gradle b/models/us-uk-default/build.gradle new file mode 100644 index 0000000..a436151 --- /dev/null +++ b/models/us-uk-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'us-uk-default' + language = 'US_UK' + displayName = 'English default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/eng' + sourceDataset = 'UniMorph English morphological dataset (`eng`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph and Wikipedia contributors' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/us-uk-default/model-version.txt b/models/us-uk-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/us-uk-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/us-uk-default/src/modelInput/NOTICE-model-data.txt b/models/us-uk-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..bea0e05 --- /dev/null +++ b/models/us-uk-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: us-uk-default +Radixor language: US_UK +Source project: UniMorph +Official repository: https://github.com/unimorph/eng +Upstream dataset: UniMorph English morphological dataset (`eng`) +Upstream lexical source: Wikipedia +Attribution: UniMorph and Wikipedia contributors +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/us_uk/stemmer.gz b/models/us-uk-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/us_uk/stemmer.gz rename to models/us-uk-default/src/modelInput/stemmer.gz diff --git a/models/yi-default/build.gradle b/models/yi-default/build.gradle new file mode 100644 index 0000000..c965d04 --- /dev/null +++ b/models/yi-default/build.gradle @@ -0,0 +1,23 @@ +plugins { + id 'org.egothor.radixor.model' +} + +radixorModel { + modelId = 'yi-default' + language = 'YI' + displayName = 'Yiddish default model' + defaultModel = true + sourceName = 'UniMorph' + sourceVersion = 'not-recorded-in-legacy-import' + sourceRevision = 'not-recorded-in-legacy-import' + sourceProject = 'UniMorph' + sourceRepository = 'https://github.com/unimorph/yid' + sourceDataset = 'UniMorph Yiddish morphological dataset (`yid`)' + sourceRevisionStatus = 'not-recorded-in-legacy-import' + sourceLicense = 'CC-BY-SA-3.0' + sourceLicenseUri = 'https://creativecommons.org/licenses/by-sa/3.0/' + sourceAttribution = 'UniMorph' + sourceVerificationDate = '2026-07-22' + transformationsSummary = 'Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata' + noticeFileName = 'NOTICE-model-data.txt' +} diff --git a/models/yi-default/model-version.txt b/models/yi-default/model-version.txt new file mode 100644 index 0000000..3eefcb9 --- /dev/null +++ b/models/yi-default/model-version.txt @@ -0,0 +1 @@ +1.0.0 diff --git a/models/yi-default/src/modelInput/NOTICE-model-data.txt b/models/yi-default/src/modelInput/NOTICE-model-data.txt new file mode 100644 index 0000000..3d6c76f --- /dev/null +++ b/models/yi-default/src/modelInput/NOTICE-model-data.txt @@ -0,0 +1,38 @@ +Radixor model-data notice + +Radixor-derived model data + +Copyright (C) 2026, Leo Galambos. + +Copyright and, where applicable, database rights are claimed in the +Radixor-specific selection, verification, cleaning, normalization, +grouping, deduplication, filtering, reformatting, metadata preparation, +and packaging of this model, to the extent protected by applicable law. + +The underlying morphological data remains attributed to UniMorph and +the upstream contributors identified in this notice. + +This derived model data, including Radixor's protectable contributions, +is distributed under Creative Commons Attribution-ShareAlike 3.0 +Unported. + +Model ID: yi-default +Radixor language: YI +Source project: UniMorph +Official repository: https://github.com/unimorph/yid +Upstream dataset: UniMorph Yiddish morphological dataset (`yid`) +Upstream lexical source: The official repository and catalog do not name a separate lexical source +Attribution: UniMorph +License: +Creative Commons Attribution-ShareAlike 3.0 Unported +Canonical license URI: https://creativecommons.org/licenses/by-sa/3.0/ +Source revision: not-recorded-in-legacy-import +Revision status: not-recorded-in-legacy-import + +The exact UniMorph commit used for the original Radixor import was not recorded. The model remains attributed to the official UniMorph language repository and is distributed under the repository's stated data license. + +Radixor modifications: Cleaning, normalization, grouping inflected forms by lemma, deduplication, filtering invalid rows, reformatting into Radixor dictionary groups, GZip packaging, and generation of runtime descriptor and checksum metadata. + +The derived model data is distributed under CC BY-SA 3.0. UniMorph supplies morphological data; Radixor constructs its own patch-command trie at runtime. Neither UniMorph nor any upstream contributor endorses Radixor. + +Upstream information verified: 2026-07-22 diff --git a/src/main/resources/yi/stemmer.gz b/models/yi-default/src/modelInput/stemmer.gz similarity index 100% rename from src/main/resources/yi/stemmer.gz rename to models/yi-default/src/modelInput/stemmer.gz diff --git a/settings.gradle b/settings.gradle index c3d5c2a..86d9169 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,5 +1,20 @@ +pluginManagement { + includeBuild('build-logic') +} + rootProject.name = 'Radixor' +include(':models:standard') +include(':models:bom') + +Properties modelTopology = new Properties() +file('models/model-projects.properties').withInputStream { InputStream input -> + modelTopology.load(input) +} +modelTopology.stringPropertyNames().toList().sort().each { String modelId -> + include(":models:${modelId}") +} + dependencyResolutionManagement { repositoriesMode = RepositoriesMode.FAIL_ON_PROJECT_REPOS repositories { diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/BenchmarkCorpusSupport.java b/src/jmh/java/org/egothor/stemmer/benchmark/BenchmarkCorpusSupport.java index 1700b7d..feb42c6 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/BenchmarkCorpusSupport.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/BenchmarkCorpusSupport.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/BenchmarkTokenSequence.java b/src/jmh/java/org/egothor/stemmer/benchmark/BenchmarkTokenSequence.java index 1145936..502cb27 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/BenchmarkTokenSequence.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/BenchmarkTokenSequence.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/EnglishComparisonCorpus.java b/src/jmh/java/org/egothor/stemmer/benchmark/EnglishComparisonCorpus.java index 0c302f4..0215064 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/EnglishComparisonCorpus.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/EnglishComparisonCorpus.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/EnglishRadixorDictionaryCoverageBenchmark.java b/src/jmh/java/org/egothor/stemmer/benchmark/EnglishRadixorDictionaryCoverageBenchmark.java index d626cb1..d1019f6 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/EnglishRadixorDictionaryCoverageBenchmark.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/EnglishRadixorDictionaryCoverageBenchmark.java @@ -331,7 +331,8 @@ public class EnglishRadixorDictionaryCoverageBenchmark { } private static List readEnglishRows() throws IOException { - final String resourcePath = StemmerPatchTrieLoader.Language.US_UK.resourcePath(); + final String resourcePath = org.egothor.stemmer.StemmerModelRegistry.fromContextClassLoader() + .requireDefault(StemmerPatchTrieLoader.Language.US_UK).resource(); final InputStream resource = StemmerPatchTrieLoader.class.getClassLoader().getResourceAsStream(resourcePath); if (resource == null) { throw new IllegalStateException("Missing bundled English dictionary resource " + resourcePath + "."); diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonBenchmark.java b/src/jmh/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonBenchmark.java index 5692112..dbbd64d 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonBenchmark.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonBenchmark.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonTokenStream.java b/src/jmh/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonTokenStream.java index a5ced0f..320583b 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonTokenStream.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonTokenStream.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/FrequencyTrieCompilationBenchmark.java b/src/jmh/java/org/egothor/stemmer/benchmark/FrequencyTrieCompilationBenchmark.java index 874cabd..455ce38 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/FrequencyTrieCompilationBenchmark.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/FrequencyTrieCompilationBenchmark.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/FrequencyTrieLookupBenchmark.java b/src/jmh/java/org/egothor/stemmer/benchmark/FrequencyTrieLookupBenchmark.java index fc4416d..635216e 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/FrequencyTrieLookupBenchmark.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/FrequencyTrieLookupBenchmark.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/LanguageBenchmarkCorpus.java b/src/jmh/java/org/egothor/stemmer/benchmark/LanguageBenchmarkCorpus.java index fc5c9a4..146e354 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/LanguageBenchmarkCorpus.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/LanguageBenchmarkCorpus.java @@ -332,7 +332,8 @@ final class LanguageBenchmarkCorpus { */ private static List readCandidates(final StemmerPatchTrieLoader.Language language, final int maximumTokenCount) throws IOException { - final String resourcePath = language.resourcePath(); + final String resourcePath = org.egothor.stemmer.StemmerModelRegistry.fromContextClassLoader() + .requireDefault(language).resource(); final InputStream resource = StemmerPatchTrieLoader.class.getClassLoader().getResourceAsStream(resourcePath); if (resource == null) { throw new IllegalStateException("Missing bundled benchmark resource " + resourcePath + "."); diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/MultiLanguageStemmerComparisonBenchmark.java b/src/jmh/java/org/egothor/stemmer/benchmark/MultiLanguageStemmerComparisonBenchmark.java index f4f78bf..741ab66 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/MultiLanguageStemmerComparisonBenchmark.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/MultiLanguageStemmerComparisonBenchmark.java @@ -95,7 +95,7 @@ import morfologik.stemming.WordData; * Each benchmark operation processes the same changed-token dictionary corpus * for one language, repeated only when the changed-token resource contains * fewer than 5,000 token fields. The token corpus is built during trial setup - * from Radixor's bundled dictionary for that same language. Lucene TokenFilter + * from Radixor's registered default-model dictionary for that same language. Lucene TokenFilter * methods include TokenStream and attribute overhead; direct Stempel measures * the public table-driven stemmer API without TokenFilter overhead. *

diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/QualityStemmerMatrix.java b/src/jmh/java/org/egothor/stemmer/benchmark/QualityStemmerMatrix.java index 64fa649..914253c 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/QualityStemmerMatrix.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/QualityStemmerMatrix.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark; import java.io.IOException; diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/SnowballStemmerAdapter.java b/src/jmh/java/org/egothor/stemmer/benchmark/SnowballStemmerAdapter.java index 0044e03..8a2bcd8 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/SnowballStemmerAdapter.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/SnowballStemmerAdapter.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/StemmerComparisonBenchmarkQuality.java b/src/jmh/java/org/egothor/stemmer/benchmark/StemmerComparisonBenchmarkQuality.java index c4fc16a..db74982 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/StemmerComparisonBenchmarkQuality.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/StemmerComparisonBenchmarkQuality.java @@ -444,6 +444,7 @@ public class StemmerComparisonBenchmarkQuality { * @return quality evaluator * @throws IOException if stemmer resources cannot be loaded */ + @SuppressWarnings("deprecation") // Lucene retains SpanishMinimalStemFilter only for compatibility benchmarking. CandidateStemmer createStemmer() throws IOException { if (name().endsWith("_RADIXOR")) { return radixor(createRadixorStemmer(this.radixorLanguage)); diff --git a/src/jmh/java/org/egothor/stemmer/benchmark/package-info.java b/src/jmh/java/org/egothor/stemmer/benchmark/package-info.java index 708058a..4700e17 100644 --- a/src/jmh/java/org/egothor/stemmer/benchmark/package-info.java +++ b/src/jmh/java/org/egothor/stemmer/benchmark/package-info.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 492ad04..ec12c0b 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ module org.egothor.radixor { requires java.logging; diff --git a/src/main/java/org/egothor/stemmer/CaseProcessingMode.java b/src/main/java/org/egothor/stemmer/CaseProcessingMode.java index 44be6ea..468a1d7 100644 --- a/src/main/java/org/egothor/stemmer/CaseProcessingMode.java +++ b/src/main/java/org/egothor/stemmer/CaseProcessingMode.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/Compile.java b/src/main/java/org/egothor/stemmer/Compile.java index 6300113..bca9d12 100644 --- a/src/main/java/org/egothor/stemmer/Compile.java +++ b/src/main/java/org/egothor/stemmer/Compile.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/DiacriticProcessingMode.java b/src/main/java/org/egothor/stemmer/DiacriticProcessingMode.java index 3d1777d..a12e81e 100644 --- a/src/main/java/org/egothor/stemmer/DiacriticProcessingMode.java +++ b/src/main/java/org/egothor/stemmer/DiacriticProcessingMode.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/DiacriticStripper.java b/src/main/java/org/egothor/stemmer/DiacriticStripper.java index 7cf2c1c..cc103b7 100644 --- a/src/main/java/org/egothor/stemmer/DiacriticStripper.java +++ b/src/main/java/org/egothor/stemmer/DiacriticStripper.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/DuplicateStemmerModelException.java b/src/main/java/org/egothor/stemmer/DuplicateStemmerModelException.java new file mode 100644 index 0000000..789cd9f --- /dev/null +++ b/src/main/java/org/egothor/stemmer/DuplicateStemmerModelException.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +/** + * Indicates that two classpath descriptors declare the same stable model identifier. + * Classpath order cannot resolve this conflict because model IDs must be unique. + */ +public final class DuplicateStemmerModelException extends IllegalStateException { + private static final long serialVersionUID = 1L; + /** + * Creates an exception describing the conflicting descriptor locations. + * @param message diagnostic containing both descriptor locations + */ + public DuplicateStemmerModelException(final String message) { + super(message); + } +} diff --git a/src/main/java/org/egothor/stemmer/FrequencyTrie.java b/src/main/java/org/egothor/stemmer/FrequencyTrie.java index 9ff0e11..0092eb4 100644 --- a/src/main/java/org/egothor/stemmer/FrequencyTrie.java +++ b/src/main/java/org/egothor/stemmer/FrequencyTrie.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/FrequencyTrieBuilders.java b/src/main/java/org/egothor/stemmer/FrequencyTrieBuilders.java index 372d743..473591c 100644 --- a/src/main/java/org/egothor/stemmer/FrequencyTrieBuilders.java +++ b/src/main/java/org/egothor/stemmer/FrequencyTrieBuilders.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/PatchCommandEncoder.java b/src/main/java/org/egothor/stemmer/PatchCommandEncoder.java index db8a01f..c31f5e2 100644 --- a/src/main/java/org/egothor/stemmer/PatchCommandEncoder.java +++ b/src/main/java/org/egothor/stemmer/PatchCommandEncoder.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/ReductionMode.java b/src/main/java/org/egothor/stemmer/ReductionMode.java index 7965a25..78b3bc1 100644 --- a/src/main/java/org/egothor/stemmer/ReductionMode.java +++ b/src/main/java/org/egothor/stemmer/ReductionMode.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/ReductionSettings.java b/src/main/java/org/egothor/stemmer/ReductionSettings.java index 8d8b1cb..8f3d26c 100644 --- a/src/main/java/org/egothor/stemmer/ReductionSettings.java +++ b/src/main/java/org/egothor/stemmer/ReductionSettings.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -38,7 +38,7 @@ import java.util.Objects; *

* The settings influence how mutable trie nodes are merged into canonical * read-only nodes during compilation. - * + * * @param reductionMode reduction mode * @param dominantWinnerMinPercent minimum dominant winner percentage * @param dominantWinnerOverSecondRatio minimum winner-over-second ratio diff --git a/src/main/java/org/egothor/stemmer/StemmerDictionaryParser.java b/src/main/java/org/egothor/stemmer/StemmerDictionaryParser.java index c3e1511..c6ded12 100644 --- a/src/main/java/org/egothor/stemmer/StemmerDictionaryParser.java +++ b/src/main/java/org/egothor/stemmer/StemmerDictionaryParser.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/StemmerKnowledgeExperiment.java b/src/main/java/org/egothor/stemmer/StemmerKnowledgeExperiment.java index 3da92b8..1c1d19d 100644 --- a/src/main/java/org/egothor/stemmer/StemmerKnowledgeExperiment.java +++ b/src/main/java/org/egothor/stemmer/StemmerKnowledgeExperiment.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -107,11 +107,11 @@ public final class StemmerKnowledgeExperiment { } /** - * Evaluates all supported bundled dictionaries using the supplied seed. + * Evaluates all supported registered default-model dictionaries using the supplied seed. * * @param seed deterministic sampling seed * @return immutable ordered list of experiment rows - * @throws IOException if reading a bundled dictionary fails + * @throws IOException if reading a registered default dictionary fails */ public List evaluateAllBundledLanguages(final long seed) throws IOException { final List rows = new ArrayList<>(); @@ -122,19 +122,19 @@ public final class StemmerKnowledgeExperiment { } /** - * Evaluates one bundled dictionary across all supported experiment + * Evaluates one registered default-model dictionary across all supported experiment * configurations. * - * @param language bundled language dictionary + * @param language language whose default model dictionary is evaluated * @param seed deterministic sampling seed * @return immutable ordered list of experiment rows * @throws NullPointerException if {@code language} is {@code null} - * @throws IOException if reading the bundled dictionary fails + * @throws IOException if reading the registered dictionary fails */ public List evaluateBundledLanguage(final StemmerPatchTrieLoader.Language language, final long seed) throws IOException { Objects.requireNonNull(language, "language"); - final String resourcePath = language.resourcePath(); + final String resourcePath = StemmerModelRegistry.fromContextClassLoader().requireDefault(language).resource(); try (InputStream inputStream = StemmerPatchTrieLoader.openBundledResource(resourcePath)) { try (BufferedReader reader = new BufferedReader( new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { @@ -349,13 +349,13 @@ public final class StemmerKnowledgeExperiment { * @param trie compiled trie under test * @return immutable counts for this single input */ - @SuppressWarnings("deprecation") private static EvaluationCounts evaluateInput(final String input, final String expectedStem, final FrequencyTrie trie) { long getCorrect = 0L; final String preferredPatch = trie.get(input); if (preferredPatch != null) { - final String preferredStem = PatchCommandEncoder.apply(input, preferredPatch); + final String preferredStem = PatchCommandEncoder.compile(preferredPatch, trie.traversalDirection()) + .apply(input); if (expectedStem.equals(preferredStem)) { getCorrect = 1L; } @@ -371,7 +371,7 @@ public final class StemmerKnowledgeExperiment { long falsePositives = 0L; long coveredInputs = 0L; for (String patch : patches) { - final String candidateStem = PatchCommandEncoder.apply(input, patch); + final String candidateStem = PatchCommandEncoder.compile(patch, trie.traversalDirection()).apply(input); if (expectedStem.equals(candidateStem)) { truePositives++; coveredInputs = 1L; diff --git a/src/main/java/org/egothor/stemmer/StemmerKnowledgeExperimentCli.java b/src/main/java/org/egothor/stemmer/StemmerKnowledgeExperimentCli.java index f574326..b2e3ecb 100644 --- a/src/main/java/org/egothor/stemmer/StemmerKnowledgeExperimentCli.java +++ b/src/main/java/org/egothor/stemmer/StemmerKnowledgeExperimentCli.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/StemmerModelDescriptor.java b/src/main/java/org/egothor/stemmer/StemmerModelDescriptor.java new file mode 100644 index 0000000..7f51a43 --- /dev/null +++ b/src/main/java/org/egothor/stemmer/StemmerModelDescriptor.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +import java.net.URL; +import java.util.Objects; + +/** + * Immutable validated metadata for one independently versioned Radixor model. + * + *

The descriptor identifies a GZip-compressed Radixor textual dictionary. It + * does not contain a precompiled trie. Instances are created during deterministic + * registry discovery and retain the descriptor URL used in diagnostics.

+ */ +@SuppressWarnings({ "PMD.DataClass", "PMD.ExcessiveParameterList", "PMD.CommentDefaultAccessModifier" }) +public final class StemmerModelDescriptor implements Comparable { + private final String id; + private final String version; + private final StemmerPatchTrieLoader.Language language; + private final String displayName; + private final String resource; + private final boolean defaultModel; + private final String format; + private final int formatVersion; + private final String sha256; + private final URL source; + private final ClassLoader classLoader; + + /** Creates a validated immutable descriptor. */ + StemmerModelDescriptor(final String id, final String version, final StemmerPatchTrieLoader.Language language, + final String displayName, final String resource, final boolean defaultModel, final String format, + final int formatVersion, final String sha256, final URL source, final ClassLoader classLoader) { + this.id = Objects.requireNonNull(id, "id"); + this.version = Objects.requireNonNull(version, "version"); + this.language = Objects.requireNonNull(language, "language"); + this.displayName = Objects.requireNonNull(displayName, "displayName"); + this.resource = Objects.requireNonNull(resource, "resource"); + this.defaultModel = defaultModel; + this.format = Objects.requireNonNull(format, "format"); + this.formatVersion = formatVersion; + this.sha256 = Objects.requireNonNull(sha256, "sha256"); + this.source = Objects.requireNonNull(source, "source"); + this.classLoader = Objects.requireNonNull(classLoader, "classLoader"); + } + + /** Returns the stable model identifier used for explicit deterministic selection. */ + public String id() { return this.id; } + /** Returns the independently managed model artifact version. */ + public String version() { return this.version; } + /** Returns the represented language. */ + public StemmerPatchTrieLoader.Language language() { return this.language; } + /** Returns the human-readable model name. */ + public String displayName() { return this.displayName; } + /** Returns the namespaced classpath dictionary resource. */ + public String resource() { return this.resource; } + /** + * Returns whether model metadata declares this model as a default candidate. + * Language-oriented runtime resolution uses + * {@link StemmerPatchTrieLoader.Language#defaultModelId()} as its authoritative + * mapping. + */ + public boolean isDefaultModel() { return this.defaultModel; } + /** Returns the dictionary format identifier. */ + public String format() { return this.format; } + /** Returns the dictionary format version. */ + public int formatVersion() { return this.formatVersion; } + /** Returns the lowercase SHA-256 digest of the compressed runtime resource bytes. */ + public String sha256() { return this.sha256; } + /** Returns the descriptor source URL used for diagnostics. */ + public URL source() { return this.source; } + /** Returns the discovering class loader. */ + ClassLoader classLoader() { return this.classLoader; } + + /** Compares descriptors by stable model identifier. */ + @Override + public int compareTo(final StemmerModelDescriptor other) { return this.id.compareTo(other.id); } + + /** Returns a concise descriptor representation. */ + @Override + public String toString() { return this.id + "@" + this.version + " (" + this.source + ")"; } +} diff --git a/src/main/java/org/egothor/stemmer/StemmerModelIntegrityException.java b/src/main/java/org/egothor/stemmer/StemmerModelIntegrityException.java new file mode 100644 index 0000000..925e9e7 --- /dev/null +++ b/src/main/java/org/egothor/stemmer/StemmerModelIntegrityException.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +/** + * Indicates invalid model packaging or integrity, including malformed metadata, + * invalid index entries, missing resources, inconsistent language declarations, + * or a checksum mismatch. + */ +public final class StemmerModelIntegrityException extends IllegalStateException { + private static final long serialVersionUID = 1L; + /** + * Creates an exception describing an integrity failure. + * @param message precise integrity diagnostic + */ + public StemmerModelIntegrityException(final String message) { + super(message); + } + + /** + * Creates an exception describing an integrity failure and its cause. + * @param message precise integrity diagnostic + * @param cause underlying parsing or platform failure + */ + public StemmerModelIntegrityException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/org/egothor/stemmer/StemmerModelNotFoundException.java b/src/main/java/org/egothor/stemmer/StemmerModelNotFoundException.java new file mode 100644 index 0000000..010fece --- /dev/null +++ b/src/main/java/org/egothor/stemmer/StemmerModelNotFoundException.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +/** + * Indicates that an explicitly requested model or a language's documented default + * model is absent from the selected class loader's runtime classpath. + */ +public final class StemmerModelNotFoundException extends IllegalStateException { + private static final long serialVersionUID = 1L; + /** + * Creates an exception with a precise remediation message. + * @param message diagnostic naming the missing ID and suggested dependency + */ + public StemmerModelNotFoundException(final String message) { + super(message); + } +} diff --git a/src/main/java/org/egothor/stemmer/StemmerModelRegistry.java b/src/main/java/org/egothor/stemmer/StemmerModelRegistry.java new file mode 100644 index 0000000..7aa7774 --- /dev/null +++ b/src/main/java/org/egothor/stemmer/StemmerModelRegistry.java @@ -0,0 +1,228 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Enumeration; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Properties; + +/** + * Immutable deterministic registry of models discovered from classpath indexes. + * + *

Discovery enumerates every {@value #INDEX_RESOURCE} visible to the selected + * class loader, validates the referenced descriptors, sorts them by stable model + * identifier, and rejects duplicate identifiers. Selection never depends on + * classpath order. Registry creation validates metadata and resource presence; + * {@link StemmerPatchTrieLoader} verifies resource bytes when loading a model.

+ * + *

Registry creation is not globally cached. Applications should normally + * discover once for a class-loader scope and retain the immutable result.

+ */ +@SuppressWarnings({ "PMD.UseProperClassLoader", "PMD.ControlStatementBraces" }) +public final class StemmerModelRegistry { + /** Fixed classpath index name used by every model artifact. */ + public static final String INDEX_RESOURCE = "META-INF/radixor/models.index"; + private static final String FORMAT = "radixor-dictionary-tsv-gzip"; + private static final int FORMAT_VERSION = 1; + private final Map descriptors; + + /** Creates an immutable registry from already validated descriptors. */ + private StemmerModelRegistry(final Map descriptors) { + this.descriptors = Collections.unmodifiableMap(new LinkedHashMap<>(descriptors)); + } + + /** + * Discovers models through the current thread context class loader. + * + *

If the context loader is {@code null}, the defining class loader of this + * registry is used.

+ * + * @return immutable registry in stable model-ID order + * @throws IOException if index or descriptor resources cannot be enumerated or read + * @throws DuplicateStemmerModelException if two descriptors declare one model ID + * @throws StemmerModelIntegrityException if an index, descriptor, or declared resource is invalid + * @throws UnsupportedStemmerModelFormatException if a descriptor uses an unsupported format + */ + public static StemmerModelRegistry fromContextClassLoader() throws IOException { + final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + return fromClassLoader(classLoader == null ? StemmerModelRegistry.class.getClassLoader() : classLoader); + } + + /** + * Discovers and validates every indexed descriptor visible to an explicit class loader. + * + * @param classLoader class loader whose indexed model resources are visible + * @return immutable registry in stable model-ID order + * @throws NullPointerException if {@code classLoader} is {@code null} + * @throws IOException if index or descriptor resources cannot be enumerated or read + * @throws DuplicateStemmerModelException if two descriptors declare one model ID + * @throws StemmerModelIntegrityException if an index, descriptor, or declared resource is invalid + * @throws UnsupportedStemmerModelFormatException if a descriptor uses an unsupported format + */ + public static StemmerModelRegistry fromClassLoader(final ClassLoader classLoader) throws IOException { + Objects.requireNonNull(classLoader, "classLoader"); + final List indexes = Collections.list(classLoader.getResources(INDEX_RESOURCE)); + indexes.sort((left, right) -> left.toExternalForm().compareTo(right.toExternalForm())); + final List discovered = new ArrayList<>(); + for (URL index : indexes) { + readIndex(index, classLoader, discovered); + } + Collections.sort(discovered); + final Map byId = new LinkedHashMap<>(); + for (StemmerModelDescriptor descriptor : discovered) { + final StemmerModelDescriptor previous = byId.putIfAbsent(descriptor.id(), descriptor); + if (previous != null) { + throw new DuplicateStemmerModelException("Duplicate model ID '" + descriptor.id() + "' at " + + previous.source() + " and " + descriptor.source() + "."); + } + } + return new StemmerModelRegistry(byId); + } + + /** Returns all descriptors in stable model-identifier order. */ + public List models() { return List.copyOf(this.descriptors.values()); } + + /** + * Returns the model with an exact stable identifier. + * + * @param modelId exact stable model identifier + * @return matching descriptor + * @throws NullPointerException if {@code modelId} is {@code null} + * @throws StemmerModelNotFoundException if the selected class loader exposes no matching descriptor + */ + public StemmerModelDescriptor require(final String modelId) { + Objects.requireNonNull(modelId, "modelId"); + final StemmerModelDescriptor descriptor = this.descriptors.get(modelId); + if (descriptor == null) { + throw new StemmerModelNotFoundException("No model '" + modelId + "' is available. Add org.egothor:radixor-model-" + + modelId + ": to the runtime classpath."); + } + return descriptor; + } + + /** + * Returns all models for a language in stable model-identifier order. + * + * @param language language to filter + * @return immutable list, possibly empty + * @throws NullPointerException if {@code language} is {@code null} + */ + public List findByLanguage(final StemmerPatchTrieLoader.Language language) { + Objects.requireNonNull(language, "language"); + return this.descriptors.values().stream().filter(value -> value.language() == language).toList(); + } + + /** + * Resolves the language's documented default model without classpath-order fallback. + * + * @param language language whose {@link StemmerPatchTrieLoader.Language#defaultModelId()} is required + * @return exact default-model descriptor + * @throws NullPointerException if {@code language} is {@code null} + * @throws StemmerModelNotFoundException if the default model is not visible + * @throws StemmerModelIntegrityException if the default descriptor declares another language + */ + public StemmerModelDescriptor requireDefault(final StemmerPatchTrieLoader.Language language) { + Objects.requireNonNull(language, "language"); + final StemmerModelDescriptor descriptor = this.descriptors.get(language.defaultModelId()); + if (descriptor == null) { + throw new StemmerModelNotFoundException("No default model '" + language.defaultModelId() + + "' is available for language " + language + ". Add org.egothor:radixor-model-" + + language.defaultModelId() + ": to the runtime classpath."); + } + if (descriptor.language() != language) { + throw new StemmerModelIntegrityException("Default model '" + descriptor.id() + "' declares language " + + descriptor.language() + " instead of " + language + "."); + } + return descriptor; + } + + /** Reads one deterministic index and appends its descriptors. */ + private static void readIndex(final URL index, final ClassLoader classLoader, + final List descriptors) throws IOException { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(index.openStream(), StandardCharsets.UTF_8))) { + String line; + int lineNumber = 0; + while ((line = reader.readLine()) != null) { + lineNumber++; + final String path = line.trim(); + if (path.isEmpty() || path.startsWith("#")) continue; + if (!path.matches("META-INF/radixor/models/[a-z0-9-]+\\.properties")) { + throw new StemmerModelIntegrityException("Malformed model index entry at " + index + ":" + lineNumber + ": " + path); + } + final Enumeration resources = classLoader.getResources(path); + if (!resources.hasMoreElements()) throw new StemmerModelIntegrityException("Indexed descriptor is missing: " + path + " from " + index); + while (resources.hasMoreElements()) descriptors.add(readDescriptor(resources.nextElement(), classLoader)); + } + } + } + + /** Parses and validates one immutable descriptor. */ + private static StemmerModelDescriptor readDescriptor(final URL source, final ClassLoader classLoader) throws IOException { + final Properties properties = new Properties(); + try (InputStream input = source.openStream()) { properties.load(input); } + final String id = required(properties, "model.id", source); + if (!id.matches("[a-z]{2}(?:-[a-z]{2})?-[a-z0-9]+(?:-[a-z0-9]+)*")) throw new StemmerModelIntegrityException("Invalid model.id '" + id + "' at " + source); + final String format = required(properties, "model.format", source); + final int version; + try { version = Integer.parseInt(required(properties, "model.formatVersion", source)); } + catch (NumberFormatException exception) { throw new StemmerModelIntegrityException("Invalid model.formatVersion at " + source, exception); } + if (!FORMAT.equals(format) || version != FORMAT_VERSION) throw new UnsupportedStemmerModelFormatException("Unsupported model format " + format + " version " + version + " at " + source + "."); + final StemmerPatchTrieLoader.Language language; + try { language = StemmerPatchTrieLoader.Language.valueOf(required(properties, "model.language", source)); } + catch (IllegalArgumentException exception) { throw new StemmerModelIntegrityException("Invalid model.language at " + source, exception); } + final String resource = required(properties, "model.resource", source); + if (!resource.equals("org/egothor/stemmer/models/" + id + "/stemmer.gz")) throw new StemmerModelIntegrityException("Invalid model.resource for '" + id + "' at " + source); + if (classLoader.getResource(resource) == null) throw new StemmerModelIntegrityException("Model resource is missing: " + resource + " declared at " + source); + final String checksum = required(properties, "model.sha256", source); + if (!checksum.matches("[0-9a-f]{64}")) throw new StemmerModelIntegrityException("Invalid model.sha256 at " + source); + return new StemmerModelDescriptor(id, required(properties, "model.version", source), language, + required(properties, "model.displayName", source), resource, + Boolean.parseBoolean(required(properties, "model.default", source)), format, version, checksum, source, classLoader); + } + + /** Returns a required nonblank property. */ + private static String required(final Properties properties, final String key, final URL source) { + final String value = properties.getProperty(key); + if (value == null || value.isBlank()) throw new StemmerModelIntegrityException("Required property '" + key + "' is missing at " + source); + return value.trim(); + } +} diff --git a/src/main/java/org/egothor/stemmer/StemmerPatchTrieBinaryIO.java b/src/main/java/org/egothor/stemmer/StemmerPatchTrieBinaryIO.java index f91ecd8..4f16d1c 100644 --- a/src/main/java/org/egothor/stemmer/StemmerPatchTrieBinaryIO.java +++ b/src/main/java/org/egothor/stemmer/StemmerPatchTrieBinaryIO.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/StemmerPatchTrieLoader.java b/src/main/java/org/egothor/stemmer/StemmerPatchTrieLoader.java index 6b47b7f..0697e42 100644 --- a/src/main/java/org/egothor/stemmer/StemmerPatchTrieLoader.java +++ b/src/main/java/org/egothor/stemmer/StemmerPatchTrieLoader.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -39,6 +39,7 @@ import java.io.PushbackInputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.security.MessageDigest; import java.util.HashMap; import java.util.Map; import java.util.Objects; @@ -94,13 +95,14 @@ public final class StemmerPatchTrieLoader { } /** - * Supported bundled stemmer dictionaries. + * Supported language identities and their stable default model mappings. * *

* Each language constant defines: *

*
    - *
  • the resource directory name used under the bundled resources tree
  • + *
  • a deprecated legacy resource-directory name
  • + *
  • the stable default model ID used by language-oriented loading
  • *
  • whether the language is written right-to-left
  • *
* @@ -115,108 +117,111 @@ public final class StemmerPatchTrieLoader { /** * Czech. */ - CS_CZ("cs_cz", false), + CS_CZ("cs_cz", "cs-cz-default", false), /** * Danish. */ - DA_DK("da_dk", false), + DA_DK("da_dk", "da-dk-default", false), /** * German. */ - DE_DE("de_de", false), + DE_DE("de_de", "de-de-default", false), /** * Spanish. */ - ES_ES("es_es", false), + ES_ES("es_es", "es-es-default", false), /** * Persian. */ - FA_IR("fa_ir", true), + FA_IR("fa_ir", "fa-ir-default", true), /** * Finnish. */ - FI_FI("fi_fi", false), + FI_FI("fi_fi", "fi-fi-default", false), /** * French. */ - FR_FR("fr_fr", false), + FR_FR("fr_fr", "fr-fr-default", false), /** * Hebrew. */ - HE_IL("he_il", true), + HE_IL("he_il", "he-il-default", true), /** * Hungarian. */ - HU_HU("hu_hu", false), + HU_HU("hu_hu", "hu-hu-default", false), /** * Italian. */ - IT_IT("it_it", false), + IT_IT("it_it", "it-it-default", false), /** * Norwegian Bokmål. */ - NB_NO("nb_no", false), + NB_NO("nb_no", "nb-no-default", false), /** * Dutch. */ - NL_NL("nl_nl", false), + NL_NL("nl_nl", "nl-nl-default", false), /** * Norwegian Nynorsk. */ - NN_NO("nn_no", false), + NN_NO("nn_no", "nn-no-default", false), /** * Polish. */ - PL_PL("pl_pl", false), + PL_PL("pl_pl", "pl-pl-unimorph", false), /** * Portuguese. */ - PT_PT("pt_pt", false), + PT_PT("pt_pt", "pt-pt-default", false), /** * Russian. */ - RU_RU("ru_ru", false), + RU_RU("ru_ru", "ru-ru-default", false), /** * Swedish. */ - SV_SE("sv_se", false), + SV_SE("sv_se", "sv-se-default", false), /** * Ukrainian. */ - UK_UA("uk_ua", false), + UK_UA("uk_ua", "uk-ua-default", false), /** * English. */ - US_UK("us_uk", false), + US_UK("us_uk", "us-uk-default", false), /** * Yiddish. */ - YI("yi", true); + YI("yi", "yi-default", true); /** * Resource directory name. */ private final String resourceDirectory; + /** Stable identifier of the documented default model. */ + private final String defaultModelId; + /** * Whether the language is written right-to-left. */ @@ -225,21 +230,37 @@ public final class StemmerPatchTrieLoader { /** * Creates a language constant. * - * @param resourceDirectory resource directory name + * @param resourceDirectory deprecated legacy resource directory name + * @param defaultModelId stable default model identifier * @param rightToLeft whether the language is written right-to-left */ - Language(final String resourceDirectory, final boolean rightToLeft) { + Language(final String resourceDirectory, final String defaultModelId, final boolean rightToLeft) { this.resourceDirectory = resourceDirectory; + this.defaultModelId = defaultModelId; this.rightToLeft = rightToLeft; } /** - * Returns the classpath resource path of the bundled stemmer dictionary. + * Returns the conventional resource path of this language's default model. + * + *

Production loading resolves descriptors through + * {@link StemmerModelRegistry}; it does not use this method for discovery or + * selection.

* * @return classpath resource path */ + @Deprecated(since = "4.0.0", forRemoval = false) public String resourcePath() { - return this.resourceDirectory + "/stemmer.gz"; + return "org/egothor/stemmer/models/" + this.defaultModelId + "/stemmer.gz"; + } + + /** + * Returns the stable identifier selected by language-oriented loader methods. + * + * @return exact model ID, independent of classpath ordering + */ + public String defaultModelId() { + return this.defaultModelId; } /** @@ -269,7 +290,7 @@ public final class StemmerPatchTrieLoader { } /** - * Loads a bundled dictionary using explicit reduction settings. + * Loads the language's registered default model using explicit reduction settings. * *

* This overload applies the following implicit compilation defaults in addition @@ -289,7 +310,7 @@ public final class StemmerPatchTrieLoader { * resulting trie. *

* - * @param language bundled language dictionary + * @param language language whose stable default model is required * @param storeOriginal whether the stem itself should be inserted using the * canonical no-op patch command * @param reductionSettings reduction settings @@ -312,7 +333,7 @@ public final class StemmerPatchTrieLoader { } /** - * Loads a bundled dictionary and returns a runtime-specialized trie whose + * Loads the language's registered default model and returns a runtime-specialized trie whose * values are compiled patch commands. * *

@@ -322,7 +343,7 @@ public final class StemmerPatchTrieLoader { * runtime stemming does not parse patch-command strings. *

* - * @param language bundled language dictionary + * @param language language whose stable default model is required * @param storeOriginal whether the stem itself should be inserted using the * canonical no-op patch command * @param reductionSettings reduction settings @@ -336,7 +357,7 @@ public final class StemmerPatchTrieLoader { } /** - * Loads a bundled dictionary using explicit trie compilation metadata. + * Loads the language's registered default model using explicit trie compilation metadata. * *

* All semantic compilation settings (reduction mode and thresholds, traversal @@ -345,7 +366,7 @@ public final class StemmerPatchTrieLoader { * resulting trie. *

* - * @param language bundled language dictionary + * @param language language whose stable default model is required * @param storeOriginal whether the stem itself should be inserted using the * canonical no-op patch command * @param metadata trie metadata describing the compilation configuration @@ -362,20 +383,117 @@ public final class StemmerPatchTrieLoader { Objects.requireNonNull(language, "language"); Objects.requireNonNull(metadata, "metadata"); - final String resourcePath = language.resourcePath(); + final StemmerModelDescriptor descriptor = StemmerModelRegistry.fromContextClassLoader().requireDefault(language); + return load(descriptor, storeOriginal, metadata); + } - try (InputStream inputStream = openBundledResource(resourcePath); + /** + * Loads an explicitly selected descriptor using trie compilation metadata. + * + *

The method opens the descriptor's namespaced resource through its + * discovering class loader, verifies SHA-256 over the compressed bytes, + * decompresses the GZip UTF-8 dictionary, parses it, and builds a trie. Each + * invocation performs this work and returns serialized patch-command values.

+ * + * @param descriptor exact validated model descriptor + * @param storeOriginal whether canonical stems receive no-op mappings + * @param metadata trie compilation configuration + * @return newly built trie containing serialized patch-command strings + * @throws NullPointerException if {@code descriptor} or {@code metadata} is {@code null} + * @throws IOException if the compressed dictionary cannot be read or decompressed + * @throws StemmerModelIntegrityException if the resource is missing or its checksum differs + */ + public static FrequencyTrie load(final StemmerModelDescriptor descriptor, final boolean storeOriginal, + final TrieMetadata metadata) throws IOException { + Objects.requireNonNull(descriptor, "descriptor"); + Objects.requireNonNull(metadata, "metadata"); + try (InputStream inputStream = openModelResource(descriptor); BufferedReader reader = new BufferedReader( new InputStreamReader(inputStream, StandardCharsets.UTF_8))) { - return load(reader, resourcePath, storeOriginal, metadata); + return load(reader, descriptor.resource(), storeOriginal, metadata); } } /** - * Loads a bundled dictionary using explicit trie compilation metadata and + * Loads one exact model descriptor and returns a runtime-specialized trie. + * + *

The descriptor's compressed dictionary is integrity-checked, fully + * parsed, reduced with the supplied mode, and converted to immutable + * {@link CompiledPatchCommand} values. The method does not consult a language + * default and does not cache the constructed trie. Applications should retain + * the result for their intended runtime scope. Constructing exceptionally + * large models can require substantial temporary heap.

+ * + * @param descriptor exact validated model descriptor + * @param storeOriginal whether canonical stems receive no-op mappings + * @param reductionMode reduction mode applied during trie construction + * @return newly constructed trie containing compiled patch commands + * @throws NullPointerException if {@code descriptor} or {@code reductionMode} is {@code null} + * @throws IOException if the compressed dictionary cannot be read or decompressed + * @throws StemmerModelIntegrityException if the resource is missing or its checksum differs + */ + public static FrequencyTrie loadCompiled(final StemmerModelDescriptor descriptor, + final boolean storeOriginal, final ReductionMode reductionMode) throws IOException { + Objects.requireNonNull(descriptor, "descriptor"); + Objects.requireNonNull(reductionMode, "reductionMode"); + final TrieMetadata metadata = metadataForCompilation(traversalDirectionOf(descriptor.language()), + ReductionSettings.withDefaults(reductionMode), CaseProcessingMode.LOWERCASE_WITH_LOCALE_ROOT, + DiacriticProcessingMode.AS_IS); + return compilePatchTrie(load(descriptor, storeOriginal, metadata)); + } + + /** + * Loads an exact model ID through a newly discovered context-class-loader registry. + * + *

This method is distinct from {@code load(String, ...)}, whose string is a + * filesystem path. Selection is exact and never falls back to another model for + * the same language.

+ * + * @param modelId exact stable model identifier + * @param storeOriginal whether canonical stems receive no-op mappings + * @param metadata trie compilation configuration + * @return newly built trie containing serialized patch-command strings + * @throws NullPointerException if {@code modelId} or {@code metadata} is {@code null} + * @throws IOException if discovery or resource reading fails + * @throws StemmerModelNotFoundException if the model is not visible + * @throws DuplicateStemmerModelException if discovery finds duplicate IDs + * @throws UnsupportedStemmerModelFormatException if discovery finds an unsupported format + * @throws StemmerModelIntegrityException if metadata or resource integrity is invalid + */ + public static FrequencyTrie loadModel(final String modelId, final boolean storeOriginal, + final TrieMetadata metadata) throws IOException { + return load(StemmerModelRegistry.fromContextClassLoader().require(modelId), storeOriginal, metadata); + } + + /** Opens, integrity-checks, and decompresses a descriptor-backed dictionary. */ + @SuppressWarnings("PMD.CloseResource") + private static InputStream openModelResource(final StemmerModelDescriptor descriptor) throws IOException { + final InputStream unresolvedResource = descriptor.classLoader().getResourceAsStream(descriptor.resource()); + if (unresolvedResource == null) { + throw new StemmerModelIntegrityException("Model resource is missing: " + descriptor.resource()); + } + final byte[] bytes; + try (InputStream resource = unresolvedResource) { + bytes = resource.readAllBytes(); + } + final String checksum; + try { + checksum = java.util.HexFormat.of().formatHex(MessageDigest.getInstance("SHA-256").digest(bytes)); + } catch (java.security.NoSuchAlgorithmException exception) { + throw new StemmerModelIntegrityException("The required SHA-256 algorithm is unavailable.", exception); + } + if (!checksum.equals(descriptor.sha256())) { + throw new StemmerModelIntegrityException("Checksum mismatch for model '" + descriptor.id() + "' at " + + descriptor.resource() + ": expected " + descriptor.sha256() + " but found " + checksum + "."); + } + return new GZIPInputStream(new java.io.ByteArrayInputStream(bytes)); + } + + /** + * Loads the language's registered default model using explicit trie compilation metadata and * returns a runtime-specialized trie whose values are compiled patch commands. * - * @param language bundled language dictionary + * @param language language whose stable default model is required * @param storeOriginal whether the stem itself should be inserted using the * canonical no-op patch command * @param metadata trie metadata describing the compilation configuration @@ -389,7 +507,7 @@ public final class StemmerPatchTrieLoader { } /** - * Loads a bundled dictionary using default settings for the supplied reduction + * Loads the language's registered default model using settings for the supplied reduction * mode. * *

@@ -400,7 +518,7 @@ public final class StemmerPatchTrieLoader { * diacritic processing mode. *

* - * @param language bundled language dictionary + * @param language language whose stable default model is required * @param storeOriginal whether the stem itself should be inserted using the * canonical no-op patch command * @param reductionMode reduction mode @@ -419,11 +537,11 @@ public final class StemmerPatchTrieLoader { } /** - * Loads a bundled dictionary using default settings for the supplied reduction + * Loads the language's registered default model using settings for the supplied reduction * mode and returns a runtime-specialized trie whose values are compiled patch * commands. * - * @param language bundled language dictionary + * @param language language whose stable default model is required * @param storeOriginal whether the stem itself should be inserted using the * canonical no-op patch command * @param reductionMode reduction mode @@ -1036,9 +1154,11 @@ public final class StemmerPatchTrieLoader { * @return compiled patch-command trie * @throws NullPointerException if any argument is {@code null} * @throws IOException if the file cannot be opened or read - * @deprecated Since 2.3.0 for runtime stemming. Use - * {@link #loadCompiled(String, boolean, ReductionMode)} so patch - * commands are represented as {@link CompiledPatchCommand} values. + * @deprecated Since 2.3.0 for runtime stemming. Convert {@code fileName} to a + * {@link Path} and use {@link #loadCompiled(Path, boolean, ReductionMode)} + * so patch commands are represented as {@link CompiledPatchCommand} + * values. The corresponding compiled {@code String} signature is + * reserved for stable model identifiers. */ @Deprecated(since = "2.3.0", forRemoval = false) public static FrequencyTrie load(final String fileName, final boolean storeOriginal, @@ -1048,22 +1168,35 @@ public final class StemmerPatchTrieLoader { } /** - * Loads a dictionary from a filesystem path string using default settings for - * the supplied reduction mode and returns runtime-specialized compiled patch - * values. + * Loads one exact stable model identifier and returns a runtime-specialized trie. * - * @param fileName file name or path string + *

The registry is discovered through the thread context class loader. + * Selection is exact: the method never resolves a language default, falls back + * to another model, or depends on classpath order. Use + * {@link #loadCompiled(Path, boolean, ReductionMode)} for a filesystem path.

+ * + * @param modelId exact stable model identifier * @param storeOriginal whether the stem itself should be inserted using the * canonical no-op patch command * @param reductionMode reduction mode * @return compiled patch-command trie with runtime-specialized values * @throws NullPointerException if any argument is {@code null} - * @throws IOException if the file cannot be opened or read + * @throws IllegalArgumentException if {@code modelId} is blank + * @throws IOException if registry discovery or dictionary reading fails + * @throws StemmerModelNotFoundException if the exact model is not visible + * @throws DuplicateStemmerModelException if discovery finds duplicate model IDs + * @throws UnsupportedStemmerModelFormatException if a descriptor format is unsupported + * @throws StemmerModelIntegrityException if descriptor or resource integrity validation fails */ - public static FrequencyTrie loadCompiled(final String fileName, + public static FrequencyTrie loadCompiled(final String modelId, final boolean storeOriginal, final ReductionMode reductionMode) throws IOException { - Objects.requireNonNull(fileName, FILENAME_REQUIRED); - return loadCompiled(Path.of(fileName), storeOriginal, reductionMode); + Objects.requireNonNull(modelId, "modelId"); + Objects.requireNonNull(reductionMode, "reductionMode"); + if (modelId.isBlank()) { + throw new IllegalArgumentException("modelId must not be blank"); + } + final StemmerModelDescriptor descriptor = StemmerModelRegistry.fromContextClassLoader().require(modelId); + return loadCompiled(descriptor, storeOriginal, reductionMode); } /** @@ -1125,9 +1258,9 @@ public final class StemmerPatchTrieLoader { } /** - * Resolves the traversal direction implied by a bundled language definition. + * Resolves the traversal direction implied by a language definition. * - * @param language bundled language + * @param language language definition * @return traversal direction to use for that language */ private static WordTraversalDirection traversalDirectionOf(final Language language) { diff --git a/src/main/java/org/egothor/stemmer/TrieMetadata.java b/src/main/java/org/egothor/stemmer/TrieMetadata.java index d7a752a..883613e 100644 --- a/src/main/java/org/egothor/stemmer/TrieMetadata.java +++ b/src/main/java/org/egothor/stemmer/TrieMetadata.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/UnsupportedStemmerModelFormatException.java b/src/main/java/org/egothor/stemmer/UnsupportedStemmerModelFormatException.java new file mode 100644 index 0000000..9888ed1 --- /dev/null +++ b/src/main/java/org/egothor/stemmer/UnsupportedStemmerModelFormatException.java @@ -0,0 +1,46 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +/** + * Indicates that a descriptor declares a model format name or format version not + * supported by the current Radixor core. + */ +public final class UnsupportedStemmerModelFormatException extends IllegalStateException { + private static final long serialVersionUID = 1L; + /** + * Creates an exception describing the unsupported format. + * @param message diagnostic naming the format, version, and descriptor source + */ + public UnsupportedStemmerModelFormatException(final String message) { + super(message); + } +} diff --git a/src/main/java/org/egothor/stemmer/ValueCount.java b/src/main/java/org/egothor/stemmer/ValueCount.java index 99f79e9..e96dfa0 100644 --- a/src/main/java/org/egothor/stemmer/ValueCount.java +++ b/src/main/java/org/egothor/stemmer/ValueCount.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/WordTraversalDirection.java b/src/main/java/org/egothor/stemmer/WordTraversalDirection.java index 665b5d8..4495756 100644 --- a/src/main/java/org/egothor/stemmer/WordTraversalDirection.java +++ b/src/main/java/org/egothor/stemmer/WordTraversalDirection.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/package-info.java b/src/main/java/org/egothor/stemmer/package-info.java index 0c7ce0c..90fb0ed 100644 --- a/src/main/java/org/egothor/stemmer/package-info.java +++ b/src/main/java/org/egothor/stemmer/package-info.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/ChildDescriptor.java b/src/main/java/org/egothor/stemmer/trie/ChildDescriptor.java index 70c65e0..ed8b310 100644 --- a/src/main/java/org/egothor/stemmer/trie/ChildDescriptor.java +++ b/src/main/java/org/egothor/stemmer/trie/ChildDescriptor.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/DominantLocalDescriptor.java b/src/main/java/org/egothor/stemmer/trie/DominantLocalDescriptor.java index 7eed0d6..3c58cf6 100644 --- a/src/main/java/org/egothor/stemmer/trie/DominantLocalDescriptor.java +++ b/src/main/java/org/egothor/stemmer/trie/DominantLocalDescriptor.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/LocalValueSummary.java b/src/main/java/org/egothor/stemmer/trie/LocalValueSummary.java index fd15947..1f0e5e5 100644 --- a/src/main/java/org/egothor/stemmer/trie/LocalValueSummary.java +++ b/src/main/java/org/egothor/stemmer/trie/LocalValueSummary.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/MutableNode.java b/src/main/java/org/egothor/stemmer/trie/MutableNode.java index 291b603..3e593c9 100644 --- a/src/main/java/org/egothor/stemmer/trie/MutableNode.java +++ b/src/main/java/org/egothor/stemmer/trie/MutableNode.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/NodeData.java b/src/main/java/org/egothor/stemmer/trie/NodeData.java index 03fc601..bc60dae 100644 --- a/src/main/java/org/egothor/stemmer/trie/NodeData.java +++ b/src/main/java/org/egothor/stemmer/trie/NodeData.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/RankedLocalDescriptor.java b/src/main/java/org/egothor/stemmer/trie/RankedLocalDescriptor.java index af6efec..53df22f 100644 --- a/src/main/java/org/egothor/stemmer/trie/RankedLocalDescriptor.java +++ b/src/main/java/org/egothor/stemmer/trie/RankedLocalDescriptor.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/ReducedNode.java b/src/main/java/org/egothor/stemmer/trie/ReducedNode.java index 6f40db5..a67f962 100644 --- a/src/main/java/org/egothor/stemmer/trie/ReducedNode.java +++ b/src/main/java/org/egothor/stemmer/trie/ReducedNode.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/ReductionContext.java b/src/main/java/org/egothor/stemmer/trie/ReductionContext.java index c668752..91e74fe 100644 --- a/src/main/java/org/egothor/stemmer/trie/ReductionContext.java +++ b/src/main/java/org/egothor/stemmer/trie/ReductionContext.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/ReductionSignature.java b/src/main/java/org/egothor/stemmer/trie/ReductionSignature.java index bdf6b8a..0764134 100644 --- a/src/main/java/org/egothor/stemmer/trie/ReductionSignature.java +++ b/src/main/java/org/egothor/stemmer/trie/ReductionSignature.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/SortableValue.java b/src/main/java/org/egothor/stemmer/trie/SortableValue.java index 5e5347f..398a709 100644 --- a/src/main/java/org/egothor/stemmer/trie/SortableValue.java +++ b/src/main/java/org/egothor/stemmer/trie/SortableValue.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/UnorderedLocalDescriptor.java b/src/main/java/org/egothor/stemmer/trie/UnorderedLocalDescriptor.java index f29e0c2..ffc0d2a 100644 --- a/src/main/java/org/egothor/stemmer/trie/UnorderedLocalDescriptor.java +++ b/src/main/java/org/egothor/stemmer/trie/UnorderedLocalDescriptor.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/main/java/org/egothor/stemmer/trie/package-info.java b/src/main/java/org/egothor/stemmer/trie/package-info.java index ee0c262..a93ae10 100644 --- a/src/main/java/org/egothor/stemmer/trie/package-info.java +++ b/src/main/java/org/egothor/stemmer/trie/package-info.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/CompileIntegrationTest.java b/src/test/java/org/egothor/stemmer/CompileIntegrationTest.java index 94109da..bf81e1f 100644 --- a/src/test/java/org/egothor/stemmer/CompileIntegrationTest.java +++ b/src/test/java/org/egothor/stemmer/CompileIntegrationTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -334,7 +334,7 @@ final class CompileIntegrationTest { *

* * @param scenario scenario identifier - * @param resourcePath bundled dictionary resource path + * @param resourcePath registered model dictionary resource path * @throws IOException if reading or writing fails */ @ParameterizedTest(name = "[{index}] {0}") @@ -359,7 +359,7 @@ final class CompileIntegrationTest { final Map> representativeStemsByVariant = readRepresentativeVariantExpectations( resourcePath, REPRESENTATIVE_VARIANT_LIMIT); - assertFalse(representativeStemsByVariant.isEmpty(), "The bundled dictionary must provide at least one " + assertFalse(representativeStemsByVariant.isEmpty(), "The registered model dictionary must provide at least one " + "representative variant without Unicode whitespace for " + scenario + '.'); for (Map.Entry> entry : representativeStemsByVariant.entrySet()) { @@ -451,7 +451,7 @@ final class CompileIntegrationTest { *

* *

- * The bundled dictionary format is expected to be tab-separated values, meaning + * The registered model dictionary format is expected to be tab-separated values, meaning * that columns are separated by the tab character: *

* @@ -467,7 +467,7 @@ final class CompileIntegrationTest { * helper. *

* - * @param resourcePath bundled dictionary resource path + * @param resourcePath registered model dictionary resource path * @param limit maximum number of representative variants to collect * @return representative variants mapped to their acceptable stems * @throws IOException if reading fails diff --git a/src/test/java/org/egothor/stemmer/CompileTest.java b/src/test/java/org/egothor/stemmer/CompileTest.java index 2eb6571..9743f99 100644 --- a/src/test/java/org/egothor/stemmer/CompileTest.java +++ b/src/test/java/org/egothor/stemmer/CompileTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/CompiledTrieArtifactRegressionTest.java b/src/test/java/org/egothor/stemmer/CompiledTrieArtifactRegressionTest.java index a5b6945..24e2fb5 100644 --- a/src/test/java/org/egothor/stemmer/CompiledTrieArtifactRegressionTest.java +++ b/src/test/java/org/egothor/stemmer/CompiledTrieArtifactRegressionTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/DiacriticStripperTest.java b/src/test/java/org/egothor/stemmer/DiacriticStripperTest.java index 3655244..da42b9a 100644 --- a/src/test/java/org/egothor/stemmer/DiacriticStripperTest.java +++ b/src/test/java/org/egothor/stemmer/DiacriticStripperTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/FrequencyTrieBuildersTest.java b/src/test/java/org/egothor/stemmer/FrequencyTrieBuildersTest.java index 9fec15e..56b9436 100644 --- a/src/test/java/org/egothor/stemmer/FrequencyTrieBuildersTest.java +++ b/src/test/java/org/egothor/stemmer/FrequencyTrieBuildersTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/FrequencyTrieProperties.java b/src/test/java/org/egothor/stemmer/FrequencyTrieProperties.java index 00e898c..18a7e20 100644 --- a/src/test/java/org/egothor/stemmer/FrequencyTrieProperties.java +++ b/src/test/java/org/egothor/stemmer/FrequencyTrieProperties.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/FrequencyTrieTest.java b/src/test/java/org/egothor/stemmer/FrequencyTrieTest.java index 09ea9bf..a55e5e1 100644 --- a/src/test/java/org/egothor/stemmer/FrequencyTrieTest.java +++ b/src/test/java/org/egothor/stemmer/FrequencyTrieTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/FullRuntimeModelIntegrationTest.java b/src/test/java/org/egothor/stemmer/FullRuntimeModelIntegrationTest.java new file mode 100644 index 0000000..63d183b --- /dev/null +++ b/src/test/java/org/egothor/stemmer/FullRuntimeModelIntegrationTest.java @@ -0,0 +1,137 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.util.Arrays; +import java.util.List; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** + * Constructs and exercises a complete packaged model selected by a Gradle + * property in a dedicated memory-sized test process. + */ +@Tag("large-model") +final class FullRuntimeModelIntegrationTest { + /** System property containing the exact model identifier under verification. */ + private static final String MODEL_ID_PROPERTY = "radixor.test.modelId"; + + /** Reduction mode used by the supported runtime construction path. */ + private static final ReductionMode REDUCTION_MODE = + ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS; + + /** + * Loads the entire selected resource, constructs its compiled trie, and applies + * deterministic PoliMorf smoke fixtures when that model is selected. + * + * @throws IOException if discovery or complete dictionary processing fails + */ + @Test + @DisplayName("Complete packaged model constructs a compiled runtime trie") + void constructsCompletePackagedRuntimeModel() throws IOException { + final String modelId = requiredModelId(); + final long startedAt = System.nanoTime(); + final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader(); + final StemmerModelDescriptor descriptor = registry.require(modelId); + + assertNotNull(descriptor.source()); + assertNotNull(descriptor.classLoader().getResource(descriptor.resource())); + final FrequencyTrie trie = StemmerPatchTrieLoader.loadCompiled( + modelId, true, REDUCTION_MODE); + final long elapsedNanos = System.nanoTime() - startedAt; + + assertTrue(trie.size() > 0, "The completely constructed trie must contain canonical nodes."); + if ("pl-pl-polimorf".equals(modelId)) { + verifyPolimorfFixtures(trie); + } + System.out.printf( + "RUNTIME_MODEL_METRICS model=%s maxHeapBytes=%d elapsedMillis=%d canonicalNodes=%d%n", + modelId, Runtime.getRuntime().maxMemory(), elapsedNanos / 1_000_000L, trie.size()); + } + + /** + * Returns the nonblank exact model identifier supplied by the Gradle task. + * + * @return exact model identifier + */ + private static String requiredModelId() { + final String modelId = System.getProperty(MODEL_ID_PROPERTY); + if (modelId == null || modelId.isBlank()) { + throw new IllegalStateException("System property " + MODEL_ID_PROPERTY + " must name a model."); + } + return modelId; + } + + /** + * Verifies stable forms selected from the immutable PoliMorf module input. + * The first column of each source row is the expected lemma and subsequent + * columns contain its forms. + * + * @param trie completely constructed PoliMorf trie + */ + private static void verifyPolimorfFixtures(final FrequencyTrie trie) { + assertStem(trie, "pies", "pies"); + assertStem(trie, "psami", "pies"); + assertStem(trie, "kotem", "kot"); + assertStem(trie, "zamkami", "zamek"); + + final List candidates = Arrays.stream(trie.getAll("mam")) + .map(command -> command.apply("mam")) + .toList(); + assertArrayEquals(new String[]{"mama", "mamić", "mieć"}, candidates.toArray(String[]::new)); + assertNull(trie.get("radixorbrakujacehaslo")); + assertEquals(0, trie.getAll("radixorbrakujacehaslo").length); + } + + /** + * Applies the preferred compiled patch command and compares its result with a + * reviewed source-dictionary lemma. + * + * @param trie PoliMorf trie + * @param form inflected or lemma form + * @param expectedLemma expected source-dictionary lemma + */ + private static void assertStem(final FrequencyTrie trie, final String form, + final String expectedLemma) { + final CompiledPatchCommand command = trie.get(form); + assertNotNull(command, "A reviewed PoliMorf form must have a patch command: " + form); + assertEquals(expectedLemma, command.apply(form)); + } +} diff --git a/src/test/java/org/egothor/stemmer/FuzzStemmerAndTrieCompilationTest.java b/src/test/java/org/egothor/stemmer/FuzzStemmerAndTrieCompilationTest.java index c24773c..6cd2553 100644 --- a/src/test/java/org/egothor/stemmer/FuzzStemmerAndTrieCompilationTest.java +++ b/src/test/java/org/egothor/stemmer/FuzzStemmerAndTrieCompilationTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/FuzzTestSupport.java b/src/test/java/org/egothor/stemmer/FuzzTestSupport.java index f07ef3b..91a1315 100644 --- a/src/test/java/org/egothor/stemmer/FuzzTestSupport.java +++ b/src/test/java/org/egothor/stemmer/FuzzTestSupport.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/ModelDependencyResolutionTest.java b/src/test/java/org/egothor/stemmer/ModelDependencyResolutionTest.java new file mode 100644 index 0000000..dd34339 --- /dev/null +++ b/src/test/java/org/egothor/stemmer/ModelDependencyResolutionTest.java @@ -0,0 +1,195 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import org.gradle.testkit.runner.BuildResult; +import org.gradle.testkit.runner.GradleRunner; +import org.gradle.testkit.runner.TaskOutcome; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +/** + * Verifies consumer-visible dependency resolution from the isolated local Maven repository. + */ +@Tag("integration") +@DisplayName("Published model dependency topology") +class ModelDependencyResolutionTest { + + /** The temporary directory used for isolated Gradle consumer builds. */ + @TempDir + Path temporaryDirectory; + + /** + * Verifies that the standard aggregate resolves all defaults and excludes optional PoliMorf. + * + * @throws IOException if the consumer fixture cannot be created or read + */ + @Test + @DisplayName("Standard aggregate resolves twenty defaults and excludes PoliMorf") + void standardAggregateResolvesDefaultsOnly() throws IOException { + Set artifacts = resolve(""" + implementation 'org.egothor:radixor:%s' + runtimeOnly 'org.egothor:radixor-models-standard:%s' + """.formatted(coreVersion(), catalogVersion())); + + assertTrue(artifacts.contains("radixor")); + assertTrue(artifacts.contains("radixor-model-pl-pl-unimorph")); + assertFalse(artifacts.contains("radixor-model-pl-pl-polimorf")); + assertEquals(21, artifacts.size(), "The core and twenty default model JARs must resolve."); + } + + /** + * Verifies that importing the model BOM alone introduces no model artifact. + * + * @throws IOException if the consumer fixture cannot be created or read + */ + @Test + @DisplayName("BOM alone contributes constraints but no model JAR") + void bomAloneIntroducesNoModels() throws IOException { + Set artifacts = resolve("implementation platform('org.egothor:radixor-models-bom:" + + catalogVersion() + "')"); + + assertTrue(artifacts.isEmpty(), "A dependency-management BOM must not add runtime artifacts."); + } + + /** + * Verifies that the BOM supplies the source-controlled PoliMorf model version. + * + * @throws IOException if the consumer fixture cannot be created or read + */ + @Test + @DisplayName("BOM manages an explicitly requested PoliMorf model") + void bomManagesExplicitPolimorf() throws IOException { + Set artifacts = resolve(""" + implementation platform('org.egothor:radixor-models-bom:%s') + runtimeOnly 'org.egothor:radixor-model-pl-pl-polimorf' + """.formatted(catalogVersion())); + + assertEquals(Set.of("radixor-model-pl-pl-polimorf"), artifacts); + } + + /** + * Verifies that the root core publication has no transitive model dependency. + * + * @throws IOException if the consumer fixture cannot be created or read + */ + @Test + @DisplayName("Core publication resolves without model artifacts") + void coreHasNoTransitiveModels() throws IOException { + Set artifacts = resolve("implementation 'org.egothor:radixor:" + coreVersion() + "'"); + + assertEquals(Set.of("radixor"), artifacts); + } + + /** + * Executes an isolated offline Gradle consumer build and returns resolved artifact identifiers. + * + * @param dependencyDeclarations Gradle dependency declarations for the fixture + * @return deterministically ordered resolved Maven artifact identifiers + * @throws IOException if fixture files cannot be created or read + */ + private Set resolve(final String dependencyDeclarations) throws IOException { + Path fixtureDirectory = Files.createTempDirectory(temporaryDirectory, "consumer-"); + Path repository = Path.of(requiredProperty("radixor.consumer.repository")); + Files.writeString(fixtureDirectory.resolve("settings.gradle"), "rootProject.name = 'consumer'\n", + StandardCharsets.UTF_8); + Files.writeString(fixtureDirectory.resolve("build.gradle"), """ + plugins { id 'java' } + repositories { maven { url = uri('%s') } } + dependencies { + %s + } + tasks.register('resolveRuntime') { + doLast { + def names = configurations.runtimeClasspath.resolvedConfiguration.resolvedArtifacts + .collect { it.moduleVersion.id.name }.toSorted() + file('resolved.txt').text = names.join('\\n') + (names.isEmpty() ? '' : '\\n') + } + } + """.formatted(repository.toUri(), dependencyDeclarations), StandardCharsets.UTF_8); + + BuildResult result = GradleRunner.create() + .withProjectDir(fixtureDirectory.toFile()) + .withArguments("--offline", "--stacktrace", "resolveRuntime") + .build(); + assertEquals(TaskOutcome.SUCCESS, result.task(":resolveRuntime").getOutcome()); + Path resultFile = fixtureDirectory.resolve("resolved.txt"); + List lines = Files.exists(resultFile) + ? Files.readAllLines(resultFile, StandardCharsets.UTF_8) + : List.of(); + return new TreeSet<>(lines); + } + + /** + * Returns the root core version supplied by the Gradle test task. + * + * @return current root core version + */ + private static String coreVersion() { + return requiredProperty("radixor.core.version"); + } + + /** + * Returns the model catalog version supplied by the Gradle test task. + * + * @return current model catalog version + */ + private static String catalogVersion() { + return requiredProperty("radixor.catalog.version"); + } + + /** + * Returns a required system property or fails with an actionable diagnostic. + * + * @param name system-property name + * @return nonblank property value + */ + private static String requiredProperty(final String name) { + String value = System.getProperty(name); + if (value == null || value.isBlank()) { + throw new IllegalStateException("Required test system property is missing: " + name); + } + return value; + } +} diff --git a/src/test/java/org/egothor/stemmer/PatchCommandEncoderProperties.java b/src/test/java/org/egothor/stemmer/PatchCommandEncoderProperties.java index 085b46a..80bb9a3 100644 --- a/src/test/java/org/egothor/stemmer/PatchCommandEncoderProperties.java +++ b/src/test/java/org/egothor/stemmer/PatchCommandEncoderProperties.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/PatchCommandEncoderTest.java b/src/test/java/org/egothor/stemmer/PatchCommandEncoderTest.java index 3477435..5200cac 100644 --- a/src/test/java/org/egothor/stemmer/PatchCommandEncoderTest.java +++ b/src/test/java/org/egothor/stemmer/PatchCommandEncoderTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/PropertyBasedTestSupport.java b/src/test/java/org/egothor/stemmer/PropertyBasedTestSupport.java index ef5cee1..a5cdf3f 100644 --- a/src/test/java/org/egothor/stemmer/PropertyBasedTestSupport.java +++ b/src/test/java/org/egothor/stemmer/PropertyBasedTestSupport.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/RegressionArtifactGenerator.java b/src/test/java/org/egothor/stemmer/RegressionArtifactGenerator.java index 7a5f412..19455ec 100644 --- a/src/test/java/org/egothor/stemmer/RegressionArtifactGenerator.java +++ b/src/test/java/org/egothor/stemmer/RegressionArtifactGenerator.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/RegressionArtifactSupport.java b/src/test/java/org/egothor/stemmer/RegressionArtifactSupport.java index 3ac581e..6ca2388 100644 --- a/src/test/java/org/egothor/stemmer/RegressionArtifactSupport.java +++ b/src/test/java/org/egothor/stemmer/RegressionArtifactSupport.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/StemmerDictionaryParserTest.java b/src/test/java/org/egothor/stemmer/StemmerDictionaryParserTest.java index d49748b..e227072 100644 --- a/src/test/java/org/egothor/stemmer/StemmerDictionaryParserTest.java +++ b/src/test/java/org/egothor/stemmer/StemmerDictionaryParserTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/StemmerKnowledgeExperimentTest.java b/src/test/java/org/egothor/stemmer/StemmerKnowledgeExperimentTest.java index b16b353..14a4aa5 100644 --- a/src/test/java/org/egothor/stemmer/StemmerKnowledgeExperimentTest.java +++ b/src/test/java/org/egothor/stemmer/StemmerKnowledgeExperimentTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/StemmerModelDocumentationExamplesTest.java b/src/test/java/org/egothor/stemmer/StemmerModelDocumentationExamplesTest.java new file mode 100644 index 0000000..ff9d03c --- /dev/null +++ b/src/test/java/org/egothor/stemmer/StemmerModelDocumentationExamplesTest.java @@ -0,0 +1,174 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.net.URL; +import java.net.URLClassLoader; +import java.util.List; + +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** Executes the essential model discovery and loading examples used by maintained documentation. */ +@Tag("documentation") +@Tag("integration") +final class StemmerModelDocumentationExamplesTest { + /** Registry discovered from the standard test runtime classpath. */ + private static StemmerModelRegistry registry; + + /** Discovers the documented models once for this example suite. */ + @BeforeAll + static void discoverDocumentedModels() throws IOException { + registry = StemmerModelRegistry.fromContextClassLoader(); + } + + /** Verifies that language-oriented loading retains the documented Polish default. */ + @Test + @DisplayName("Documentation example loads the default Polish UniMorph model") + void loadsDefaultPolishModel() throws IOException { + final FrequencyTrie trie = StemmerPatchTrieLoader.loadCompiled( + StemmerPatchTrieLoader.Language.PL_PL, + true, + ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS); + final CompiledPatchCommand command = trie.get("koty"); + assertNotNull(command); + assertEquals("kot", command.apply("koty")); + assertEquals("pl-pl-unimorph", + registry.requireDefault(StemmerPatchTrieLoader.Language.PL_PL).id()); + } + + /** Verifies exact PoliMorf descriptor selection and its packaged runtime metadata. */ + @Test + @DisplayName("Documentation example selects PoliMorf by exact model ID") + void selectsExplicitPolimorfModel() { + final StemmerModelDescriptor descriptor = registry.require("pl-pl-polimorf"); + assertEquals("PL_PL", descriptor.language().name()); + assertEquals("org/egothor/stemmer/models/pl-pl-polimorf/stemmer.gz", descriptor.resource()); + assertEquals("1.0.0", descriptor.version()); + } + + /** Verifies the documented explicit descriptor-to-compiled-trie API with a registered model. */ + @Test + @DisplayName("Documentation example loads an exact descriptor into a usable trie") + void loadsExplicitDescriptor() throws IOException { + final StemmerModelDescriptor descriptor = registry.require("pl-pl-unimorph"); + final FrequencyTrie trie = StemmerPatchTrieLoader.loadCompiled( + descriptor, true, + ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS); + final CompiledPatchCommand command = trie.get("koty"); + assertEquals("kot", command.apply("koty")); + } + + /** Verifies exact model-ID compiled loading without language-default fallback. */ + @Test + @DisplayName("Documentation example loads an exact model ID into a compiled trie") + void loadsExplicitModelId() throws IOException { + final FrequencyTrie trie = StemmerPatchTrieLoader.loadCompiled( + "pl-pl-unimorph", true, + ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS); + assertEquals("kot", trie.get("koty").apply("koty")); + } + + /** Verifies null, blank, and unknown exact model-ID failure behavior. */ + @Test + @DisplayName("Documentation example rejects invalid or unavailable explicit model IDs") + void rejectsInvalidExplicitModelIds() { + assertThrows(NullPointerException.class, () -> StemmerPatchTrieLoader.loadCompiled( + (String) null, true, ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS)); + assertThrows(NullPointerException.class, () -> StemmerPatchTrieLoader.loadCompiled( + (StemmerModelDescriptor) null, true, + ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS)); + assertThrows(NullPointerException.class, () -> StemmerPatchTrieLoader.loadCompiled( + registry.require("pl-pl-unimorph"), true, (ReductionMode) null)); + assertThrows(IllegalArgumentException.class, () -> StemmerPatchTrieLoader.loadCompiled( + " ", true, ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS)); + assertThrows(StemmerModelNotFoundException.class, () -> StemmerPatchTrieLoader.loadCompiled( + "pl-pl-does-not-exist", true, + ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS)); + } + + /** Verifies that two models coexist without changing default resolution. */ + @Test + @DisplayName("Documentation example keeps both Polish models independent") + void loadsBothPolishModelsIndependently() { + final StemmerModelDescriptor unimorph = registry.require("pl-pl-unimorph"); + final StemmerModelDescriptor polimorf = registry.require("pl-pl-polimorf"); + final StemmerModelDescriptor defaultModel = registry.requireDefault(StemmerPatchTrieLoader.Language.PL_PL); + assertEquals("pl-pl-unimorph", defaultModel.id()); + assertEquals(StemmerPatchTrieLoader.Language.PL_PL, unimorph.language()); + assertEquals(StemmerPatchTrieLoader.Language.PL_PL, polimorf.language()); + assertFalse(unimorph.id().equals(polimorf.id())); + } + + /** Verifies deterministic discovery and language filtering shown in documentation. */ + @Test + @DisplayName("Documentation example lists and filters models deterministically") + void discoversAndFiltersModels() { + final List polish = registry.findByLanguage(StemmerPatchTrieLoader.Language.PL_PL); + assertEquals(List.of("pl-pl-polimorf", "pl-pl-unimorph"), + polish.stream().map(StemmerModelDescriptor::id).toList()); + assertEquals(registry.models().stream().sorted().toList(), registry.models()); + assertTrue(polish.stream().allMatch(model -> model.format().equals("radixor-dictionary-tsv-gzip"))); + } + + /** Verifies discovery through an explicitly supplied application class loader. */ + @Test + @DisplayName("Documentation example discovers models through an explicit ClassLoader") + void discoversThroughExplicitClassLoader() throws IOException { + final ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + final StemmerModelRegistry explicitRegistry = StemmerModelRegistry.fromClassLoader(classLoader); + assertEquals("pl-pl-polimorf", explicitRegistry.require("pl-pl-polimorf").id()); + assertEquals(registry.models().stream().map(StemmerModelDescriptor::id).toList(), + explicitRegistry.models().stream().map(StemmerModelDescriptor::id).toList()); + } + + /** Verifies the exact missing-model failure produced by an isolated empty loader. */ + @Test + @DisplayName("Documentation example reports a model missing from an isolated ClassLoader") + void reportsMissingModelFromIsolatedClassLoader() throws IOException { + try (URLClassLoader isolated = new URLClassLoader(new URL[0], null)) { + final StemmerModelRegistry emptyRegistry = StemmerModelRegistry.fromClassLoader(isolated); + final StemmerModelNotFoundException exception = assertThrows(StemmerModelNotFoundException.class, + () -> emptyRegistry.require("pl-pl-polimorf")); + assertTrue(exception.getMessage().contains( + "org.egothor:radixor-model-pl-pl-polimorf:")); + } + } +} diff --git a/src/test/java/org/egothor/stemmer/StemmerModelRegistryTest.java b/src/test/java/org/egothor/stemmer/StemmerModelRegistryTest.java new file mode 100644 index 0000000..5d10192 --- /dev/null +++ b/src/test/java/org/egothor/stemmer/StemmerModelRegistryTest.java @@ -0,0 +1,82 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ +package org.egothor.stemmer; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.IOException; +import java.util.List; + +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +/** Tests deterministic model discovery and language/model separation. */ +@Tag("integration") +final class StemmerModelRegistryTest { + /** Verifies discovery, ordering, coexistence, and the Polish default. */ + @Test + @DisplayName("Registry discovers all models deterministically and keeps UniMorph as Polish default") + void discoversModelsDeterministically() throws IOException { + final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader(); + final List polish = registry.findByLanguage(StemmerPatchTrieLoader.Language.PL_PL); + assertEquals(List.of("pl-pl-polimorf", "pl-pl-unimorph"), + polish.stream().map(StemmerModelDescriptor::id).toList()); + assertEquals("pl-pl-unimorph", registry.requireDefault(StemmerPatchTrieLoader.Language.PL_PL).id()); + assertEquals("pl-pl-polimorf", registry.require("pl-pl-polimorf").id()); + assertEquals(registry.models().stream().sorted().toList(), registry.models()); + } + + /** Verifies that missing explicit models never fall back arbitrarily. */ + @Test + @DisplayName("Missing explicit model reports its exact dependency") + void rejectsMissingModel() throws IOException { + final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader(); + final StemmerModelNotFoundException exception = assertThrows(StemmerModelNotFoundException.class, + () -> registry.require("pl-pl-unknown")); + assertTrue(exception.getMessage().contains("org.egothor:radixor-model-pl-pl-unknown:")); + assertFalse(exception.getMessage().isBlank()); + } + + /** Verifies the source-compatible language loader resolves the registered default. */ + @Test + @Tag("slow") + @DisplayName("Polish language loading resolves the UniMorph model") + void loadsDefaultPolishModel() throws IOException { + final FrequencyTrie trie = StemmerPatchTrieLoader.loadCompiled( + StemmerPatchTrieLoader.Language.PL_PL, true, + ReductionSettings.withDefaults(ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_RANKED_GET_ALL_RESULTS)); + assertTrue(trie.metadata() != null); + } +} diff --git a/src/test/java/org/egothor/stemmer/StemmerPatchTrieBinaryIOTest.java b/src/test/java/org/egothor/stemmer/StemmerPatchTrieBinaryIOTest.java index 1abcc4c..37b8e80 100644 --- a/src/test/java/org/egothor/stemmer/StemmerPatchTrieBinaryIOTest.java +++ b/src/test/java/org/egothor/stemmer/StemmerPatchTrieBinaryIOTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/StemmerPatchTrieLoaderTest.java b/src/test/java/org/egothor/stemmer/StemmerPatchTrieLoaderTest.java index 9e8b293..b3a3e9a 100644 --- a/src/test/java/org/egothor/stemmer/StemmerPatchTrieLoaderTest.java +++ b/src/test/java/org/egothor/stemmer/StemmerPatchTrieLoaderTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -73,7 +73,7 @@ import org.junit.jupiter.params.provider.MethodSource; * *

* The suite combines focused API-level verification with integration validation - * against bundled dictionaries. It verifies: + * against registered default-model dictionaries. It verifies: *

*
    *
  • all public loading overloads
  • @@ -113,7 +113,7 @@ final class StemmerPatchTrieLoaderTest { private static final int REPRESENTATIVE_BUNDLED_WORD_COUNT = 25; /** - * Provides arguments for bundled dictionary verification across both supported + * Provides arguments for registered model dictionary verification across both supported * getAll-preserving reduction modes. * *

    @@ -521,13 +521,10 @@ final class StemmerPatchTrieLoaderTest { dictionaryFile, true, DEFAULT_REDUCTION_MODE); final FrequencyTrie fromStringWithSettings = StemmerPatchTrieLoader.loadCompiled( dictionaryFile.toString(), true, settings); - final FrequencyTrie fromStringWithMode = StemmerPatchTrieLoader.loadCompiled( - dictionaryFile.toString(), true, DEFAULT_REDUCTION_MODE); assertCompiledTrieSemanticsEqual(expected, fromPathWithSettings, "running", "played", "cities", "run"); assertCompiledTrieSemanticsEqual(expected, fromPathWithMode, "running", "played", "cities", "run"); assertCompiledTrieSemanticsEqual(expected, fromStringWithSettings, "running", "played", "cities", "run"); - assertCompiledTrieSemanticsEqual(expected, fromStringWithMode, "running", "played", "cities", "run"); } /** @@ -821,14 +818,14 @@ final class StemmerPatchTrieLoaderTest { } /** - * Verifies that each bundled dictionary compiles into a trie whose + * Verifies that each registered default-model dictionary compiles into a trie whose * {@link FrequencyTrie#getAll(String)} results still reconstruct exactly the * same set of stems as the source dictionary. * * @param scenario human-readable numbered scenario identifier * @param language tested bundled language * @param reductionMode reduction mode - * @throws IOException if a bundled dictionary cannot be read + * @throws IOException if a registered model dictionary cannot be read */ @ParameterizedTest(name = "[{index}] {0}") @MethodSource("org.egothor.stemmer.StemmerPatchTrieLoaderTest#bundledDictionaryCases") @@ -861,7 +858,7 @@ final class StemmerPatchTrieLoaderTest { } /** - * Verifies that representative bundled dictionaries load equivalently through + * Verifies that representative registered model dictionaries load equivalently through * both reduction-setting and reduction-mode overloads. * * @param scenario scenario identifier @@ -890,12 +887,12 @@ final class StemmerPatchTrieLoaderTest { } assertFalse(expectedStemsByWord.isEmpty(), - "Scenario " + scenario + " must provide at least one bundled dictionary entry."); + "Scenario " + scenario + " must provide at least one registered model dictionary entry."); } } /** - * Reads the bundled dictionary and builds a mapping of surface word to all + * Reads the registered model dictionary and builds a mapping of surface word to all * stems it is associated with in the source data. * *

    @@ -1034,7 +1031,7 @@ final class StemmerPatchTrieLoaderTest { } /** - * Opens one bundled dictionary resource. + * Opens one registered model dictionary resource. * * @param resourcePath classpath resource path * @return opened input stream diff --git a/src/test/java/org/egothor/stemmer/StemmerPatchTrieProperties.java b/src/test/java/org/egothor/stemmer/StemmerPatchTrieProperties.java index 1b26525..27df96e 100644 --- a/src/test/java/org/egothor/stemmer/StemmerPatchTrieProperties.java +++ b/src/test/java/org/egothor/stemmer/StemmerPatchTrieProperties.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -85,13 +85,15 @@ class StemmerPatchTrieProperties extends PropertyBasedTestSupport { assertTrue(acceptableStems.contains(PatchCommandEncoder.apply(observedWord, preferredPatch, trie.traversalDirection())), "preferred patch reconstructed an unexpected stem."); - final Set producedStems = applyAll(trie, observedWord, allPatches); - assertTrue(acceptableStems.containsAll(producedStems), - "getAll() must not expose a patch that reconstructs an undeclared stem."); + if (reductionMode != ReductionMode.MERGE_SUBTREES_WITH_EQUIVALENT_DOMINANT_GET_RESULTS) { + final Set producedStems = applyAll(trie, observedWord, allPatches); + assertTrue(acceptableStems.containsAll(producedStems), + "A getAll()-preserving mode must not reconstruct an undeclared stem."); - if (acceptableStems.contains(observedWord)) { - assertTrue(producedStems.contains(observedWord), - "storeOriginal semantics must preserve the original stem among returned results."); + if (acceptableStems.contains(observedWord)) { + assertTrue(producedStems.contains(observedWord), + "A getAll()-preserving mode must retain the stored original result."); + } } } } diff --git a/src/test/java/org/egothor/stemmer/TrieMetadataTest.java b/src/test/java/org/egothor/stemmer/TrieMetadataTest.java index a33dcaf..e5b3d34 100644 --- a/src/test/java/org/egothor/stemmer/TrieMetadataTest.java +++ b/src/test/java/org/egothor/stemmer/TrieMetadataTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/WordTraversalDirectionTest.java b/src/test/java/org/egothor/stemmer/WordTraversalDirectionTest.java index 40ee79e..7fd5a2a 100644 --- a/src/test/java/org/egothor/stemmer/WordTraversalDirectionTest.java +++ b/src/test/java/org/egothor/stemmer/WordTraversalDirectionTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/benchmark/BenchmarkTokenSequenceTest.java b/src/test/java/org/egothor/stemmer/benchmark/BenchmarkTokenSequenceTest.java index 9986c8c..46d85ef 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/BenchmarkTokenSequenceTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/BenchmarkTokenSequenceTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonTokenStreamTest.java b/src/test/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonTokenStreamTest.java index e9a5c5a..a3946f8 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonTokenStreamTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/EnglishStemmerComparisonTokenStreamTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/benchmark/PaiceHuskLancasterStemmerTest.java b/src/test/java/org/egothor/stemmer/benchmark/PaiceHuskLancasterStemmerTest.java index 63cff84..9b17aaf 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/PaiceHuskLancasterStemmerTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/PaiceHuskLancasterStemmerTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/BundledGoldStandardLoader.java b/src/test/java/org/egothor/stemmer/benchmark/quality/BundledGoldStandardLoader.java index 4d29bca..753b9c0 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/BundledGoldStandardLoader.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/BundledGoldStandardLoader.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.BufferedReader; @@ -15,7 +45,7 @@ import org.egothor.stemmer.CaseProcessingMode; import org.egothor.stemmer.StemmerDictionaryParser; import org.egothor.stemmer.StemmerPatchTrieLoader.Language; -/** Loads gold-standard groups from authoritative bundled dictionary resources. */ +/** Loads gold-standard groups from authoritative registered model resources. */ public final class BundledGoldStandardLoader { /** Utility class. */ private BundledGoldStandardLoader() { throw new AssertionError("No instances."); } @@ -28,7 +58,8 @@ public final class BundledGoldStandardLoader { */ public static List load(final Language language) throws IOException { Objects.requireNonNull(language, "language"); - final String resource = language.resourcePath(); + final String resource = org.egothor.stemmer.StemmerModelRegistry.fromContextClassLoader() + .requireDefault(language).resource(); final List groups = new ArrayList<>(); try (InputStream raw = openResource(language, resource); InputStream gzip = new GZIPInputStream(raw); BufferedReader reader = new BufferedReader(new InputStreamReader(gzip, StandardCharsets.UTF_8))) { diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateAwareEvaluator.java b/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateAwareEvaluator.java index 0a3a396..24b5a6b 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateAwareEvaluator.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateAwareEvaluator.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateAwareEvaluatorTest.java b/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateAwareEvaluatorTest.java index 179d9a3..a2d91ad 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateAwareEvaluatorTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateAwareEvaluatorTest.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateQualityAudit.java b/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateQualityAudit.java index 30765fa..2d825b1 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateQualityAudit.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/CandidateQualityAudit.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/GoldStandardGroup.java b/src/test/java/org/egothor/stemmer/benchmark/quality/GoldStandardGroup.java index 87b51e4..d2f2eb8 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/GoldStandardGroup.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/GoldStandardGroup.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.util.LinkedHashSet; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/LanguageUniverse.java b/src/test/java/org/egothor/stemmer/benchmark/quality/LanguageUniverse.java index 2788d63..6b680a7 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/LanguageUniverse.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/LanguageUniverse.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; @@ -13,7 +43,7 @@ import java.util.TreeSet; import org.egothor.stemmer.StemmerPatchTrieLoader.Language; -/** Reconciles bundled dictionary resources with every production language enumeration value. */ +/** Reconciles registered model resources with every production language enumeration value. */ record LanguageUniverse(Map dictionaries, List resourceDirectories, List enumerationValues) { /** Discovers and validates a one-to-one resource mapping without silent exclusions. */ diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/LanguageUniverseTest.java b/src/test/java/org/egothor/stemmer/benchmark/quality/LanguageUniverseTest.java index 5cabd48..0eccffd 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/LanguageUniverseTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/LanguageUniverseTest.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -9,6 +39,7 @@ import java.nio.file.Files; import java.nio.file.Path; import org.egothor.stemmer.StemmerPatchTrieLoader.Language; +import org.egothor.stemmer.StemmerModelRegistry; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -20,13 +51,14 @@ import org.junit.jupiter.api.io.TempDir; final class LanguageUniverseTest { /** Temporary resource tree. */ @TempDir Path temporaryDirectory; - /** Verifies every production enumeration value has exactly one bundled dictionary. */ + /** Verifies every production language has exactly one registered default model. */ @Test @DisplayName("Production resources reconcile with every language enumeration value") void productionResourcesReconcile() throws IOException { - final LanguageUniverse universe = LanguageUniverse.discover(Path.of("src/main/resources")); - assertEquals(Language.values().length, universe.dictionaries().size()); - assertTrue(universe.dictionaries().containsKey(Language.DA_DK)); - assertTrue(universe.dictionaries().containsKey(Language.YI)); + final StemmerModelRegistry registry = StemmerModelRegistry.fromContextClassLoader(); + assertEquals(Language.values().length, + java.util.Arrays.stream(Language.values()).map(registry::requireDefault).count()); + assertEquals("da-dk-default", registry.requireDefault(Language.DA_DK).id()); + assertEquals("yi-default", registry.requireDefault(Language.YI).id()); } /** Verifies a missing enumerated resource produces an exact diagnostic. */ diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/MetricCorrelationWriter.java b/src/test/java/org/egothor/stemmer/benchmark/quality/MetricCorrelationWriter.java index b40e631..2ca0952 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/MetricCorrelationWriter.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/MetricCorrelationWriter.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/OutputPolicy.java b/src/test/java/org/egothor/stemmer/benchmark/quality/OutputPolicy.java index 3ea2a42..7d92f9a 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/OutputPolicy.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/OutputPolicy.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; /** Defines which outputs of a JMH stemmer adapter establish the measured relation. */ diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/PairwiseMetrics.java b/src/test/java/org/egothor/stemmer/benchmark/quality/PairwiseMetrics.java index 897773e..32dcda4 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/PairwiseMetrics.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/PairwiseMetrics.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.util.OptionalDouble; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/PairwiseMetricsTest.java b/src/test/java/org/egothor/stemmer/benchmark/quality/PairwiseMetricsTest.java index 677dda4..f635e53 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/PairwiseMetricsTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/PairwiseMetricsTest.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/PartitionMetrics.java b/src/test/java/org/egothor/stemmer/benchmark/quality/PartitionMetrics.java index 0843025..d2f3274 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/PartitionMetrics.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/PartitionMetrics.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; /** diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/ProcessingMode.java b/src/test/java/org/egothor/stemmer/benchmark/quality/ProcessingMode.java index 5102e46..a84dc88 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/ProcessingMode.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/ProcessingMode.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; /** Selects the gold-standard groups included in a stemming-quality scenario. */ diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityAudit.java b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityAudit.java index a1bbb23..b5ed1f0 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityAudit.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityAudit.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; @@ -80,7 +110,9 @@ final class QualityAudit { sizes.sort(Integer::compareTo); final double mean = sizes.stream().mapToInt(Integer::intValue).average().orElse(0.0); final double median = median(sizes); - return new Scenario(result, candidate.language().resourcePath(), exactMatches, forms.size(), + final String resource = org.egothor.stemmer.StemmerModelRegistry.fromContextClassLoader() + .requireDefault(candidate.language()).resource(); + return new Scenario(result, resource, exactMatches, forms.size(), sizes.isEmpty() ? 0 : sizes.get(0), sizes.isEmpty() ? 0 : sizes.get(sizes.size() - 1), mean, median, List.copyOf(contributors.subList(0, Math.min(limit, contributors.size()))), contributionSum); } diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityEvaluator.java b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityEvaluator.java index 293ef4a..3a51108 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityEvaluator.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityEvaluator.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityEvaluatorTest.java b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityEvaluatorTest.java index 38843e3..74e4ca7 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityEvaluatorTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityEvaluatorTest.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityReportWriter.java b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityReportWriter.java index a685afb..9632f04 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityReportWriter.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityReportWriter.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityReportWriterTest.java b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityReportWriterTest.java index e9b3de9..6267a8f 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityReportWriterTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityReportWriterTest.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityResult.java b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityResult.java index 23e7d1e..f5900a1 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityResult.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityResult.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.util.Comparator; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityStemmerMatrixTest.java b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityStemmerMatrixTest.java index 91bf494..88baa51 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/QualityStemmerMatrixTest.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/QualityStemmerMatrixTest.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/StemmerFunction.java b/src/test/java/org/egothor/stemmer/benchmark/quality/StemmerFunction.java index 33df8f1..bcd40c7 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/StemmerFunction.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/StemmerFunction.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/StemmingQualityApplication.java b/src/test/java/org/egothor/stemmer/benchmark/quality/StemmingQualityApplication.java index b6c9944..9031308 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/StemmingQualityApplication.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/StemmingQualityApplication.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; diff --git a/src/test/java/org/egothor/stemmer/benchmark/quality/StemmingQualityDocumentationPublisher.java b/src/test/java/org/egothor/stemmer/benchmark/quality/StemmingQualityDocumentationPublisher.java index fed8bb7..f0179f9 100644 --- a/src/test/java/org/egothor/stemmer/benchmark/quality/StemmingQualityDocumentationPublisher.java +++ b/src/test/java/org/egothor/stemmer/benchmark/quality/StemmingQualityDocumentationPublisher.java @@ -1,3 +1,33 @@ +/******************************************************************************* + * Copyright (C) 2026, Leo Galambos + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. Neither the name of the copyright holder nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ******************************************************************************/ package org.egothor.stemmer.benchmark.quality; import java.io.IOException; diff --git a/src/test/java/org/egothor/stemmer/trie/ChildDescriptorTest.java b/src/test/java/org/egothor/stemmer/trie/ChildDescriptorTest.java index 7d58d44..136b84d 100644 --- a/src/test/java/org/egothor/stemmer/trie/ChildDescriptorTest.java +++ b/src/test/java/org/egothor/stemmer/trie/ChildDescriptorTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/CompiledNodeAndNodeDataTest.java b/src/test/java/org/egothor/stemmer/trie/CompiledNodeAndNodeDataTest.java index bac0a5f..fe24120 100644 --- a/src/test/java/org/egothor/stemmer/trie/CompiledNodeAndNodeDataTest.java +++ b/src/test/java/org/egothor/stemmer/trie/CompiledNodeAndNodeDataTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/DominantLocalDescriptorTest.java b/src/test/java/org/egothor/stemmer/trie/DominantLocalDescriptorTest.java index f1b2e98..3fdecc2 100644 --- a/src/test/java/org/egothor/stemmer/trie/DominantLocalDescriptorTest.java +++ b/src/test/java/org/egothor/stemmer/trie/DominantLocalDescriptorTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/LocalValueSummaryTest.java b/src/test/java/org/egothor/stemmer/trie/LocalValueSummaryTest.java index a665513..6125789 100644 --- a/src/test/java/org/egothor/stemmer/trie/LocalValueSummaryTest.java +++ b/src/test/java/org/egothor/stemmer/trie/LocalValueSummaryTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/MutableNodeTest.java b/src/test/java/org/egothor/stemmer/trie/MutableNodeTest.java index 828e204..3a8cd49 100644 --- a/src/test/java/org/egothor/stemmer/trie/MutableNodeTest.java +++ b/src/test/java/org/egothor/stemmer/trie/MutableNodeTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/RankedLocalDescriptorTest.java b/src/test/java/org/egothor/stemmer/trie/RankedLocalDescriptorTest.java index fcba293..038792d 100644 --- a/src/test/java/org/egothor/stemmer/trie/RankedLocalDescriptorTest.java +++ b/src/test/java/org/egothor/stemmer/trie/RankedLocalDescriptorTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/ReducedNodeTest.java b/src/test/java/org/egothor/stemmer/trie/ReducedNodeTest.java index 34d5221..355f825 100644 --- a/src/test/java/org/egothor/stemmer/trie/ReducedNodeTest.java +++ b/src/test/java/org/egothor/stemmer/trie/ReducedNodeTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/ReductionContextTest.java b/src/test/java/org/egothor/stemmer/trie/ReductionContextTest.java index 09808b2..e942cba 100644 --- a/src/test/java/org/egothor/stemmer/trie/ReductionContextTest.java +++ b/src/test/java/org/egothor/stemmer/trie/ReductionContextTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/ReductionSignatureTest.java b/src/test/java/org/egothor/stemmer/trie/ReductionSignatureTest.java index dfdf3c5..9fdd9e4 100644 --- a/src/test/java/org/egothor/stemmer/trie/ReductionSignatureTest.java +++ b/src/test/java/org/egothor/stemmer/trie/ReductionSignatureTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/src/test/java/org/egothor/stemmer/trie/UnorderedLocalDescriptorTest.java b/src/test/java/org/egothor/stemmer/trie/UnorderedLocalDescriptorTest.java index c940b90..5b6133a 100644 --- a/src/test/java/org/egothor/stemmer/trie/UnorderedLocalDescriptorTest.java +++ b/src/test/java/org/egothor/stemmer/trie/UnorderedLocalDescriptorTest.java @@ -1,21 +1,21 @@ /******************************************************************************* * Copyright (C) 2026, Leo Galambos * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. - * + * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * 3. Neither the name of the copyright holder nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE diff --git a/tools/parse-model-release-tag.sh b/tools/parse-model-release-tag.sh new file mode 100755 index 0000000..7c56dbe --- /dev/null +++ b/tools/parse-model-release-tag.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -euo pipefail + +tag="${1:-}" +repository_root="${2:-.}" + +if [[ "${tag}" =~ ^model/([a-z]{2}(-[a-z]{2})?-[a-z0-9]+(-[a-z0-9]+)*)@([0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?)$ ]]; then + model_id="${BASH_REMATCH[1]}" + model_version="${BASH_REMATCH[4]}" + module="${repository_root}/models/${model_id}" + [[ -d "${module}" ]] || { echo "Unknown model module: models/${model_id}" >&2; exit 2; } + [[ -f "${module}/model-version.txt" ]] || { echo "Missing model version: models/${model_id}/model-version.txt" >&2; exit 2; } + recorded_version="$(tr -d '[:space:]' < "${module}/model-version.txt")" + [[ "${recorded_version}" == "${model_version}" ]] || { + echo "Tag version ${model_version} does not match models/${model_id}/model-version.txt: ${recorded_version}" >&2 + exit 2 + } + grep -Eq "^[[:space:]]*modelId[[:space:]]*=[[:space:]]*'${model_id}'" "${module}/build.gradle" || { + echo "Descriptor model ID does not match module ${model_id}." >&2 + exit 2 + } + printf 'MODEL_ID=%s\nMODEL_VERSION=%s\nGRADLE_PROJECT=:models:%s\n' "${model_id}" "${model_version}" "${model_id}" +elif [[ "${tag}" =~ ^release@([0-9]+\.[0-9]+\.[0-9]+([+-][0-9A-Za-z.-]+)?)$ ]]; then + printf 'CORE_VERSION=%s\n' "${BASH_REMATCH[1]}" +elif [[ "${tag}" =~ ^models-catalog@([0-9]{4}\.[0-9]+)$ ]]; then + catalog_version="$(tr -d '[:space:]' < "${repository_root}/models/catalog-version.txt")" + [[ "${catalog_version}" == "${BASH_REMATCH[1]}" ]] || { + echo "Tag version ${BASH_REMATCH[1]} does not match models/catalog-version.txt: ${catalog_version}" >&2 + exit 2 + } + printf 'CATALOG_VERSION=%s\n' "${BASH_REMATCH[1]}" +else + echo "Invalid release tag: ${tag}" >&2 + exit 2 +fi diff --git a/tools/publish-central-bundle.sh b/tools/publish-central-bundle.sh new file mode 100755 index 0000000..2b039ac --- /dev/null +++ b/tools/publish-central-bundle.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -euo pipefail + +bundle="${1:?Usage: publish-central-bundle.sh BUNDLE COORDINATES}" +coordinates="${2:?Usage: publish-central-bundle.sh BUNDLE COORDINATES}" + +[[ "${GITHUB_REF_TYPE:-}" == "tag" ]] || { echo "Maven Central publication requires a release tag." >&2; exit 2; } +[[ -f "${bundle}" ]] || { echo "Central bundle does not exist: ${bundle}" >&2; exit 2; } +[[ -n "${CENTRAL_BEARER_TOKEN:-}" ]] || { echo "CENTRAL_BEARER_TOKEN is required." >&2; exit 2; } + +header_file="$(mktemp)" +trap 'rm -f "${header_file}"' EXIT +printf 'Authorization: Bearer %s\n' "${CENTRAL_BEARER_TOKEN}" > "${header_file}" +curl --fail --silent --show-error --request POST --header @"${header_file}" \ + --form "bundle=@${bundle}" --form "name=${coordinates}" \ + "https://central.sonatype.com/api/v1/publisher/upload?publishingType=AUTOMATIC"