use of org.apache.stanbol.enhancer.nlp.pos.LexicalCategory in project stanbol by apache.
the class PhraseTagSupport method parse.
@Override
public PhraseTag parse(ObjectNode jValue, AnalysedText at) {
JsonNode tag = jValue.path("tag");
if (!tag.isTextual()) {
throw new IllegalStateException("Unable to parse PhraseTag. The value of the " + "'tag' field MUST have a textual value (json: " + jValue + ")");
}
JsonNode jCat = jValue.path("lc");
LexicalCategory lc = null;
if (jCat.isTextual()) {
try {
lc = LexicalCategory.valueOf(jCat.getTextValue());
} catch (IllegalArgumentException e) {
log.warn("Unable to parse category for PhraseTag from '" + jCat.getTextValue() + "' (will create with tag only)!", e);
}
} else if (jCat.isInt()) {
lc = LexicalCategory.values()[jCat.getIntValue()];
} else if (!jCat.isMissingNode()) {
log.warn("Unable to parse category for PhraseTag from " + jCat + "(will create with tag only)");
}
return new PhraseTag(tag.getTextValue(), lc);
}
use of org.apache.stanbol.enhancer.nlp.pos.LexicalCategory in project stanbol by apache.
the class CeliMorphoFeatures method featuresAsTriples.
public Collection<? extends Triple> featuresAsTriples(IRI textAnnotation, Language lang) {
Collection<TripleImpl> result = new Vector<TripleImpl>();
result.add(new TripleImpl(textAnnotation, CeliLemmatizerEnhancementEngine.hasLemmaForm, new PlainLiteralImpl(getLemma(), lang)));
for (PosTag pos : getPosList()) {
if (pos.isMapped()) {
for (LexicalCategory cat : pos.getCategories()) {
result.add(new TripleImpl(textAnnotation, RDF_TYPE, cat.getUri()));
}
}
}
for (NumberTag num : getNumberList()) {
if (num.getNumber() != null) {
result.add(new TripleImpl(textAnnotation, HAS_NUMBER, num.getNumber().getUri()));
}
}
for (Person pers : getPersonList()) {
result.add(new TripleImpl(textAnnotation, HAS_PERSON, pers.getUri()));
}
for (GenderTag gender : getGenderList()) {
if (gender.getGender() != null) {
result.add(new TripleImpl(textAnnotation, HAS_GENDER, gender.getGender().getUri()));
}
}
for (Definitness def : getDefinitnessList()) {
result.add(new TripleImpl(textAnnotation, HAS_DEFINITENESS, def.getUri()));
}
for (CaseTag caseFeat : getCaseList()) {
if (caseFeat.getCase() != null) {
result.add(new TripleImpl(textAnnotation, HAS_CASE, caseFeat.getCase().getUri()));
}
}
for (VerbMoodTag vf : getVerbMoodList()) {
if (vf.getVerbForm() != null) {
result.add(new TripleImpl(textAnnotation, HAS_MOOD, vf.getVerbForm().getUri()));
}
}
for (TenseTag tense : getTenseList()) {
if (tense.getTense() != null) {
result.add(new TripleImpl(textAnnotation, HAS_TENSE, tense.getTense().getUri()));
}
}
return result;
}
use of org.apache.stanbol.enhancer.nlp.pos.LexicalCategory in project stanbol by apache.
the class NIFHelper method writePos.
/**
* Writes the {@link NlpAnnotations#POS_ANNOTATION} as NIF 1.0 to the parsed
* RDF graph by using the parsed segmentUri as subject
* @param graph the graph
* @param annotated the annotated element (e.g. a {@link Token})
* @param segmentUri the URI of the resource representing the parsed
* annotated element in the graph
*/
public static void writePos(Graph graph, Annotated annotated, IRI segmentUri) {
Value<PosTag> posTag = annotated.getAnnotation(NlpAnnotations.POS_ANNOTATION);
if (posTag != null) {
if (posTag.value().isMapped()) {
for (Pos pos : posTag.value().getPos()) {
graph.add(new TripleImpl(segmentUri, SsoOntology.oliaLink.getUri(), pos.getUri()));
}
for (LexicalCategory cat : posTag.value().getCategories()) {
graph.add(new TripleImpl(segmentUri, SsoOntology.oliaLink.getUri(), cat.getUri()));
}
}
graph.add(new TripleImpl(segmentUri, SsoOntology.posTag.getUri(), lf.createTypedLiteral(posTag.value().getTag())));
graph.add(new TripleImpl(segmentUri, ENHANCER_CONFIDENCE, lf.createTypedLiteral(posTag.probability())));
}
}
Aggregations