By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,651 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,651 IT Pros & Developers. It's quick & easy.

implementation of porter's stemmer in Java

P: 8
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.
Attached Files
File Type: txt porter.txt (11.2 KB, 2422 views)
Aug 13 '13 #1
Share this Question
Share on Google+
5 Replies


Nepomuk
Expert 2.5K+
P: 3,112
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(String), 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.
Aug 14 '13 #2

P: 8
Hmm,,,actually I am not getting the point that you have mentioned.
Aug 14 '13 #3

Nepomuk
Expert 2.5K+
P: 3,112
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:
Expand|Select|Wrap|Line Numbers
  1. Porter porterStemmer = new Porter();
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(String). So you can call that function like such:
Expand|Select|Wrap|Line Numbers
  1. porterStemmer.stripAffixes("graceful as a penguin");
Rather than using the String I gave it would of course make sense to use something the algorithm can actually work with.
Aug 15 '13 #4

P: 8
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.
Aug 16 '13 #5

Nepomuk
Expert 2.5K+
P: 3,112
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.
Aug 16 '13 #6

Post your reply

Sign in to post your reply or Sign up for a free account.