Question

How to find out the verbs in the text with part of speech tags using the...

How to find out the verbs in the text with part of speech tags using the constrains in Stanford CoreNLP.

For example, in the text

Supplementary_NNP Data_NNP are_VBP available_JJ at_IN NAR_NNP Online_NNP ._. 

I want to find out the verb of the sentence which must contain the word `online`

I have many thses sentences, which has been added with part of speech suffix to each word. And I would like to use regex or other means to find out verb of the sentence which contains specific word.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

please do like if you are impressed with the answer

Answer:

Code to extract verbs using NLP libraries in Java :

import edu.stanford.nlp.ie.util.RelationTriple;
import edu.stanford.nlp.ling.CoreAnnotations;
import edu.stanford.nlp.ling.CoreAnnotations.TextAnnotation;
import edu.stanford.nlp.pipeline.Annotation;
import edu.stanford.nlp.pipeline.StanfordCoreNLP;
import edu.stanford.nlp.naturalli.NaturalLogicAnnotations;
import edu.stanford.nlp.util.CoreMap;
import java.util.Collection;
import java.util.Properties;

public class OpenIE {

    public static void main(String[] args) {
        Properties props = new Properties();
        props.setProperty("annotators", "tokenize,ssplit,pos,lemma,depparse,natlog,openie");
        StanfordCoreNLP pipeline = new StanfordCoreNLP(props);

        // Annotate your sentences
        Annotation doc = new Annotation("This person is trust worthy. This person is non judgemental. This person is well spoken.");
        pipeline.annotate(doc);

        // Loop over sentences in the document
        for (CoreMap sentence : doc.get(CoreAnnotations.SentencesAnnotation.class)) {
          // Get the OpenIE triples for the sentence
          Collection<RelationTriple> triples = sentence.get(NaturalLogicAnnotations.RelationTriplesAnnotation.class);
          // Print the triples
          for (RelationTriple triple : triples){
              triple.object.forEach(object -> System.out.print(object.get(TextAnnotation.class) + " "));
              System.out.println();
          }
       }
    }
}

Output :

trust worthy non judgemental judgemental well spoken spoken ... Program finished with exit code o Press ENTER to exit console

Add a comment
Know the answer?
Add Answer to:
How to find out the verbs in the text with part of speech tags using the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In the following sentence, identify the part of speech of the italicized word

    1. In the following sentence, identify the part of speech of the italicized word. Large fish swim swiftly in the sea. A. Verb B. Noun C. Adjective D. Adverb 2. In the following sentence, identify the part of speech of the italicized word. Large fish swim swiftly in the sea. 3. Choose the sentence that contains a relative pronoun. A. Mr. Moon, whom you have met, is my assistant. B. Those are not my shoes. C. Someone is coming down...

  • In the following sentence, identify the part of speech of the italicized word

    1. In the following sentence, identify the part of speech of the italicized word. Large fish swim swiftly in the sea. A. Verb B. Noun C. Adjective D. Adverb 2. In the following sentence, identify the part of speech of the italicized word. Large fish swim swiftly in the sea. 3. Choose the sentence that contains a relative pronoun. A. Mr. Moon, whom you have met, is my assistant. B. Those are not my shoes. C. Someone is coming down...

  • PART B. The part of the exam is worth 5 Points - BRIEF Essay In the...

    PART B. The part of the exam is worth 5 Points - BRIEF Essay In the space below provide a brief essay on the following topic. Please follow the rules. TOPIC We are experiencing an unusual period in US GAAP reporting. More and more companies are reporting Negative Balances for TOTAL Equity. In class meetings we reviewed the Balance Sheets of McDonald's and American Airlines to see two examples of this. Negative equity is counter-intuitive. That means it is both...

  • Assignment #6 - Arrays and Strings - Making random sentences! Due: Tuesday April 2, 11:59:00 pm...

    Assignment #6 - Arrays and Strings - Making random sentences! Due: Tuesday April 2, 11:59:00 pm Objective This assignment will consist of writing a program that involves practice with arrays, random number generation, and Strings. You may use c-strings or string objects here, however, string objects is recommended. Exercise Filename: sentences.cpp Write a program that uses random-number generation to create sentences. Create four arrays of strings (string objects highly suggested over c-strings) called article, noun, verb, and preposition. The arrays...

  • Is there any english experts out there? I couldn’t find the english section for these questions. These are english questions that was tough for me thank u. 1. which of the following sentences correc...

    Is there any english experts out there? I couldn’t find the english section for these questions. These are english questions that was tough for me thank u. 1. which of the following sentences correctly uses a compound sentence structure? A. He liked to cook at home, but she preferred to eat at restaurants. B. Although he would have gone to the movie that his friends recommended, it started too late. C. The professor enjoyed reading, cycling, and listening to jazz...

  • Grammar & Writing Style Which sentence communicates most concisely? If I am right, then we need...

    Grammar & Writing Style Which sentence communicates most concisely? If I am right, then we need to be innovative in our search for new solutions. If I am right about this being the case, then we as individuals need to be creative and innovative in our search for new solutions. Which of the following sentences should be rewritten in active voice? The experiment was first conducted at Yale University in the 1970s. The gold medal was won by gymnast Peter...

  • For this project, you are tasked with creating a text-based, basic String processing program that performs...

    For this project, you are tasked with creating a text-based, basic String processing program that performs basic search on a block of text inputted into your program from an external .txt file. After greeting your end user for a program description, your program should prompt the end user to enter a .txt input filename from which to read the block of text to analyze. Then, prompt the end user for a search String. Next, prompt the end user for the...

  • point out the topic sentence in the following paragraph;identify those paragraphs that also contain concluding sentence...

    point out the topic sentence in the following paragraph;identify those paragraphs that also contain concluding sentence 97%C4) Help Tue 10:46 PM ww Q Ang.cengage.com Mind Tap - Cengage Learning CENGAGE MINDTAP Q Search this course apter 3: The Body Paragraphs į AA B . A. Point out the topic sentences in the following paragraphs, identify those paragraphs that also contain concluding sentences. Cross out any stray topic sentences that belong elsewhere. 1. Denim is one of America's most widely used...

  • 1 Overview and Background Many of the assignments in this course will introduce you to topics in ...

    1 Overview and Background Many of the assignments in this course will introduce you to topics in computational biology. You do not need to know anything about biology to do these assignments other than what is contained in the description itself. The objective of each assignment is for you to acquire certain particular skills or knowledge, and the choice of topic is independent of that objective. Sometimes the topics will be related to computational problems in biology, chemistry, or physics,...

  • Tokeniser in C++

    TokenisersBackgroundThe primary task of any language translator is to work out how the structure and meaning of an input in a given language so that an appropriate translation can be output in another language. If you think of this in terms of a natural language such as English. When you attempt to read a sentence you do not spend your time worrying about what characters there are, how much space is between the letters or where lines are broken. What...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT