I need to implement porter's stemmer in java programming language.but I am not getting what have to write inside the main method.So,if anyone knows it, help me.
attached is the code of the program.
Hm, you can't figure out what to call in the main method? That's odd, didn't you write the code yourself?
From looking at it briefly (and not knowing the porter-stemm-algorithm), I'd guess you have to create an object of the type Porter and then (as it has no specific constructors) call a public method on it. The only public method seems to be stripAffixes(St ring), so that's a good guess. You'll also have to pass it a String; presumably the one you want to get the stemm of.
OK, so you're trying to write the main method, correct? First thing I'd do is create an instance of the Porter class in there. You know, something like this:
[code=java]Porter porterStemmer = new Porter();[/code]
Now you have an object called (in my case) porterStemmer. This has several methods, only one of those however seems to be publicly visible: stripAffixes(St ring). So you can call that function like such:
[code=java]porterStemmer.s tripAffixes("gr aceful as a penguin");[/code]
Rather than using the String I gave it would of course make sense to use something the algorithm can actually work with.
thank you for your help...I have tried to do the things as you have mentioned.but still I am not getting how to input the text files to get the stemming word.it is not working at all.
Ah, file i/o. You didn't mention that before.
There's an article called Reading and Writing files that was written a few years ago but is still valid. The first post should include everything you need; basically pay attention to the use of the File and Scanner classes. The solution will of course have to be adapted - for example, you're not trying to print a file to the output but rather use your algorithm on it. But the adjustments should be fairly simple.
Comment