int ReplaceEnd(char *word, RuleList *rule) { register char *ending; /* set to start of possible stemmed suffix */ char tmp_ch; /* save replaced character when testing */ while ( 0 != rule->id ) { ending = end - rule->old_offset; if ( word <= ending ) if ( 0 == strcmp(ending,rule->old_end) ) { tmp_ch = *ending; *ending = '\0'; if ( rule->min_root_size < WordSize(word) ) if ( !rule->condition || (*rule->condition)(word) ) { (void)strcat( word, rule->new_end ); end = ending + rule->new_offset; break; } *ending = tmp_ch; } rule++; } return( rule->id ); } /* ReplaceEnd */
int ReplaceEnd(char *word, RuleList *rule) { char *ending; /* set to start of possible stemmed suffix */ char tmp_ch; /* save replaced character when testing */ char *end; /* pointer to last char of string */ end = word + strlen( word ) - 1; while ( rule->id ) { /* point ending to the start of the test sufix */ ending = end - rule->old_offset; /* is word long enough to contain suffix, and does it exist? */ if ( (word <= ending ) && (0 == strcmp(ending, rule->old_end)) ) { tmp_ch = *ending; /* in case we change our mind */ *ending = '\0'; if ( rule->min_root_size < WordSize(word) ) if (!rule->condition || (*rule->condition) ( word )) { /* replace the ending */ if ( (strlen( word ) + rule->new_offset + 1 ) >= MAXWORDLEN ) return STEM_WORD_TOO_BIG; strcat( word, rule->new_end ); return rule->id; } *ending = tmp_ch; /* nope, put it back */ } rule++; } return STEM_OK; } /* ReplaceEnd */
int RemoveAnE(char *word) { return( (1 == WordSize(word)) && !EndsWithCVC(word) ); } /* RemoveAnE */
int AddAnE( char *word) { return( (1 == WordSize(word)) && EndsWithCVC(word) ); } /* AddAnE */