public PosTag(String tag,Collection<LexicalCategory> categories, Collection<Pos> pos, boolean copy){ super(tag); if(copy){ this.pos = EnumSet.noneOf(Pos.class); if(pos != null){ this.pos.addAll(pos); } } else { this.pos = (EnumSet<Pos>)pos; } if(copy){ this.category = EnumSet.noneOf(LexicalCategory.class); if(categories != null){ this.category.addAll(categories); } } else { this.category = (EnumSet<LexicalCategory>)categories; } //and the union over the pos parents this.posHierarchy = EnumSet.noneOf(Pos.class); for(Pos p : this.pos){ this.posHierarchy.addAll(p.hierarchy()); this.category.addAll(p.categories()); } } /**
Pos(String name, LexicalCategory category, LexicalCategory additional) { this.uri = new IRI(OLIA_NAMESPACE + (name == null ? name() : name)); categories = EnumSet.of(category); if (additional != null) { categories.add(additional); } parents = Collections.emptySet(); }
jPosTag.put("tag", value.getTag()); if(value.getPos().size() == 1){ jPosTag.put("pos",value.getPos().iterator().next().ordinal()); } else if(!value.getPos().isEmpty()){ ArrayNode jPos = mapper.createArrayNode(); for(Pos pos : value.getPos()){ jPos.add(pos.ordinal()); categories.addAll(value.getCategories()); for(Pos pos : value.getPos()){ categories.removeAll(pos.categories());
/** * 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); } } /**
jPosTag.put("tag", value.getTag()); if(value.getPos().size() == 1){ jPosTag.put("pos",value.getPos().iterator().next().ordinal()); } else if(!value.getPos().isEmpty()){ ArrayNode jPos = mapper.createArrayNode(); for(Pos pos : value.getPos()){ jPos.add(pos.ordinal()); categories.addAll(value.getCategories()); for(Pos pos : value.getPos()){ categories.removeAll(pos.categories());
/** * 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()))); } }
Pos(String name, LexicalCategory category, LexicalCategory additional) { this.uri = new IRI(OLIA_NAMESPACE + (name == null ? name() : name)); categories = EnumSet.of(category); if (additional != null) { categories.add(additional); } parents = Collections.emptySet(); }
public PosTag(String tag,Collection<LexicalCategory> categories, Collection<Pos> pos, boolean copy){ super(tag); if(copy){ this.pos = EnumSet.noneOf(Pos.class); if(pos != null){ this.pos.addAll(pos); } } else { this.pos = (EnumSet<Pos>)pos; } if(copy){ this.category = EnumSet.noneOf(LexicalCategory.class); if(categories != null){ this.category.addAll(categories); } } else { this.category = (EnumSet<LexicalCategory>)categories; } //and the union over the pos parents this.posHierarchy = EnumSet.noneOf(Pos.class); for(Pos p : this.pos){ this.posHierarchy.addAll(p.hierarchy()); this.category.addAll(p.categories()); } } /**
/** * 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()))); } }
Pos(String name, LexicalCategory category, Pos... parent) { this.uri = new IRI(OLIA_NAMESPACE + (name == null ? name() : name)); this.parents = parent == null || parent.length < 1 ? Collections.EMPTY_SET : Arrays.asList(parent); categories = category == null ? EnumSet.noneOf(LexicalCategory.class) : EnumSet.of(category); Set<Pos> toProcess = new HashSet<Pos>(parents); while (!toProcess.isEmpty()) { Iterator<Pos> it = toProcess.iterator(); Pos p = it.next(); it.remove(); categories.addAll(p.categories); toProcess.addAll(p.parents); } }
Pos(String name, LexicalCategory category, Pos... parent) { this.uri = new IRI(OLIA_NAMESPACE + (name == null ? name() : name)); this.parents = parent == null || parent.length < 1 ? Collections.EMPTY_SET : Arrays.asList(parent); categories = category == null ? EnumSet.noneOf(LexicalCategory.class) : EnumSet.of(category); Set<Pos> toProcess = new HashSet<Pos>(parents); while (!toProcess.isEmpty()) { Iterator<Pos> it = toProcess.iterator(); Pos p = it.next(); it.remove(); categories.addAll(p.categories); toProcess.addAll(p.parents); } }