private void setupTagHandlers() { handlerMap = new HashMap<String, TagValueHandler>(); addTagHandler(new IDTagValueHandler(this)); addTagHandler(new NameTagValueHandler(this)); addTagHandler(new IsATagValueHandler(this)); addTagHandler(new PartOfTagValueHandler(this)); addTagHandler(new TransitiveTagValueHandler(this)); addTagHandler(new SymmetricTagValueHandler(this)); addTagHandler(new RelationshipTagValueHandler(this)); addTagHandler(new UnionOfHandler(this)); addTagHandler(new IntersectionOfHandler(this)); addTagHandler(new DisjointFromHandler(this)); addTagHandler(new AsymmetricHandler(this)); addTagHandler(new InverseHandler(this)); addTagHandler(new ReflexiveHandler(this)); addTagHandler(new TransitiveOverHandler(this)); addTagHandler(new DefaultNamespaceTagValueHandler(this)); }
private void createIntersectionEquivalentClass() { OWLClassExpression equivalentClass; if (intersectionOfOperands.size() == 1) { equivalentClass = intersectionOfOperands.iterator().next(); } else { equivalentClass = getDataFactory().getOWLObjectIntersectionOf(intersectionOfOperands); } createEquivalentClass(equivalentClass); }
public void endFrame() { if (!unionOfOperands.isEmpty()) { createUnionEquivalentClass(); unionOfOperands.clear(); } if (!intersectionOfOperands.isEmpty()) { createIntersectionEquivalentClass(); intersectionOfOperands.clear(); } }
public OWLEntity getCurrentEntity() { if (isTerm()) { return getCurrentClass(); } else if (isTypedef()) { return getDataFactory().getOWLObjectProperty(getIRI(currentId)); } else { return getDataFactory().getOWLNamedIndividual(getIRI(currentId)); } }
private void createEquivalentClass(OWLClassExpression classExpression) { OWLAxiom ax = getDataFactory().getOWLEquivalentClassesAxiom(CollectionFactory.createSet(getCurrentClass(), classExpression)); getOWLOntologyManager().applyChange(new AddAxiom(ontology, ax)); }
public void handle(String currentId, String value, String qualifierBlock, String comment) { if (currentId == null) { return; } OWLAnnotation xrefAnnotation = getConsumer().parseXRef(value); IRI subject = getIRIFromOBOId(currentId); OWLAnnotationAssertionAxiom ax = getDataFactory().getOWLAnnotationAssertionAxiom(xrefAnnotation.getProperty(), subject, xrefAnnotation.getValue()); applyChange(new AddAxiom(getOntology(), ax)); if(getConsumer().isTypedef() && xrefAnnotation.getValue() instanceof IRI) { IRI xrefIRI = (IRI) xrefAnnotation.getValue(); String typedefId = getConsumer().getCurrentId(); getConsumer().addSymbolicIdMapping(typedefId, xrefIRI); } }
public void handle(String id, String value) { getConsumer().setCurrentId(value); final OWLEntity entity = getConsumer().getCurrentEntity(); if (entity != null){ applyChange(new AddAxiom(getOntology(), getDataFactory().getOWLDeclarationAxiom(entity))); } } }
public OWLClass getCurrentClass() { return getDataFactory().getOWLClass(getIRIFromValue(consumer.getCurrentId())); }
@Override public void handle(String currentId, String value, String qualifierBlock, String comment) { Matcher matcher = valuePattern.matcher(value); if(matcher.matches()) { OWLDataFactory df = getDataFactory(); OWLAnnotationProperty property = getSynonymAnnotationProperty(matcher); Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>(); annotations.addAll(getSynonymTypeAnnotations(matcher)); annotations.addAll(getXRefAnnotations(matcher)); OWLEntity subject = getConsumer().getCurrentEntity(); String synonym = matcher.group(VALUE_GROUP); OWLLiteral synonymLiteral = df.getOWLLiteral(synonym); OWLAnnotationAssertionAxiom annoAssertion = df.getOWLAnnotationAssertionAxiom(property, subject.getIRI(), synonymLiteral, annotations); applyChange(new AddAxiom(getOntology(), annoAssertion)); } }
OBOConsumer oboConsumer = new OBOConsumer(ontology, configuration, documentSource.getDocumentIRI()); parser.setHandler(rawFrameHandler); try { format.setIDSpaceManager(oboConsumer.getIdSpaceManager()); return format;
@Override public void handle(String currentId, String value, String qualifierBlock, String comment) { getConsumer().addUnionOfOperand(getOWLClassOrRestriction(value)); } }
public void handle(String id, String value) { getConsumer().addIntersectionOfOperand(getOWLClassOrRestriction(value)); } }
public OWLOntologyFormat parse(OWLOntologyDocumentSource documentSource, OWLOntology ontology) throws OWLParserException, IOException { OBOParser parser; if (documentSource.isReaderAvailable()) { parser = new OBOParser(documentSource.getReader()); } else if (documentSource.isInputStreamAvailable()) { parser = new OBOParser(documentSource.getInputStream()); } else { parser = new OBOParser(getInputStream(documentSource.getDocumentIRI())); } parser.setHandler(new OBOConsumer(getOWLOntologyManager(), ontology)); try { parser.parse(); } catch (ParseException e) { throw new OWLParserException(e, e.currentToken.beginLine, e.currentToken.beginColumn); } catch(TokenMgrError e) { throw new OWLParserException(e); } return new OBOOntologyFormat(); } }
public OWLEntity getCurrentEntity() { if (isTerm()) { return getCurrentClass(); } else if (isTypedef()) { // Sometimes, we can have symbolic names e.g. has_part. It's not really clear how to tell the difference IRI propertyIRI = getRelationIRIFromSymbolicIdOrOBOId(currentId); return getDataFactory().getOWLObjectProperty(propertyIRI); } else { return getDataFactory().getOWLNamedIndividual(getIRI(currentId)); } }
private void createEquivalentClass(OWLClassExpression classExpression) { OWLAxiom ax = getDataFactory().getOWLEquivalentClassesAxiom(CollectionFactory.createSet(getCurrentClass(), classExpression)); getOWLOntologyManager().applyChange(new AddAxiom(ontology, ax)); }
@Override public void handle(String currentId, String value, String qualifierBlock, String comment) { if (currentId == null) { return; } OWLAnnotation xrefAnnotation = getConsumer().parseXRef(value); IRI subject = getIRIFromOBOId(currentId); OWLAnnotationAssertionAxiom ax = getDataFactory().getOWLAnnotationAssertionAxiom(xrefAnnotation.getProperty(), subject, xrefAnnotation.getValue()); applyChange(new AddAxiom(getOntology(), ax)); if(getConsumer().isTypedef() && xrefAnnotation.getValue() instanceof IRI) { IRI xrefIRI = (IRI) xrefAnnotation.getValue(); String typedefId = getConsumer().getCurrentId(); getConsumer().addSymbolicIdMapping(typedefId, xrefIRI); } }
@Override public void handle(String currentId, String value, String qualifierBlock, String comment) { getConsumer().setCurrentId(value); final OWLEntity entity = getConsumer().getCurrentEntity(); if (entity != null){ applyChange(new AddAxiom(getOntology(), getDataFactory().getOWLDeclarationAxiom(entity))); } } }
public OWLClass getCurrentClass() { return getDataFactory().getOWLClass(getIRIFromOBOId(consumer.getCurrentId())); }
public void handle(String currentId, String value, String qualifierBlock, String comment) { Matcher matcher = valuePattern.matcher(value); if(matcher.matches()) { OWLDataFactory df = getDataFactory(); OWLAnnotationProperty property = getSynonymAnnotationProperty(matcher); Set<OWLAnnotation> annotations = new HashSet<OWLAnnotation>(); annotations.addAll(getSynonymTypeAnnotations(matcher)); annotations.addAll(getXRefAnnotations(matcher, df)); OWLEntity subject = getConsumer().getCurrentEntity(); String synonym = matcher.group(VALUE_GROUP); OWLLiteral synonymLiteral = df.getOWLLiteral(synonym); OWLAnnotationAssertionAxiom annoAssertion = df.getOWLAnnotationAssertionAxiom(property, subject.getIRI(), synonymLiteral, annotations); applyChange(new AddAxiom(getOntology(), annoAssertion)); } }
OBOConsumer oboConsumer = new OBOConsumer(ontology, configuration, documentSource.getDocumentIRI()); parser.setHandler(rawFrameHandler); try { return new OBOOntologyFormat(oboConsumer.getIdSpaceManager());