Skip to content

Commit ee17d88

Browse files
committed
TIKA-4720: merge and clean
1 parent 40a7536 commit ee17d88

26 files changed

Lines changed: 1568 additions & 657 deletions

File tree

docs/modules/ROOT/nav.adoc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
* xref:advanced/index.adoc[Advanced]
4848
** xref:advanced/charset-detection-design.adoc[Charset Detection Pipeline]
4949
** xref:advanced/language-detection.adoc[Language Detection]
50-
** xref:advanced/generative-language-model.adoc[Generative Language Model]
5150
** xref:advanced/language-detection-build.adoc[Building the Language Detector]
5251
** xref:advanced/junk-detection.adoc[Text Quality Scoring (Junk Detection)]
5352
** xref:advanced/junk-detection-build.adoc[Building the Junk Detector]

docs/modules/ROOT/pages/advanced/charset-detection-design.adoc

Lines changed: 86 additions & 161 deletions
Large diffs are not rendered by default.

docs/modules/ROOT/pages/advanced/generative-language-model.adoc

Lines changed: 0 additions & 240 deletions
This file was deleted.

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

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,16 @@ is found (fast lenient regex matcher, curated WHATWG label aliases).
5454
Emits DECLARATIVE.
5555

5656
|5
57-
|`charsoup-encoding-detector`
58-
|`MetaEncodingDetector` — arbitrates across all base-detector candidates
59-
using a character-bigram language model. When one or more base detectors
60-
return a result, CharSoup decodes the probe with each candidate charset
61-
and picks the one whose decoded text scores best for any supported
62-
language. Always runs last.
57+
|`junk-filter-encoding-detector`
58+
|`MetaEncodingDetector` — strips HTML/XML markup, decodes the probe under
59+
each candidate charset, and picks the cleanest decoding via a script-aware
60+
text-quality model. Honours a declaration when its decoding is
61+
byte-identical to at least one other candidate's. Always runs last.
6362
|===
6463

65-
NOTE: `charsoup-encoding-detector` is supplied by
66-
`tika-encoding-detector-charsoup` and loads automatically via SPI when
67-
the module jar is present. Omit it to get strict first-match-wins
68-
behaviour that honours declarations authoritatively — see
69-
<<opting-out-of-charsoup>>.
64+
NOTE: `junk-filter-encoding-detector` is supplied by `tika-ml-junkdetect`
65+
and SPI-loads when the module jar is on the classpath. Omit it for plain
66+
first-match-wins — see <<opting-out-of-arbitration>>.
7067

7168
== Available Detectors
7269

@@ -106,15 +103,10 @@ curated subset of WHATWG label aliases. In the default chain.
106103
explicitly if you need strict WHATWG tokenisation (e.g. ignoring charset
107104
declarations inside comments or other contexts the lenient regex may match).
108105

109-
|`charsoup-encoding-detector`
110-
|`tika-encoding-detector-charsoup`
111-
|Language-aware arbitrator (`MetaEncodingDetector`). In the default
112-
chain when the module jar is on the classpath; always runs last.
113-
114-
|`mojibuster-encoding-detector`
115-
|`tika-encoding-detector-mojibuster`
116-
|Legacy maxent charset classifier. Still available for explicit opt-in;
117-
not auto-registered.
106+
|`junk-filter-encoding-detector`
107+
|`tika-ml-junkdetect`
108+
|Text-quality arbitrator (`MetaEncodingDetector`). In the default chain
109+
when the module jar is on the classpath; always runs last.
118110

119111
|`icu4j-encoding-detector`
120112
|`tika-encoding-detector-icu4j`
@@ -144,13 +136,11 @@ auto-registered; opt in if you specifically need it.
144136
}
145137
----
146138

147-
[[opting-out-of-charsoup]]
148-
=== Strict declared-charset honoring (no CharSoup arbitration)
139+
[[opting-out-of-arbitration]]
140+
=== Strict first-match-wins (no JunkFilter arbitration)
149141

