Skip to content

Commit

Permalink
add module tests for kuromoji and nori
Browse files Browse the repository at this point in the history
  • Loading branch information
mocobeta committed Mar 22, 2022
1 parent 6003fae commit c069ecb
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lucene/analysis/kuromoji.tests/build.gradle
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')
}
26 changes: 26 additions & 0 deletions lucene/analysis/kuromoji.tests/src/test/module-info.java
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;
}
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());
}
}
25 changes: 25 additions & 0 deletions lucene/analysis/nori.tests/build.gradle
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')
}
26 changes: 26 additions & 0 deletions lucene/analysis/nori.tests/src/test/module-info.java
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;
}
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());
}
}
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit c069ecb

Please sign in to comment.