Exemplo n.º 1
0
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 */
Exemplo n.º 2
0
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 */
Exemplo n.º 3
0
int RemoveAnE(char *word)
{

	return( (1 == WordSize(word)) && !EndsWithCVC(word) );

} /* RemoveAnE */
Exemplo n.º 4
0
int AddAnE( char *word)
{

	return( (1 == WordSize(word)) && EndsWithCVC(word) );

} /* AddAnE */