Integrate given Porter stemmer in C

1.1k views Asked by At

I saw the following has a porter stemmer implementation for C http://tartarus.org/martin/PorterStemmer/

However, though I have tried several times, I cannot integrate it in my code. Can someone tell me how I should call the downloaded file and what I should pass to it in order to stem a string.

In other words, i have a program that requires to stem strings and i need a porter stemmer for that . I am thinking of using the above but i dont know how to use the downloaded file. Please give example

2

There are 2 answers

0
wildplasser On

The c code supplies the function:

int stem ( *str, int i, int j);

That is the one you should call. It modifies the original string, and returns the length of the result.The typical usage is demonstrated in the function stem_file(), which does something like:

char buff[12345]; //should contain one word.

buff [ stem(buff, xx, yy) ] = '\0' ;

I don't know what the 2nd and 3rd parameters mean exactly. Look it up.

0
user2480956 On

The code has two parts.

There is a part that marks the Stemmer definition ending. Before this, they have shown the major 5 steps that the porter's algorithm states. The part after that deals with the file handling part, converts the characters into lower cases. stem function deals with the initialization part. j is considered as the initial word length.

Go through it properly once. It isn't very easy to understand.