diff --git a/lucene/analysis/kuromoji.tests/build.gradle b/lucene/analysis/kuromoji.tests/build.gradle new file mode 100644 index 000000000000..d8fa405da11d --- /dev/null +++ b/lucene/analysis/kuromoji.tests/build.gradle @@ -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') +} diff --git a/lucene/analysis/kuromoji.tests/src/test/module-info.java b/lucene/analysis/kuromoji.tests/src/test/module-info.java new file mode 100644 index 000000000000..e3a14188d45d --- /dev/null +++ b/lucene/analysis/kuromoji.tests/src/test/module-info.java @@ -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; +} diff --git a/lucene/analysis/kuromoji.tests/src/test/org/apache/lucene/analysis/kuromoji/tests/TestJapaneseAnalyzer.java b/lucene/analysis/kuromoji.tests/src/test/org/apache/lucene/analysis/kuromoji/tests/TestJapaneseAnalyzer.java new file mode 100644 index 000000000000..3e4f28ab42d7 --- /dev/null +++ b/lucene/analysis/kuromoji.tests/src/test/org/apache/lucene/analysis/kuromoji/tests/TestJapaneseAnalyzer.java @@ -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()); + } +} diff --git a/lucene/analysis/nori.tests/build.gradle b/lucene/analysis/nori.tests/build.gradle new file mode 100644 index 000000000000..27bc7eef3e80 --- /dev/null +++ b/lucene/analysis/nori.tests/build.gradle @@ -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') +} diff --git a/lucene/analysis/nori.tests/src/test/module-info.java b/lucene/analysis/nori.tests/src/test/module-info.java new file mode 100644 index 000000000000..7cc1956d3fc4 --- /dev/null +++ b/lucene/analysis/nori.tests/src/test/module-info.java @@ -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; +} diff --git a/lucene/analysis/nori.tests/src/test/org/apache/lucene/analysis/nori/tests/TestKoreanAnalyzer.java b/lucene/analysis/nori.tests/src/test/org/apache/lucene/analysis/nori/tests/TestKoreanAnalyzer.java new file mode 100644 index 000000000000..b84b11547b26 --- /dev/null +++ b/lucene/analysis/nori.tests/src/test/org/apache/lucene/analysis/nori/tests/TestKoreanAnalyzer.java @@ -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()); + } +} diff --git a/settings.gradle b/settings.gradle index 971fbb6c5bc2..bcf4f08c9b85 100644 --- a/settings.gradle +++ b/settings.gradle @@ -29,9 +29,11 @@ includeBuild("dev-tools/missing-doclet") include "lucene:analysis:common" include "lucene:analysis:icu" include "lucene:analysis:kuromoji" +include "lucene:analysis:kuromoji.tests" include "lucene:analysis:morfologik" include "lucene:analysis:morfologik.tests" include "lucene:analysis:nori" +include "lucene:analysis:nori.tests" include "lucene:analysis:opennlp" include "lucene:analysis:phonetic" include "lucene:analysis:smartcn"