Skip to content

Apache Lucene open-source search software

LUCENE-8752: Add Japanese new imperial era '令和' (Reiwa) to the dictionary used in JapaneseTokenizer

Tomoko Uchida7619c07d3a80
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 63adfcbb5e6..1ecde59cedd 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -110,7 +110,7 @@ Improvements
* LUCENE-8750: Implements setMissingValue() on sort fields produced from
DoubleValuesSource and LongValuesSource (Mike Sokolov via Alan Woodward)
-
+
* LUCENE-8701: ToParentBlockJoinQuery now creates a child scorer that disallows skipping over
non-competitive documents if the score of a parent depends on the score of multiple
children (avg, max, min). Additionally the score mode `none` that assigns a constant score to
@@ -119,6 +119,10 @@ Improvements
* LUCENE-8751: Weight#matches now use the ScorerSupplier to build scorers with a lead cost of 1
(single document). (Jim Ferenczi)
+* LUCENE-8752: Japanese new era name '令和' (Reiwa) is added to the dictionary used in
+ JapaneseTokenizer so that the analyzer handles the era name correctly.
+ Reiwa is set to replace the Heisei Era on May 1, 2019. (Tomoko Uchida)
+
Changes in Runtime Behavior
* LUCENE-8671: Load FST off-heap also for ID-like fields if reader is not opened
diff --git a/lucene/analysis/kuromoji/build.xml b/lucene/analysis/kuromoji/build.xml
index 0bce4b4ca28..decfa7a06fc 100644
--- a/lucene/analysis/kuromoji/build.xml
+++ b/lucene/analysis/kuromoji/build.xml
@@ -64,6 +64,11 @@
<untar src="${build.dir}/${ipadic.version}.tar" dest="${build.dir}"/>
</target>
+ <target name="patch-dict" depends="download-dict">
+ <patch patchfile="src/tools/patches/Noun.proper.csv.patch"
+ originalfile="${dict.src.dir}/Noun.proper.csv"/>
+ </target>
+
<path id="tools.dependencies">
<fileset dir="../icu/lib"/>
</path>
@@ -81,7 +86,7 @@
<pathelement location="${build.dir}/classes/tools-test"/>
</path>
- <target name="build-dict" depends="compile-tools, download-dict">
+ <target name="build-dict" depends="compile-tools, patch-dict">
<sequential>
<delete verbose="true">
<fileset dir="${resources.dir}/org/apache/lucene/analysis/ja/dict" includes="**/*"/>
diff --git a/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$buffer.dat b/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$buffer.dat
index dcf430a4644..09f1e46680b 100644
Binary files a/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$buffer.dat and b/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$buffer.dat differ
diff --git a/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$fst.dat b/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$fst.dat
index 6cfad720383..c06fd4a128c 100644
Binary files a/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$fst.dat and b/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$fst.dat differ
diff --git a/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$targetMap.dat b/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$targetMap.dat
index 0e27345a48b..13d09bc2eb6 100644
Binary files a/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$targetMap.dat and b/lucene/analysis/kuromoji/src/resources/org/apache/lucene/analysis/ja/dict/TokenInfoDictionary$targetMap.dat differ
diff --git a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizer.java b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizer.java
index cc698408711..1a478db9835 100644
--- a/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizer.java
+++ b/lucene/analysis/kuromoji/src/test/org/apache/lucene/analysis/ja/TestJapaneseTokenizer.java
@@ -836,4 +836,16 @@ public class
tokenizer.reset();
while (tokenizer.incrementToken());
}
+
+ public void testPatchedSystemDict() throws Exception {
+ assertAnalyzesTo(analyzer, "令和元年",
+ new String[]{"令和", "元年"},
+ new int[]{0, 2},
+ new int[]{2, 4});
+
+ assertAnalyzesTo(analyzerNormal, "令和元年",
+ new String[]{"令和", "元年"},
+ new int[]{0, 2},
+ new int[]{2, 4});
+ }
}
diff --git a/lucene/analysis/kuromoji/src/tools/patches/Noun.proper.csv.patch b/lucene/analysis/kuromoji/src/tools/patches/Noun.proper.csv.patch
new file mode 100644
index 00000000000..ee845ab8456
--- /dev/null
+++ b/lucene/analysis/kuromoji/src/tools/patches/Noun.proper.csv.patch
@@ -0,0 +1,7 @@
+--- Noun.proper.csv 2007-07-31 23:50:07.000000000 +0900
++++ Noun.proper.csv.20190403 2019-04-03 15:52:43.793191818 +0900
+@@ -27325,3 +27325,4 @@
+ ������ɡ,1288,1288,8538,̾��,��ͭ̾��,����,*,*,*,������ɡ,���Υ��ϥ�,���Υ��ϥ�
+ �ɥ���,1288,1288,3765,̾��,��ͭ̾��,����,*,*,*,�ɥ���,�ɥ�����,�ɡ�����
+ �;뻳,1288,1288,8538,̾��,��ͭ̾��,����,*,*,*,�;뻳,�ȥ������,�ȥ������
++����,1288,1288,5904,̾��,��ͭ̾��,����,*,*,*,����,�쥤��,�쥤��