Skip to content

TIKA-4662#2623

Draft
tballison wants to merge 8 commits intomainfrom
TIKA-4662
Draft

TIKA-4662#2623
tballison wants to merge 8 commits intomainfrom
TIKA-4662

Conversation

@tballison
Copy link
Contributor

Thanks for your contribution to Apache Tika! Your help is appreciated!

Before opening the pull request, please verify that

  • there is an open issue on the Tika issue tracker which describes the problem or the improvement. We cannot accept pull requests without an issue because the change wouldn't be listed in the release notes.
  • the issue ID (TIKA-XXXX)
    • is referenced in the title of the pull request
    • and placed in front of your commit messages surrounded by square brackets ([TIKA-XXXX] Issue or pull request title)
  • commits are squashed into a single one (or few commits for larger changes)
  • Tika is successfully built and unit tests pass by running ./mvnw clean test
  • there should be no conflicts when merging the pull request branch into the recent main branch. If there are conflicts, please try to rebase the pull request branch on top of a freshly pulled main branch
  • if you add new module that downstream users will depend upon add it to relevant group in tika-bom/pom.xml.

We will be able to faster integrate your pull request if these conditions are met. If you have any questions how to fix your problem or about using Tika in general, please sign up for the Tika mailing list. Thanks!

tballison and others added 8 commits February 17, 2026 14:14
Co-authored-by: Cursor <cursoragent@cursor.com>
…or training pipeline

- Move core ML classes from tika-langdetect-charsoup-core to new tika-ml/tika-ml-core module:
  rename CharSoupModel → LinearModel, FeatureExtractor → TextFeatureExtractor,
  add generic FeatureExtractor<T> interface and Prediction class
- Add tika-ml/tika-ml-chardetect scaffold: ByteNgramFeatureExtractor,
  MlEncodingDetector, CharsetConfusables, TrainCharsetModel
- ScriptAwareFeatureExtractor: add skip-bigram support (non-CJK only),
  configurable trigrams; use distinct FNV salt for skip-bigrams
- CorpusReader: filter tilde-redacted web-crawl noise (~~~), split
  literal \n paragraph separators so each segment trains independently
  (fixes dv Dhivehi headline-prefix contamination: 32.9% → 95.5% @20 chars)
- TrainLanguageModel: add --skip-bigrams, --max-train, --eval-only flags;
  multi-length evaluation (@20/50/100/200/full chars); per-language accuracy
  breakdown; confusion matrix for worst languages; macro-F1 reporting;
  lenient scoring via LanguageConfusables
- Add LanguageConfusables: symmetric confusable groups for lenient eval,
  buildGroupIndices/collapseGroups utilities extracted from CharSoupLanguageDetector
- Add download_madlad.py and build_charset_training.py training data scripts
- Add run-lang-train.sh helper script

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Consolidates all encoding detection into a dedicated module hierarchy:

  tika-charset-detectors (parent)
  ├── tika-charset-detectors-core    — BOM, HTML (WHATWG spec), ML detector;
  │                                    no heavy external deps beyond commons-io
  ├── tika-charset-detectors-icu4j   — wraps ICU4J (optional)
  ├── tika-charset-detectors-universal — wraps juniversalchardet fork (optional)
  └── tika-charset-detectors-tools   — TrainCharsetModel, EvalCharsetDetectors,
                                       DiagnoseCharsetDetector, BenchmarkCharsetDetectors,
                                       and the Python data-prep scripts

Default detection chain (SPI): BOM → StandardHtmlEncodingDetector → MlEncodingDetector.
CharSoupEncodingDetector (MetaEncodingDetector, tika-langdetect-charsoup) arbitrates
when present on the classpath.

Moved out of tika-parser-html-module: HtmlEncodingDetector, StandardHtmlEncodingDetector
  and all charsetdetector helpers → org.apache.tika.detect.html
Moved out of tika-parser-text-module: Icu4jEncodingDetector, UniversalEncodingDetector,
  UniversalEncodingListener → org.apache.tika.detect.encoding

Security fixes in StandardHtmlEncodingDetector pipeline:
  - CharsetAliases: replaced synchronized lazy-init with static initializer
  - PreScanner.getAttributeValue: explicit EOF handling for unclosed quoted values
  - PreScanner.skipAll: documented mark(1) pattern and its invariants

New detectors: BomEncodingDetector, HttpHeaderEncodingDetector.

Added docs/modules/ROOT/pages/configuration/encoding-detectors.adoc.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant