List of usage examples for edu.stanford.nlp.coref.data Mention toString
@Override
public String toString()
From source file:sentimentanalysis.SentimentAnalysis.java
private static ArrayList<String> getAttributes(String twitter) throws IOException, ClassNotFoundException { ArrayList<String> attributes = new ArrayList<String>(); String[] sentences = SentenceDetect(twitter); Properties props = new Properties(); props.setProperty("annotators", "tokenize,ssplit,pos,lemma,ner,parse,mention,coref"); StanfordCoreNLP pipeline = new StanfordCoreNLP(props); for (String sentence : sentences) { Annotation document = new Annotation(sentence); pipeline.annotate(document);//www . j av a 2s .c om for (CoreMap sent : document.get(CoreAnnotations.SentencesAnnotation.class)) { for (Mention m : sent.get(CorefCoreAnnotations.CorefMentionsAnnotation.class)) { if (m.getRelation() == "verbArg") { ArrayList<String[]> POSResult = POSTag(m.toString()); PreProcess preprocessor = new PreProcess(); String TokenizedWord[] = preprocessor.tokenize(m.toString()); String[] ArrayOfTag = POSResult.get(0); for (int i = 0; i < ArrayOfTag.length; i++) { if (ArrayOfTag[i].length() > 2) { if (ArrayOfTag[i].substring(0, 2).equals("JJ") && (i + 1) < ArrayOfTag.length) { if (ArrayOfTag[i + 1].length() > 1) { if (ArrayOfTag[i + 1].substring(0, 2).equals("NN")) { String attr = TokenizedWord[i] + " " + TokenizedWord[i + 1]; attributes.add(attr); } } } if (ArrayOfTag[i].equals("NNS") && !TokenizedWord[i].toLowerCase().contains("https") && !TokenizedWord[i].contains("http")) { String attr = TokenizedWord[i]; attributes.add(attr); } } } } } } } return attributes; }