将corenlp的输出保存在文件中

时间:2017-05-29 18:58:51

标签: stanford-nlp sentiment-analysis

是否有任何方法可以将核心NLP情绪分析的输出保存在文件中而不是在输出中进行消息传递?

我的代码告知结果:

`    NLP.init();

ConfigurationBuilder cb = new ConfigurationBuilder();
cb.setDebugEnabled(true);
cb.setOAuthConsumerKey("Qxykv655aAS4L5JFXszO1Ym0o");
cb.setOAuthConsumerSecret("EUSziBboNBzn8arsxt2cOgPJWGhs8uCK7yWwZSpKdbzBohRost");
cb.setOAuthAccessToken("825807469238706181-CD69DQaULHhZzNzyIPxDQaTXc4KIDHK");
cb.setOAuthAccessTokenSecret("Y836DvgGset2FMfe9VX3wlzaT69HV0qE7oQumZQCuT7vR");

TwitterStream twitterStream = new TwitterStreamFactory(cb.build()).getInstance();
StatusListener listener = new StatusListener() {

    public void onStatus(Status status) {
        if (((NLP.findSentiment(status.getText()) == 1) | (NLP.findSentiment(status.getText()) == 0))
        ){
            System.out.println(status.getText());

            if (status.getGeoLocation() != null) {

                double latitude = status.getGeoLocation().getLatitude();
                double longitude = status.getGeoLocation().getLongitude();
                if (latitude != 20 && longitude != 78) {
                    return;
                }

            }
        }
    }

};


FilterQuery fq = new FilterQuery();
String keywords[] = {"pizza, junk food, hamburger"};
fq.track(keywords);
fq.language(new String[]{"en"});
twitterStream.addListener(listener);
twitterStream.filter(fq);

`

enter image description here

0 个答案:

没有答案