Apache Lucene open-source search software
Curate Thai stopwords to prevent over-filtering of compound words (#5323, #14730) (#16718)
Kamthorn Krairaksab0ae596a78b1
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 7e267cfbb04..31465cb63d4 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -149,6 +149,9 @@ New FeaturesImprovements---------------------+* GITHUB#16718: Modernize ThaiAnalyzer default stopwords list based on contemporary Thai corpus+ frequency analysis and linguistically validated stop words. (Kamthorn Krairaksa)+* GITHUB#15704: Replace LinkedList with more efficient data structure. (Renato Haeberli)* GITHUB#15682: Use ArrayDeque instead of LinkedList in CompoundWordTokenFilterBase.java. (Renato Haeberli)diff --git a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/th/stopwords.txt b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/th/stopwords.txtindex 07f0fabe692..50d44237ecd 100644--- a/lucene/analysis/common/src/resources/org/apache/lucene/analysis/th/stopwords.txt+++ b/lucene/analysis/common/src/resources/org/apache/lucene/analysis/th/stopwords.txt@@ -1,44 +1,35 @@-# Thai stopwords from:-# "Opinion Detection in Thai Political News Columns-# Based on Subjectivity Analysis"-# Khampol Sukhum, Supot Nitsuwat, and Choochart Haruechaiyasak+# Thai stopwords+# Originally derived from Sukhum et al. (2010) "Opinion Detection in Thai Political News Columns"+# Curated for general information retrieval to prevent over-filtering of compound words,+# common verbs, and nouns (LUCENE-4253, #14730).ไว้ไม่-ไป-ได้ให้ในโดย+ได้แห่งแล้วและ-แรก-แบบแต่เอง-เห็นเลย-เริ่มเราเมื่อเพื่อเพราะเป็นการเป็น-เปิดเผย-เปิดเนื่องจากเดียวกันเดียวเช่นเฉพาะเคย-เข้าเขาอีกอาจอะไร-ออกอย่างอยู่อยาก@@ -49,38 +40,26 @@หรือหนึ่งส่วน-ส่งสุดสําหรับ+สำหรับว่า-วัน-ลง-ร่วม-ราย-รับระหว่างรวมยังมีมาก-มาพร้อม-พบ-ผ่าน-ผลบางน่านี้-นํานั้น-นักนอกจากทุกที่สุดที่ทําให้-ทํา-ทาง+ทำให้ทั้งนี้ทั้งถ้า@@ -92,23 +71,17 @@ต่อตามตั้งแต่-ตั้ง-ด้านด้วยดังซึ่ง-ช่วงจึงจาก-จัดจะคือความครั้งคง-ขึ้นของ-ขอขณะก่อนก็@@ -116,4 +89,3 @@กับกันกว่า-กล่าวdiff --git a/lucene/analysis/common/src/test/org/apache/lucene/analysis/th/TestThaiAnalyzer.java b/lucene/analysis/common/src/test/org/apache/lucene/analysis/th/TestThaiAnalyzer.javaindex 9bca83c8f7b..58565d23293 100644--- a/lucene/analysis/common/src/test/org/apache/lucene/analysis/th/TestThaiAnalyzer.java+++ b/lucene/analysis/common/src/test/org/apache/lucene/analysis/th/TestThaiAnalyzer.java@@ -147,6 +147,22 @@ public class TestThaiAnalyzer extends BaseTokenStreamTestCase {analyzer.close();}+ /** LUCENE-4253, #14730: Test that common content words in compounds are not over-filtered */+ public void testCompoundAndContentWordsNotOverFiltered() throws Exception {+ Analyzer analyzer = new ThaiAnalyzer();+ // Issue #14730: "ที่ผ่านมา" should retain "ผ่าน" and "มา"+ assertAnalyzesTo(analyzer, "ที่ผ่านมา", new String[] {"ผ่าน", "มา"});+ // "เปิดตัวสินค้า" should retain "เปิด"+ assertAnalyzesTo(analyzer, "เปิดตัวสินค้า", new String[] {"เปิด", "ตัว", "สินค้า"});+ // "ส่งออก" should retain both "ส่ง" and "ออก"+ assertAnalyzesTo(analyzer, "ส่งออก", new String[] {"ส่ง", "ออก"});+ // "วันหยุด" should retain "วัน"+ assertAnalyzesTo(analyzer, "วันหยุด", new String[] {"วัน", "หยุด"});+ // "ผลการเรียน" should retain "ผล" and "เรียน"+ assertAnalyzesTo(analyzer, "ผลการเรียน", new String[] {"ผล", "เรียน"});+ analyzer.close();+ }+public void testNormalization() throws Exception {Analyzer analyzer = new ThaiAnalyzer(CharArraySet.EMPTY_SET);// Double Sara E -> Sara Ae