I am trying to analyze sentiment using nlp. The version of stanford-nlp I am using is 3.4.1. I have some junk data to process and it looks like it takes around 45 seconds to process using default PCFG file.
Here is the example:
String text = "Nm n n 4 n n bkj nun4hmnun Onn njnb hm5bn nm55m nbbh n mnrrnut but n rym4n nbn 4nn65 m nun m n nn nun 4nm 5 gm n my b bb b b rtmrt55tmmm5tttn b b bb g bn nn n h r ret n nun bn d. B bbbbbbbbbbr bung NHnhn nn nk, v v v n gain t g 4gnyhimmigration ndn nb NVnb bin uny 7 nbbbbbnn vv bbvb ninn njnj n4 nm n km n n n cb j bun. Nhfnt bn nn. N hm nn nun m bum my b mmmnbjk nn n by nn nun nun n nun nn bn n nhn n nn n n m NH nb4mnm mkn 4 n n n n hm r b rnfngg4d in b nut mmmkmmm5 bbjn n n ij BBM 8u8i by nun n.nn hm n. n4n By 4n4n bunny RN bny hm j mi. Nymmn FBT not mn n n nm g by n n nnm? Rnyb vCard n5 Yu nn n n n n nt .nm mn nt n nb n n n n by y5nnnhyyh h b b nt njj n m f4n re";
Properties props = new Properties();
props.setProperty("annotators","tokenize, ssplit, pos,parse,sentiment");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation annotation = pipeline.process(text);
Based on the suggestion here, I tried again with the shift-reduce parser.
Properties props = new Properties();
props.setProperty("annotators","tokenize, ssplit, pos,parse,sentiment");
props.put("parse.model", "com/example/nlp/englishSR.ser.gz");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation annotation = pipeline.process(text);
I have to download the shift-reduce model and put it in the classpath. The model class is getting loaded but it's throwing a null pointer exception. Any thoughts and suggestions?
Is there a specific reason why you are using version 3.4.1 and not the latest version?
If I run your code with the latest version, it works for me (after I change the path to the SR model to edu/stanford/nlp/models/srparser/englishSR.ser.gz
but I assume you changed that path on purpose).
Also make sure that the models you downloaded are compatible with your version of CoreNLP. If you downloaded the latest models and try to use them with an older version of CoreNLP, then you will most likely run into problems.