35
35
import org .apache .lucene .analysis .Analyzer ;
36
36
import org .apache .lucene .analysis .TokenStream ;
37
37
import org .apache .lucene .analysis .tokenattributes .CharTermAttribute ;
38
+ import org .junit .Before ;
38
39
import org .opensearch .Version ;
39
40
import org .opensearch .cluster .metadata .IndexMetadata ;
40
41
import org .opensearch .common .settings .Settings ;
66
67
import static org .hamcrest .Matchers .instanceOf ;
67
68
68
69
public class CompoundAnalysisTests extends OpenSearchTestCase {
70
+
71
+ Settings [] settingsArr ;
72
+
73
+ @ Before
74
+ public void initialize () throws IOException {
75
+ this .settingsArr = getSettingsArr ();
76
+ }
77
+
69
78
public void testDefaultsCompoundAnalysis () throws Exception {
70
- Settings [] settingsArr = getSettingsArr ();
71
- for (Settings settings : settingsArr ) {
79
+ for (Settings settings : this .settingsArr ) {
72
80
IndexSettings idxSettings = IndexSettingsModule .newIndexSettings ("test" , settings );
73
81
AnalysisModule analysisModule = createAnalysisModule (settings );
74
82
TokenFilterFactory filterFactory = analysisModule .getAnalysisRegistry ().buildTokenFilterFactories (idxSettings ).get ("dict_dec" );
@@ -77,8 +85,7 @@ public void testDefaultsCompoundAnalysis() throws Exception {
77
85
}
78
86
79
87
public void testDictionaryDecompounder () throws Exception {
80
- Settings [] settingsArr = getSettingsArr ();
81
- for (Settings settings : settingsArr ) {
88
+ for (Settings settings : this .settingsArr ) {
82
89
List <String > terms = analyze (settings , "decompoundingAnalyzer" , "donaudampfschiff spargelcremesuppe" );
83
90
MatcherAssert .assertThat (terms .size (), equalTo (8 ));
84
91
MatcherAssert .assertThat (
@@ -91,8 +98,7 @@ public void testDictionaryDecompounder() throws Exception {
91
98
// Hyphenation Decompounder tests mimic the behavior of lucene tests
92
99
// lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java
93
100
public void testHyphenationDecompounder () throws Exception {
94
- Settings [] settingsArr = getSettingsArr ();
95
- for (Settings settings : settingsArr ) {
101
+ for (Settings settings : this .settingsArr ) {
96
102
List <String > terms = analyze (settings , "hyphenationAnalyzer" , "min veninde som er lidt af en læsehest" );
97
103
MatcherAssert .assertThat (terms .size (), equalTo (10 ));
98
104
MatcherAssert .assertThat (terms , hasItems ("min" , "veninde" , "som" , "er" , "lidt" , "af" , "en" , "læsehest" , "læse" , "hest" ));
@@ -102,8 +108,7 @@ public void testHyphenationDecompounder() throws Exception {
102
108
// Hyphenation Decompounder tests mimic the behavior of lucene tests
103
109
// lucene/analysis/common/src/test/org/apache/lucene/analysis/compound/TestHyphenationCompoundWordTokenFilterFactory.java
104
110
public void testHyphenationDecompounderNoSubMatches () throws Exception {
105
- Settings [] settingsArr = getSettingsArr ();
106
- for (Settings settings : settingsArr ) {
111
+ for (Settings settings : this .settingsArr ) {
107
112
List <String > terms = analyze (settings , "hyphenationAnalyzerNoSubMatches" , "basketballkurv" );
108
113
MatcherAssert .assertThat (terms .size (), equalTo (3 ));
109
114
MatcherAssert .assertThat (terms , hasItems ("basketballkurv" , "basketball" , "kurv" ));
0 commit comments