From 9b2f85bfbe9884d1fd3214aa971773d3812447a4 Mon Sep 17 00:00:00 2001 From: Masakazu Nagaya Date: Fri, 8 Feb 2019 14:58:34 +0900 Subject: [PATCH] Port kuromoji-linguistics to vespa7 --- README.md | 4 ++-- pom.xml | 8 ++++---- .../lib/kuromoji/KuromojiLinguistics.java | 20 ------------------- .../lib/kuromoji/KuromojiLinguisticsTest.java | 13 ------------ 4 files changed, 6 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 7b64e60..38927f0 100644 --- a/README.md +++ b/README.md @@ -13,14 +13,14 @@ For more details, please see official website of Kuromoji. ### Requirement -JDK (>= 1.8) and maven are required to build package. +JDK (>= 11) and maven are required to build package. ### Build Execute mvn command as below, and you can get package as target/kuromoji-linguistics-${VERSION}-deploy.jar ``` -$ mvn package -Dvespa.version='6.214.72' # You can specify 6.214.72 or later. +$ mvn package -Dvespa.version='7.7.18' # You can specify 7.7.18 or later. ``` ## Use Package diff --git a/pom.xml b/pom.xml index 1d08df8..5a0a819 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ jp.co.yahoo.vespa kuromoji-linguistics - 0.0.1-SNAPSHOT + 0.0.2-SNAPSHOT container-plugin kuromoji-linguistics @@ -26,11 +26,11 @@ UTF-8 - 1.8 - 1.8 + 11 + 11 3.5.1 - 6-SNAPSHOT + 7-SNAPSHOT 3.0 0.9.0 diff --git a/src/main/java/jp/co/yahoo/vespa/language/lib/kuromoji/KuromojiLinguistics.java b/src/main/java/jp/co/yahoo/vespa/language/lib/kuromoji/KuromojiLinguistics.java index eb5a8fe..17713b7 100644 --- a/src/main/java/jp/co/yahoo/vespa/language/lib/kuromoji/KuromojiLinguistics.java +++ b/src/main/java/jp/co/yahoo/vespa/language/lib/kuromoji/KuromojiLinguistics.java @@ -6,7 +6,6 @@ package jp.co.yahoo.vespa.language.lib.kuromoji; import com.google.inject.Inject; -import com.yahoo.collections.Tuple2; import com.yahoo.component.Version; import com.yahoo.language.Linguistics; import com.yahoo.language.detect.Detector; @@ -140,23 +139,4 @@ public GramSplitter getGramSplitter() { public CharacterClasses getCharacterClasses() { return simpleLinguistics.getCharacterClasses(); } - - @Override - public Tuple2 getVersion(Component component) { - switch (component) { - case STEMMER: - case TOKENIZER: - case SEGMENTER: - return new Tuple2("kuromoji", context.getKuromojiVersion()); - case NORMALIZER: - case TRANSFORMER: - case DETECTOR: - case GRAM_SPLITTER: - case CHARACTER_CLASSES: - return simpleLinguistics.getVersion(component); - default: - throw new IllegalArgumentException("unknown component type"); - } - } - } diff --git a/src/test/java/jp/co/yahoo/vespa/language/lib/kuromoji/KuromojiLinguisticsTest.java b/src/test/java/jp/co/yahoo/vespa/language/lib/kuromoji/KuromojiLinguisticsTest.java index 946c23a..a627250 100644 --- a/src/test/java/jp/co/yahoo/vespa/language/lib/kuromoji/KuromojiLinguisticsTest.java +++ b/src/test/java/jp/co/yahoo/vespa/language/lib/kuromoji/KuromojiLinguisticsTest.java @@ -14,7 +14,6 @@ import org.junit.Test; -import com.yahoo.collections.Tuple2; import com.yahoo.component.Version; import com.yahoo.language.Language; import com.yahoo.language.Linguistics; @@ -167,16 +166,4 @@ public void testCharacterClasses() throws Exception { assertTrue(characterClasses.isDigit(Character.codePointAt(java.text.Normalizer.normalize("123", java.text.Normalizer.Form.NFKC), 0))); } - @Test - public void testVersion() throws Exception { - Linguistics linguistics = KuromojiLinguistics.create(DEFAULT_KUROMOJI_CONFIG, DEFAULT_STOKEN_CONFIG).get(); - - Tuple2 krmjVersion = linguistics.getVersion(Linguistics.Component.TOKENIZER); - assertEquals("kuromoji", krmjVersion.first); - assertEquals("0.9", krmjVersion.second.toString()); // XXX: change if you changed version! - - Tuple2 simpleVersion = linguistics.getVersion(Linguistics.Component.GRAM_SPLITTER); - assertEquals("yahoo", simpleVersion.first); - assertEquals("1", simpleVersion.second.toString()); // XXX: change if you changed version! - } }