/** * 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, Nif20.oliaCategory.getUri(), pos.getUri())); } for(LexicalCategory cat : posTag.value().getCategories()){ graph.add(new TripleImpl(segmentUri, Nif20.oliaCategory.getUri(), cat.getUri())); } } graph.add(new TripleImpl(segmentUri, Nif20.posTag.getUri(), lf.createTypedLiteral(posTag.value().getTag()))); //set the oliaConf //remove existing conf values (e.g. for a single word phrase) setOliaConf(graph, segmentUri, posTag); } } /**
/** * 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()))); } }
/** * 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()))); } }