forked from apache/lucene
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add module tests for kuromoji and nori
- Loading branch information
Showing
7 changed files
with
202 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
|
||
apply plugin: 'java-library' | ||
|
||
description = 'Module tests for :lucene:analysis:kuromoji' | ||
|
||
dependencies { | ||
moduleTestImplementation project(':lucene:analysis:kuromoji') | ||
moduleTestImplementation project(':lucene:test-framework') | ||
} |
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,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
|
||
/** Test module for {@code org.apache.lucene.analysis.kuromoji}. */ | ||
module org.apache.lucene.analysis.kuromoji.tests { | ||
requires org.apache.lucene.core; | ||
requires org.apache.lucene.analysis.common; | ||
requires org.apache.lucene.analysis.kuromoji; | ||
requires org.apache.lucene.test_framework; | ||
|
||
exports org.apache.lucene.analysis.kuromoji.tests; | ||
} |
49 changes: 49 additions & 0 deletions
49
...romoji.tests/src/test/org/apache/lucene/analysis/kuromoji/tests/TestJapaneseAnalyzer.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,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.lucene.analysis.kuromoji.tests; | ||
|
||
import static org.apache.lucene.tests.analysis.BaseTokenStreamTestCase.assertAnalyzesTo; | ||
|
||
import java.io.IOException; | ||
import org.apache.lucene.analysis.Analyzer; | ||
import org.apache.lucene.analysis.ja.JapaneseAnalyzer; | ||
import org.apache.lucene.tests.util.LuceneTestCase; | ||
import org.junit.Assert; | ||
|
||
public class TestJapaneseAnalyzer extends LuceneTestCase { | ||
|
||
public void testJapaneseAnalyzerWorksInModuleMode() throws IOException { | ||
Analyzer a = new JapaneseAnalyzer(); | ||
assertNotNull(a); | ||
assertAnalyzesTo( | ||
a, | ||
"多くの学生が試験に落ちた。", | ||
new String[] {"多く", "学生", "試験", "落ちる"}, | ||
new int[] {0, 3, 6, 9}, | ||
new int[] {2, 5, 8, 11}, | ||
new int[] {1, 2, 2, 2}); | ||
a.close(); | ||
} | ||
|
||
public void testWeAreModule() { | ||
Assert.assertTrue(this.getClass().getModule().isNamed()); | ||
} | ||
|
||
public void testKuromojiIsAModule() { | ||
Assert.assertTrue(JapaneseAnalyzer.class.getModule().isNamed()); | ||
} | ||
} |
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,25 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
|
||
apply plugin: 'java-library' | ||
|
||
description = 'Module tests for :lucene:analysis:nori' | ||
|
||
dependencies { | ||
moduleTestImplementation project(':lucene:analysis:nori') | ||
moduleTestImplementation project(':lucene:test-framework') | ||
} |
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,26 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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. | ||
*/ | ||
|
||
/** Test module for {@code org.apache.lucene.analysis.nori}. */ | ||
module org.apache.lucene.analysis.nori.tests { | ||
requires org.apache.lucene.core; | ||
requires org.apache.lucene.analysis.common; | ||
requires org.apache.lucene.analysis.nori; | ||
requires org.apache.lucene.test_framework; | ||
|
||
exports org.apache.lucene.analysis.nori.tests; | ||
} |
49 changes: 49 additions & 0 deletions
49
...nalysis/nori.tests/src/test/org/apache/lucene/analysis/nori/tests/TestKoreanAnalyzer.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,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 org.apache.lucene.analysis.nori.tests; | ||
|
||
import static org.apache.lucene.tests.analysis.BaseTokenStreamTestCase.assertAnalyzesTo; | ||
|
||
import java.io.IOException; | ||
import org.apache.lucene.analysis.Analyzer; | ||
import org.apache.lucene.analysis.ko.KoreanAnalyzer; | ||
import org.apache.lucene.tests.util.LuceneTestCase; | ||
import org.junit.Assert; | ||
|
||
public class TestKoreanAnalyzer extends LuceneTestCase { | ||
|
||
public void testKoreanAnalyzerWorksInModuleMode() throws IOException { | ||
Analyzer a = new KoreanAnalyzer(); | ||
assertNotNull(a); | ||
assertAnalyzesTo( | ||
a, | ||
"한국은 대단한 나라입니다.", | ||
new String[] {"한국", "대단", "나라", "이"}, | ||
new int[] {0, 4, 8, 10}, | ||
new int[] {2, 6, 10, 13}, | ||
new int[] {1, 2, 3, 1}); | ||
a.close(); | ||
} | ||
|
||
public void testWeAreModule() { | ||
Assert.assertTrue(this.getClass().getModule().isNamed()); | ||
} | ||
|
||
public void testNoriIsAModule() { | ||
Assert.assertTrue(KoreanAnalyzer.class.getModule().isNamed()); | ||
} | ||
} |
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