Skip to content

Commit

Permalink
Merge pull request #2 from mnagaya/mnagaya/vespa7
Browse files Browse the repository at this point in the history
Port kuromoji-linguistics to vespa7
  • Loading branch information
y-yuyano authored Feb 8, 2019
2 parents 61d3640 + 9b2f85b commit 9c4063d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 39 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>jp.co.yahoo.vespa</groupId>
<artifactId>kuromoji-linguistics</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.2-SNAPSHOT</version>
<packaging>container-plugin</packaging>

<name>kuromoji-linguistics</name>
Expand All @@ -26,11 +26,11 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<source-jdk.version>1.8</source-jdk.version>
<target-jdk.version>1.8</target-jdk.version>
<source-jdk.version>11</source-jdk.version>
<target-jdk.version>11</target-jdk.version>
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>

<vespa.version>6-SNAPSHOT</vespa.version>
<vespa.version>7-SNAPSHOT</vespa.version>
<guice.version>3.0</guice.version>

<kuromoji-ipadic.version>0.9.0</kuromoji-ipadic.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -140,23 +139,4 @@ public GramSplitter getGramSplitter() {
public CharacterClasses getCharacterClasses() {
return simpleLinguistics.getCharacterClasses();
}

@Override
public Tuple2<String, Version> getVersion(Component component) {
switch (component) {
case STEMMER:
case TOKENIZER:
case SEGMENTER:
return new Tuple2<String, Version>("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");
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<String, Version> krmjVersion = linguistics.getVersion(Linguistics.Component.TOKENIZER);
assertEquals("kuromoji", krmjVersion.first);
assertEquals("0.9", krmjVersion.second.toString()); // XXX: change if you changed version!

Tuple2<String, Version> simpleVersion = linguistics.getVersion(Linguistics.Component.GRAM_SPLITTER);
assertEquals("yahoo", simpleVersion.first);
assertEquals("1", simpleVersion.second.toString()); // XXX: change if you changed version!
}
}

0 comments on commit 9c4063d

Please sign in to comment.