summaryrefslogtreecommitdiffstats
path: root/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java
diff options
context:
space:
mode:
Diffstat (limited to 'linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java')
-rw-r--r--linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java26
1 files changed, 6 insertions, 20 deletions
diff --git a/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java b/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java
index a27e726cda8..7ee17559d88 100644
--- a/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java
+++ b/linguistics/src/main/java/com/yahoo/language/opennlp/OpenNlpLinguistics.java
@@ -7,36 +7,22 @@ import com.yahoo.language.detect.Detector;
import com.yahoo.language.process.Tokenizer;
import com.yahoo.language.simple.SimpleDetector;
import com.yahoo.language.simple.SimpleLinguistics;
-import java.util.logging.Logger;
-import java.util.logging.Level;
+import opennlp.tools.langdetect.LanguageDetectorModel;
/**
- * Returns a linguistics implementation based on OpenNlp,
- * and (optionally, default on) Optimaize for language detection.
+ * Returns a linguistics implementation based on OpenNlp.
*
* @author bratseth
+ * @author jonmv
*/
public class OpenNlpLinguistics extends SimpleLinguistics {
- private static final Logger log = Logger.getLogger(OpenNlpLinguistics.class.getName());
private final Detector detector;
- public OpenNlpLinguistics() {
- this(true);
- }
-
@Inject
- public OpenNlpLinguistics(OpennlpLinguisticsConfig config) {
- this(config.detector().enableOptimaize());
- }
-
- public OpenNlpLinguistics(boolean enableOptimaize) {
- this(enableOptimaize ? new OptimaizeDetector() : new SimpleDetector());
- log.log(Level.FINE, "using "+(enableOptimaize ? "Optimaize" : "Simple")+" detector");
- }
-
- private OpenNlpLinguistics(Detector detector) {
- this.detector = detector;
+ public OpenNlpLinguistics(LangDetectModel model) {
+ LanguageDetectorModel loaded = model.load();
+ this.detector = loaded != null ? new OpenNlpDetector(loaded) : new SimpleDetector();
}
@Override