Module: Stemmer

Defined in:
ext/porter_wrap.c

Class Method Summary collapse

Class Method Details

.stem_word(arg) ⇒ Object

a general offset into the string



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'ext/porter_wrap.c', line 18

static VALUE stem_word(VALUE self, VALUE arg)
{
	size_t length, i;
	char *word;
	struct stemmer z;
	VALUE str, rv;

	str = StringValue(arg);
	word = malloc(RSTRING_LEN(str) + 1);
	strncpy(word, RSTRING_PTR(str), RSTRING_LEN(str));
	word[RSTRING_LEN(str)] = '\0';

	length  = stem(&z, word, strlen(word)-1);
	word[length+1] = 0;
	rv = rb_str_new2(word);
	free(word);
	return rv;
}