@@ -168,20 +168,18 @@ List<CharsRef> doStem(char[] word, int length, boolean caseVariant) {
168
168
continue ;
169
169
}
170
170
// we can't add this form, it's a pseudostem requiring an affix
171
- if (dictionary .needaffix != -1
172
- && Dictionary .hasFlag (wordFlags , (char ) dictionary .needaffix )) {
171
+ if (Dictionary .hasFlag (wordFlags , dictionary .needaffix )) {
173
172
continue ;
174
173
}
175
174
// we can't add this form, it only belongs inside a compound word
176
- if (dictionary .onlyincompound != -1
177
- && Dictionary .hasFlag (wordFlags , (char ) dictionary .onlyincompound )) {
175
+ if (Dictionary .hasFlag (wordFlags , dictionary .onlyincompound )) {
178
176
continue ;
179
177
}
180
178
stems .add (newStem (word , length , forms , i ));
181
179
}
182
180
}
183
181
try {
184
- stems .addAll (stem (word , length , -1 , - 1 , -1 , 0 , true , true , false , false , caseVariant ));
182
+ stems .addAll (stem (word , length , -1 , ( char ) 0 , -1 , 0 , true , true , false , false , caseVariant ));
185
183
} catch (IOException bogus ) {
186
184
throw new RuntimeException (bogus );
187
185
}
@@ -190,7 +188,7 @@ List<CharsRef> doStem(char[] word, int length, boolean caseVariant) {
190
188
191
189
private boolean acceptCase (boolean caseVariant , char [] wordFlags ) {
192
190
return caseVariant
193
- ? dictionary . keepcase == - 1 || !Dictionary .hasFlag (wordFlags , ( char ) dictionary .keepcase )
191
+ ? !Dictionary .hasFlag (wordFlags , dictionary .keepcase )
194
192
: !Dictionary .hasHiddenFlag (wordFlags );
195
193
}
196
194
@@ -289,7 +287,7 @@ private List<CharsRef> stem(
289
287
char [] word ,
290
288
int length ,
291
289
int previous ,
292
- int prevFlag ,
290
+ char prevFlag ,
293
291
int prefixId ,
294
292
int recursionDepth ,
295
293
boolean doPrefix ,
@@ -428,27 +426,19 @@ private char[] stripAffix(char[] word, int length, int affixLen, int affix, bool
428
426
}
429
427
430
428
private boolean isAffixCompatible (
431
- int affix , int prevFlag , int recursionDepth , boolean previousWasPrefix ) {
429
+ int affix , char prevFlag , int recursionDepth , boolean previousWasPrefix ) {
432
430
int append = dictionary .affixData (affix , Dictionary .AFFIX_APPEND );
433
431
434
432
if (recursionDepth == 0 ) {
435
- if (dictionary .onlyincompound == -1 ) {
436
- return true ;
437
- }
438
-
439
433
// check if affix is allowed in a non-compound word
440
- return !dictionary .hasFlag (append , ( char ) dictionary .onlyincompound , scratch );
434
+ return !dictionary .hasFlag (append , dictionary .onlyincompound , scratch );
441
435
}
442
436
443
437
if (isCrossProduct (affix )) {
444
438
// cross check incoming continuation class (flag of previous affix) against list.
445
439
char [] appendFlags = dictionary .decodeFlags (append , scratch );
446
- assert prevFlag >= 0 ;
447
- boolean allowed =
448
- dictionary .onlyincompound == -1
449
- || !Dictionary .hasFlag (appendFlags , (char ) dictionary .onlyincompound );
450
- if (allowed ) {
451
- return previousWasPrefix || Dictionary .hasFlag (appendFlags , (char ) prevFlag );
440
+ if (!Dictionary .hasFlag (appendFlags , dictionary .onlyincompound )) {
441
+ return previousWasPrefix || Dictionary .hasFlag (appendFlags , prevFlag );
452
442
}
453
443
}
454
444
@@ -528,8 +518,8 @@ private List<CharsRef> applyAffix(
528
518
529
519
// if circumfix was previously set by a prefix, we must check this suffix,
530
520
// to ensure it has it, and vice versa
531
- if (dictionary .circumfix != - 1 ) {
532
- boolean suffixCircumfix = isFlagAppendedByAffix (affix , ( char ) dictionary .circumfix );
521
+ if (dictionary .circumfix != Dictionary . FLAG_UNSET ) {
522
+ boolean suffixCircumfix = isFlagAppendedByAffix (affix , dictionary .circumfix );
533
523
if (circumfix != suffixCircumfix ) {
534
524
continue ;
535
525
}
@@ -540,8 +530,7 @@ private List<CharsRef> applyAffix(
540
530
continue ;
541
531
}
542
532
// we aren't decompounding (yet)
543
- if (dictionary .onlyincompound != -1
544
- && Dictionary .hasFlag (wordFlags , (char ) dictionary .onlyincompound )) {
533
+ if (Dictionary .hasFlag (wordFlags , dictionary .onlyincompound )) {
545
534
continue ;
546
535
}
547
536
stems .add (newStem (strippedWord , length , forms , i ));
@@ -551,8 +540,8 @@ private List<CharsRef> applyAffix(
551
540
552
541
// if a circumfix flag is defined in the dictionary, and we are a prefix, we need to check if we
553
542
// have that flag
554
- if (dictionary .circumfix != - 1 && !circumfix && prefix ) {
555
- circumfix = isFlagAppendedByAffix (affix , ( char ) dictionary .circumfix );
543
+ if (dictionary .circumfix != Dictionary . FLAG_UNSET && !circumfix && prefix ) {
544
+ circumfix = isFlagAppendedByAffix (affix , dictionary .circumfix );
556
545
}
557
546
558
547
if (isCrossProduct (affix ) && recursionDepth <= 1 ) {
@@ -602,7 +591,7 @@ private List<CharsRef> applyAffix(
602
591
}
603
592
604
593
private boolean isFlagAppendedByAffix (int affixId , char flag ) {
605
- if (affixId < 0 ) return false ;
594
+ if (affixId < 0 || flag == Dictionary . FLAG_UNSET ) return false ;
606
595
int appendId = dictionary .affixData (affixId , Dictionary .AFFIX_APPEND );
607
596
return dictionary .hasFlag (appendId , flag , scratch );
608
597
}
0 commit comments