How to get a general mood for several offers

How do you find the aggregated sense of several sentences / paragraph / large passage of text.

I have the following code below, which I based on the github Stanford CoreNLP tests and various examples, but everything I found completed the sentiment analysis, only calculates the mood for individual sentences. But I want the overall mood of the tweet to be independent of the number of sentences.

The only way I can do this is to create a separate thread for SentimentPipeline.main(String[])and load the text in stdinand collect a common opinion in sdout. I would rather just use my code to make it simpler / more efficient, but I did not find anything.

In addition, I don’t want to make a system call at the bank, as most people do, since I will make millions of tweets per day. The overhead will be too large, loading resources every time.

Annotation document = new Annotation(text);
pipeline.annotate(document);

List<CoreMap> sentences = document.get(SentencesAnnotation.class);
        String output;
        for (CoreMap sentence : sentences) {
            // traversing the words in the current sentence a CoreLabel is a CoreMap with additional token-specific methods
             output = "";
            for (CoreLabel token : sentence.get(TokensAnnotation.class)) {

                // this is the text of the token
                String word = token.get(TextAnnotation.class);

                // this is the Parts Of Speech tag of the token (noun, verb, adjective etc)
                // String pos = token.get(PartOfSpeechAnnotation.class);

                // this is the NER label of the token
                String ne = token.get(NamedEntityTagAnnotation.class);
                if (!ne.contentEquals("O")) {
                    output = output + (ne + " " + word + " ");
                }
            }

            //**************Sentiment Analysis 
            Tree tree = sentence.get(SentimentCoreAnnotations.AnnotatedTree.class);
             String sentiment = RNNCoreAnnotations.getPredictedClass(tree);
+3
source share
1 answer

The mood analysis tool at stanford corenlp learns the sentence-level dataset. If you need a mood mechanism at the document level, I think it's better to choose a new model for documents. You can also try to process the sentences one by one and use some complex methods (for example, medium, maximum) as initial conditions for checking how this works.

+2
source

All Articles