First of all start by deleting all the "garbage" at the first of the file (which includes description, instruction etc..)
One possible usage is to change SWN3
an make the method extract
in it return a Double
:
public Double extract(String word) { Double total = new Double(0); if(_dict.get(word+"#n") != null) total = _dict.get(word+"#n") + total; if(_dict.get(word+"#a") != null) total = _dict.get(word+"#a") + total; if(_dict.get(word+"#r") != null) total = _dict.get(word+"#r") + total; if(_dict.get(word+"#v") != null) total = _dict.get(word+"#v") + total; return total; }
Then, giving a String that you want to tag, you can split it so it'll have only words (with no signs and unknown chars) and using the result returned from extract
method on each word, you can decide what is the average weight of the String:
Read full article from java - How to use SentiWordNet - Stack Overflow
No comments:
Post a Comment