List of usage examples for edu.stanford.nlp.ling Tag setTag
public void setTag(String tag)
From source file:org.hcmut.emr.taghelper.PosBuilding.java
License:Open Source License
@Override public Map<String, Tag> getTag(String sentence) { Map<String, Tag> result = new HashedMap(); Annotation document = new Annotation(sentence); StanfordCoreNLP pipeline = getPipeline(); pipeline.annotate(document);/* w w w . j a va 2 s . c om*/ List<CoreMap> sentences = document.get(SentencesAnnotation.class); for (CoreMap sen : sentences) { for (int index = 0; index < sen.get(TokensAnnotation.class).size(); index++) { CoreLabel token = sen.get(TokensAnnotation.class).get(index); String pos = token.get(PartOfSpeechAnnotation.class); Tag tag = new Tag(); tag.setTag(pos); result.put(token.originalText(), tag); } } return result; }