I am trying to use Stanford TokensRegex. However, I get an error in the string for matches (see Comment), it says (). Please do your best to help me. Below is my code:
String file = "A store has many branches. A manager may manage at most 2 branches.";
Properties props = new Properties();
props.put("annotators", "tokenize, ssplit, pos, lemma, ner, parse, dcoref");
StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
Annotation document = new Annotation(file);
pipeline.annotate(document);
List<CoreMap> sentences = document.get(CoreAnnotations.SentencesAnnotation.class);
for(CoreMap sentence: sentences) {
TokenSequencePattern pattern = TokenSequencePattern.compile("[]");
TokenSequenceMatcher matcher = pattern.getMatcher(sentence);
while( matcher.find()){
JOptionPane.showMessageDialog(rootPane, "It has been found");
}
}
source
share