Tika LanguageDetection 给出错误 'No language detectors available'

Tika LanguageDetection gives error 'No language detectors available'

Tika 2.2.3,简单代码

public static void main(String[] args) throws IOException {
        LanguageDetector detector =LanguageDetector.getDefaultLanguageDetector();
        detector.addText("This is english");
        detector.addText("This is english");
        detector.addText("This is english");
        detector.addText("This is english");
        detector.addText("This is english");
        detector.addText("This is english");
        detector.addText("This is english");
        detector.addText("This is english");
        detector.addText("This is english");
        LanguageResult languageResult=detector.detect();
}

最后一行出错

Exception in thread "main" java.lang.IllegalStateException: No language detectors available
    at org.apache.tika.language.detect.LanguageDetector.getDefaultLanguageDetector(LanguageDetector.java:67)

更新 Maven 依赖关系

<dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-core</artifactId>
            <version>2.3.0</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.apache.tika/tika-langdetect -->
        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-langdetect</artifactId>
            <version>2.3.0</version>
            <type>pom</type>
        </dependency>

我在网上找不到任何有用的东西来解决这个问题...我是否缺少一些必须下载的模型文件,在哪里?

非常感谢任何提示!

我试过你的代码并重现了同样的问题。看完了docs, which then led to samples in github and I finally found its pom.xml就产生了另一个依赖。然后我成功得到了预期的输出:en: HIGH (0.999999).

        <dependency>
            <groupId>org.apache.tika</groupId>
            <artifactId>tika-langdetect-optimaize</artifactId>
            <version>2.3.0</version>
        </dependency>
        LanguageDetector detector = LanguageDetector.getDefaultLanguageDetector().loadModels();
        detector.addText("This is english");
        LanguageResult languageResult = detector.detect();

说明

LanguageDetector 是抽象的 class,实现应该作为依赖添加。