150-
By default, CharSoup arbitrates across all candidates including DECLARATIVE
151-
ones — which means a `<meta charset>` tag is not automatically
152-
authoritative. If you want declarations to win unconditionally (HTML5-spec
153-
behaviour), omit CharSoup:
142+
Omit JunkFilter to get plain first-match-wins (each base detector's top
143+
result wins in registration order):
154144

155145
[source,json]
156146
----
@@ -164,11 +154,10 @@ behaviour), omit CharSoup:
164154
}
165155
----
166156

167-
Without CharSoup, `CompositeEncodingDetector` runs in first-match-wins
168-
mode. Trade-off: lying declarations (common on the legacy web)
169-
propagate unfiltered. See
170-
xref:../advanced/charset-detection-design.adoc#opting-out-of-arbitration[the design doc]
171-
for details.
157+
Trade-off: lying declarations propagate unfiltered, and Mojibuster's
158+
statistical guess wins ties without any text-quality cross-check.
159+
See
160+
xref:../advanced/charset-detection-design.adoc#opting-out-of-arbitration[the design doc].
172161

173162
=== Configure the HTML detector's read limit
174163

@@ -188,7 +177,7 @@ large `<script>` blocks before the meta tag (TIKA-2485):
188177
}
189178
},
190179
{"mojibuster-encoding-detector": {}},
191-
{"charsoup-encoding-detector": {}}
180+
{"junk-filter-encoding-detector": {}}
192181
]
193182
}
194183
----

tika-app/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
<artifactId>tika-langdetect-charsoup</artifactId>
6464
<version>${project.version}</version>
6565
</dependency>
66+
<dependency>
67+
<groupId>${project.groupId}</groupId>
68+
<artifactId>tika-ml-junkdetect</artifactId>
69+
<version>${project.version}</version>
70+
</dependency>
6671
<dependency>
6772
<groupId>${project.groupId}</groupId>
6873
<artifactId>tika-xmp</artifactId>

tika-bom/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@
138138
<artifactId>tika-langdetect-charsoup</artifactId>
139139
<version>${revision}</version>
140140
</dependency>
141+
<dependency>
142+
<groupId>org.apache.tika</groupId>
143+
<artifactId>tika-ml-junkdetect</artifactId>
144+
<version>${revision}</version>
145+
</dependency>
141146
<dependency>
142147
<groupId>org.apache.tika</groupId>
143148
<artifactId>tika-langdetect-test-commons</artifactId>

tika-core/src/main/java/org/apache/tika/detect/BOMDetector.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737
* and takes priority over all statistical or structural inference.
3838
*
3939
* <p>SPI-loaded first in the default encoding-detector chain so that BOM evidence
40-
* reaches {@code CharSoupEncodingDetector} before any statistical detector runs.
41-
* {@code MojibusterEncodingDetector} strips the BOM from its own probe independently
42-
* to ensure consistent model inference (BOMs are excluded from training data).</p>
40+
* reaches the meta arbiter ({@code JunkFilterEncodingDetector}) before any
41+
* statistical detector runs. {@code MojibusterEncodingDetector} strips the BOM
42+
* from its own probe independently to ensure consistent model inference (BOMs are
43+
* excluded from training data).</p>
4344
*
4445
* @since Apache Tika 0.x (moved to org.apache.tika.detect in 4.0)
4546
*/

tika-core/src/main/java/org/apache/tika/detect/MetadataCharsetDetector.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
*
4545
* <p>This detector is SPI-loaded in {@code tika-core} and therefore always present
4646
* in the default encoding-detector chain. Its DECLARATIVE result is visible to
47-
* {@code CharSoupEncodingDetector}, which can weigh it against structural or
48-
* statistical evidence from other detectors.</p>
47+
* {@code JunkFilterEncodingDetector}, which honours it when its decoding is
48+
* byte-identical to at least one other candidate's.</p>
4949
*
5050
* @since Apache Tika 4.0
5151
*/

0 commit comments

Comments
 (0)