I am trying to make a sentiment analysis of a sentence. I am reading word's positive and negative values and then showing the result to the user as entered sentence is positive or negative. However, it works for some sentences ang gives exception for some other and I am really confused about it. My code is below. All implementations are done through this class. What should I do to solve it ?
And I have file something like boring 0.1 0.5 good 0.6 0.4 . . . When I write a boring book the output This sentence is negative
When I write a terrible car I get
a terrible car
File does not contain this word.!
Exception in thread "main" java.lang.NullPointerException
at SentimentAnalysis.posOrNeg(SentimentAnalysis.java:86)
at SentimentAnalysis.main(SentimentAnalysis.java:121)
My file's content is
a 0.8 0.8
beautiful 0.3 0.01
car 0.1 0.1
boring 0.01 0.02
book 0.2 0.18
baby 0.8 0.6
cute 0.6 0.4
terrible 0.3 0.4
ArrayIndexOutOfBoundsException
where you try to blindly accessparts[0], parts[1],
andparts[2]
without verifying that you actually split the line into three parts first. – David Conrad