Apache Solr open-source search software
LUCENE-7287: normalize Ukrainian morfologik dictionary to have unique token+lemma pairs
Mike McCandlessbc502bd9c916
diff --git a/lucene/analysis/morfologik/src/resources/org/apache/lucene/analysis/uk/mapping_uk.txt b/lucene/analysis/morfologik/src/resources/org/apache/lucene/analysis/uk/mapping_uk.txtnew file mode 100644index 00000000000..114260476e4--- /dev/null+++ b/lucene/analysis/morfologik/src/resources/org/apache/lucene/analysis/uk/mapping_uk.txt@@ -0,0 +1,19 @@+# 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.+++# This map normalizes some characters used in Ukrainian text+"\u2019" => "'"+"\u02BC" => "'"++# Remove accent+"\u0301" => ""diff --git a/lucene/analysis/morfologik/src/resources/org/apache/lucene/analysis/uk/ukrainian.dict b/lucene/analysis/morfologik/src/resources/org/apache/lucene/analysis/uk/ukrainian.dictindex 679e39251c3..246897061aa 100644Binary files a/lucene/analysis/morfologik/src/resources/org/apache/lucene/analysis/uk/ukrainian.dict and b/lucene/analysis/morfologik/src/resources/org/apache/lucene/analysis/uk/ukrainian.dict differdiff --git a/lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/uk/TestUkrainianAnalyzer.java b/lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/uk/TestUkrainianAnalyzer.javaindex 87d3be53432..a38fc63e873 100644--- a/lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/uk/TestUkrainianAnalyzer.java+++ b/lucene/analysis/morfologik/src/test/org/apache/lucene/analysis/uk/TestUkrainianAnalyzer.java@@ -37,22 +37,29 @@ public class TestUkrainianAnalyzer extends BaseTokenStreamTestCase {public void testReusableTokenStream() throws Exception {Analyzer a = new UkrainianMorfologikAnalyzer();- assertAnalyzesTo(a, "Ця п'єса у свою чергу рухається по колу.",- new String[] { "п'єса", "черга", "рухатися", "кола", "коло", "коло", "кіл", "кіл" });+ assertAnalyzesTo(a, "Ця п'єса, у свою чергу, рухається по емоційно-напруженому колу за ритм-енд-блюзом.",+ new String[] { "п'єса", "черга", "рухатися", "емоційно", "напружений", "кола", "коло", "кіл", "ритм", "енд", "блюз" });a.close();}public void testSpecialCharsTokenStream() throws Exception {Analyzer a = new UkrainianMorfologikAnalyzer();- assertAnalyzesTo(a, "Ця пʼєса, у сво́ю чергу, рухається по колу.",- new String[] { "п'єса", "черга", "рухатися", "кола", "коло", "коло", "кіл", "кіл" });+ assertAnalyzesTo(a, "Ця пʼєса, у сво́ю чергу рухається.",+ new String[] { "п'єса", "черга", "рухатися" });a.close();}public void testCapsTokenStream() throws Exception {Analyzer a = new UkrainianMorfologikAnalyzer();- assertAnalyzesTo(a, "Цей Чайковський.",- new String[] { "чайковський" });+ assertAnalyzesTo(a, "Цей Чайковський і Ґете.",+ new String[] { "чайковський", "ґете" });+ a.close();+ }++ public void testSampleSentence() throws Exception {+ Analyzer a = new UkrainianMorfologikAnalyzer();+ assertAnalyzesTo(a, "Це — проект генерування словника з тегами частин мови для української мови.",+ new String[] { "проект", "генерування", "словник", "тег", "частина", "мова", "українська", "український", "мова" });a.close();}