Search in sources :

Example 21 with PosTag

use of org.apache.stanbol.enhancer.nlp.pos.PosTag in project stanbol by apache.

the class PosTagSupport method parse.

@Override
public PosTag parse(ObjectNode jValue, AnalysedText at) {
    PosTagInfo tagInfo = new PosTagInfo();
    JsonNode tag = jValue.path("tag");
    if (!tag.isTextual()) {
        throw new IllegalStateException("Unable to parse PosTag. The value of the " + "'tag' field MUST have a textual value (json: " + jValue + ")");
    }
    tagInfo.tag = tag.getTextValue();
    if (jValue.has("lc")) {
        tagInfo.categories = JsonUtils.parseEnum(jValue, "lc", LexicalCategory.class);
    } else {
        tagInfo.categories = EnumSet.noneOf(LexicalCategory.class);
    }
    if (jValue.has("pos")) {
        tagInfo.pos = JsonUtils.parseEnum(jValue, "pos", Pos.class);
    } else {
        tagInfo.pos = EnumSet.noneOf(Pos.class);
    }
    PosTag posTag = posTagCache.get(tagInfo);
    if (posTag == null) {
        posTag = new PosTag(tagInfo.tag, tagInfo.categories, tagInfo.pos);
        posTagCache.put(tagInfo, posTag);
    }
    return posTag;
}
Also used : PosTag(org.apache.stanbol.enhancer.nlp.pos.PosTag) Pos(org.apache.stanbol.enhancer.nlp.pos.Pos) JsonNode(org.codehaus.jackson.JsonNode) LexicalCategory(org.apache.stanbol.enhancer.nlp.pos.LexicalCategory)

Aggregations

PosTag (org.apache.stanbol.enhancer.nlp.pos.PosTag)21 Token (org.apache.stanbol.enhancer.nlp.model.Token)12 AnalysedText (org.apache.stanbol.enhancer.nlp.model.AnalysedText)8 TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)7 Sentence (org.apache.stanbol.enhancer.nlp.model.Sentence)6 LexicalCategory (org.apache.stanbol.enhancer.nlp.pos.LexicalCategory)6 PlainLiteralImpl (org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl)5 Chunk (org.apache.stanbol.enhancer.nlp.model.Chunk)5 IRI (org.apache.clerezza.commons.rdf.IRI)4 MorphoFeatures (org.apache.stanbol.enhancer.nlp.morpho.MorphoFeatures)4 NerTag (org.apache.stanbol.enhancer.nlp.ner.NerTag)4 EngineException (org.apache.stanbol.enhancer.servicesapi.EngineException)4 StringSource (org.apache.stanbol.enhancer.servicesapi.impl.StringSource)4 ArrayList (java.util.ArrayList)3 Graph (org.apache.clerezza.commons.rdf.Graph)3 CaseTag (org.apache.stanbol.enhancer.nlp.morpho.CaseTag)3 GenderTag (org.apache.stanbol.enhancer.nlp.morpho.GenderTag)3 NumberTag (org.apache.stanbol.enhancer.nlp.morpho.NumberTag)3 TenseTag (org.apache.stanbol.enhancer.nlp.morpho.TenseTag)3 VerbMoodTag (org.apache.stanbol.enhancer.nlp.morpho.VerbMoodTag)3