-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into release/7.0
- Loading branch information
Showing
9 changed files
with
309 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,25 +3,25 @@ | |
|
||
<groupId>com.worksap.nlp</groupId> | ||
<artifactId>analysis-sudachi-elasticsearch7.0</artifactId> | ||
<version>1.3.1-SNAPSHOT</version> | ||
<version>1.3.1</version> | ||
<packaging>jar</packaging> | ||
|
||
<name>analysis-sudachi</name> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.8</java.version> | ||
<elasticsearch.version>7.0.1</elasticsearch.version> | ||
<lucene.version>8.0.0</lucene.version> | ||
<sudachi.version>0.2.0</sudachi.version> | ||
<sonar.host.url>https://sonarcloud.io</sonar.host.url> | ||
<sonar.language>java</sonar.language> | ||
<sonar.organization>worksapplications</sonar.organization> | ||
<sonar.links.homepage>https://github.com/WorksApplications/elasticsearch-sudachi</sonar.links.homepage> | ||
<sonar.links.ci>https://travis-ci.org/WorksApplications/elasticsearch-sudachi</sonar.links.ci> | ||
<sonar.links.issue>https://github.com/WorksApplications/elasticsearch-sudachi/issues</sonar.links.issue> | ||
<sonar.junit.reportsPath/> | ||
<sonar.junit.reportPaths>${project.build.directory}/surefire-reports</sonar.junit.reportPaths> | ||
<java.version>1.8</java.version> | ||
<elasticsearch.version>7.0.1</elasticsearch.version> | ||
<lucene.version>8.0.0</lucene.version> | ||
<sudachi.version>0.3.0</sudachi.version> | ||
<sonar.host.url>https://sonarcloud.io</sonar.host.url> | ||
<sonar.language>java</sonar.language> | ||
<sonar.organization>worksapplications</sonar.organization> | ||
<sonar.links.homepage>https://github.com/WorksApplications/elasticsearch-sudachi</sonar.links.homepage> | ||
<sonar.links.ci>https://travis-ci.org/WorksApplications/elasticsearch-sudachi</sonar.links.ci> | ||
<sonar.links.issue>https://github.com/WorksApplications/elasticsearch-sudachi/issues</sonar.links.issue> | ||
<sonar.junit.reportsPath /> | ||
<sonar.junit.reportPaths>${project.build.directory}/surefire-reports</sonar.junit.reportPaths> | ||
</properties> | ||
|
||
<build> | ||
|
@@ -153,4 +153,4 @@ | |
<developerConnection>scm:git:[email protected]:WorksApplications/elasticsearch-sudachi.git</developerConnection> | ||
<url>https://github.com/WorksApplications/elasticsearch-sudachi</url> | ||
</scm> | ||
</project> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/test/java/com/worksap/nlp/lucene/sudachi/ja/TestSudachiReadingFormFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* Copyright (c) 2019 Works Applications Co., Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.worksap.nlp.lucene.sudachi.ja; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.StringReader; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
|
||
import org.junit.Rule; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import org.apache.lucene.analysis.BaseTokenStreamTestCase; | ||
import org.apache.lucene.analysis.TokenStream; | ||
import org.apache.lucene.analysis.Tokenizer; | ||
|
||
public class TestSudachiReadingFormFilter extends BaseTokenStreamTestCase { | ||
TokenStream tokenStream; | ||
|
||
@Rule | ||
public TemporaryFolder tempFolderForDictionary = new TemporaryFolder(); | ||
|
||
public void setUp() throws Exception { | ||
super.setUp(); | ||
tempFolderForDictionary.create(); | ||
File tempFileForDictionary = tempFolderForDictionary | ||
.newFolder("sudachiDictionary"); | ||
ResourceUtil.copy(tempFileForDictionary); | ||
|
||
String settings; | ||
try (InputStream is = this.getClass().getResourceAsStream("sudachi.json")) { | ||
settings = ResourceUtil.getSudachiSetting(is); | ||
} | ||
|
||
tokenStream = new SudachiTokenizer(true, SudachiTokenizer.Mode.SEARCH, tempFileForDictionary.getPath(), settings); | ||
} | ||
|
||
public void testReadingForm() throws IOException { | ||
SudachiReadingFormFilterFactory factory = new SudachiReadingFormFilterFactory(Collections.emptyMap()); | ||
((Tokenizer)tokenStream).setReader(new StringReader("東京都に行った。")); | ||
tokenStream = factory.create(tokenStream); | ||
assertTokenStreamContents(tokenStream, new String[] {"トウキョウト", "トウキョウ", "ト", "ニ", "イッ", "タ"}); | ||
} | ||
|
||
public void testRomanizedReadingForm() throws IOException { | ||
SudachiReadingFormFilterFactory factory = new SudachiReadingFormFilterFactory(new HashMap<String, String>() {{ put("useRomaji", "true"); }}); | ||
((Tokenizer)tokenStream).setReader(new StringReader("東京都に行った。")); | ||
tokenStream = factory.create(tokenStream); | ||
assertTokenStreamContents(tokenStream, new String[] {"toukyouto", "toukyou", "to", "ni", "iltu", "ta"}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.