/** * Returns a textual summary of the given entity. * * @return */ public Map<OWLIndividual, String> getSummaries(Set<OWLIndividual> individuals, OWLClass nc, String namespace, double threshold, Cooccurrence cooccurrence, HardeningType hType) { Map<OWLIndividual, String> entity2Summaries = new HashMap<OWLIndividual, String>(); Map<OWLIndividual, List<NLGElement>> verbalize = verbalize(individuals, nc, namespace, threshold, cooccurrence, hType); for (Entry<OWLIndividual, List<NLGElement>> entry : verbalize.entrySet()) { OWLIndividual individual = entry.getKey(); List<NLGElement> elements = entry.getValue(); String summary = realize(elements); summary = summary.replaceAll("\\s?\\((.*?)\\)", ""); summary = summary.replace(" , among others,", ", among others,"); entity2Summaries.put(individual, summary); } return entity2Summaries; }
/** * Returns the most specific type of a given individual. * * @param ind * @return */ private OWLClass getMostSpecificType(OWLIndividual ind) { logger.debug("Getting the most specific type of " + ind); String query = String.format("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "select distinct ?type where {" + " <%s> a ?type ." + "?type rdfs:label []." // + "?type a owl:Class ." // too strict, thus currently omitted + "filter not exists {?subtype ^a <%s> ; rdfs:subClassOf ?type .filter(?subtype != ?type)}}", ind.toStringID(), ind.toStringID()); SortedSet<OWLClass> types = new TreeSet<OWLClass>(); QueryExecution qe = qef.createQueryExecution(query); ResultSet rs = qe.execSelect(); while (rs.hasNext()) { QuerySolution qs = rs.next(); if (qs.get("type").isURIResource()) { types.add(new OWLClassImpl(IRI.create(qs.getResource("type").getURI()))); } } qe.close(); // of more than one type exists, we have to choose one // TODO return types.first(); }
/** * Train on resources of a given class. * * @param filename * @param strategy * @param classname * @return */ public static R2VModel train(String filename, TfidfFEXStrategy strategy, String classname) { OWLOntology o = getOntology(filename); R2VModel model = new R2VModel(o, strategy); for(OWLIndividual ind : getIndividuals(classname, o)) { model.add(ind.asOWLNamedIndividual()); } model.stringFeatures(); model.normalize(); return model; }
/** * @param superclass * @param o * @return */ private static Set<OWLIndividual> getIndividuals(String superclass, OWLOntology o) { OWLReasoner reasoner = PelletReasonerFactory.getInstance() .createReasoner(o); Set<OWLNamedIndividual> instances = reasoner.getInstances( OWL.Class(IRI.create(superclass)), false).getFlattened(); // filter out all owl:sameAs instances... Set<OWLIndividual> ind = new TreeSet<>(); for (OWLNamedIndividual i : instances) { ind.add(i); } logger.info("|I| = " + ind.size()); logger.debug("I = " + ind); return ind; }
private Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> findProcesses(OWLNamedIndividual mf) { Map<OWLClass, Pair<OWLNamedIndividual, Set<OWLAnnotation>>> result = new HashMap<OWLClass, Pair<OWLNamedIndividual,Set<OWLAnnotation>>>(); Set<OWLObjectPropertyAssertionAxiom> axioms = model.getObjectPropertyAssertionAxioms(mf); for (OWLObjectPropertyAssertionAxiom axiom : axioms) { if (partOf.equals(axiom.getProperty()) && mf.equals(axiom.getSubject())) { // relevant axiom OWLIndividual bpCandidate = axiom.getObject(); if (bpCandidate.isNamed()) { final OWLNamedIndividual named = bpCandidate.asOWLNamedIndividual(); Set<OWLClass> bpTypes = getTypes(named); for (OWLClass bpType : bpTypes) { if (bpSet.contains(bpType) == false) { continue; } result.put(bpType, Pair.of(named, getAnnotations(axiom, named))); } } } } return result; }
/** * Extracts data manipulation service information from the ontology. * * @param service * service individual found in ontology. * @param ontology * searched ontology. * @return extracted data manipulation service. * @throws EntryCreationException * should any problems with extraction of data manipulation service information occur. */ private DataManipulationService extractService(OWLIndividual service, OWLOntology ontology) throws EntryCreationException { DataManipulationService dataManipulationService = new DataManipulationService(); Set<OWLIndividual> profiles = service.getObjectPropertyValues(ontologyManager.getOWLDataFactory() .getOWLObjectProperty(PRESENTS_PROPERTY_IRI), ontology); for (OWLIndividual profile : profiles) { String profilePath = profile.asOWLNamedIndividual().getIRI().getStart(); profilePath = profilePath.substring(0, profilePath.length() - 1); OWLOntology profileOntology = ontologyManager.getOntology(IRI.create(profilePath)); dataManipulationService.setIri(extractServiceIri(service)); dataManipulationService.setName(extractServiceName(profile, profileOntology)); dataManipulationService.setDescription(extractServiceDescription(profile, profileOntology)); dataManipulationService.setType(extractServiceType(profile, profileOntology)); } return dataManipulationService; }
public Boolean visit(OWLDatatypeDefinitionAxiom axiom) { reasoner.throwInconsistentOntologyExceptionIfNecessary(); if (!reasoner.isConsistent()) return true; if (reasoner.m_dlOntology.hasDatatypes()) { OWLDataFactory factory=reasoner.getDataFactory(); OWLIndividual freshIndividual=factory.getOWLAnonymousIndividual("fresh-individual"); OWLDataProperty freshDataProperty=factory.getOWLDataProperty(IRI.create("fresh-data-property")); OWLDataRange dataRange=axiom.getDataRange(); OWLDatatype dt=axiom.getDatatype(); OWLDataIntersectionOf dr1=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dataRange),dt); OWLDataIntersectionOf dr2=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dt),dataRange); OWLDataUnionOf union=factory.getOWLDataUnionOf(dr1,dr2); OWLClassExpression c=factory.getOWLDataSomeValuesFrom(freshDataProperty,union); OWLClassAssertionAxiom ax=factory.getOWLClassAssertionAxiom(c,freshIndividual); Tableau tableau=reasoner.getTableau(ax); return !tableau.isSatisfiable(true,true,null,null,null,null,null,ReasoningTaskDescription.isAxiomEntailed(axiom)); } else return false; }
/** * Extracts service type of described service. * * @param profile * profile individual found in ontology. * @param profileOntology * profile ontology. * @return type of service. * @throws EntryCreationException * should specified service type be incompatible. */ private ServiceType extractServiceType(OWLIndividual profile, OWLOntology profileOntology) throws EntryCreationException { Set<OWLClassExpression> types = profile.getTypes(profileOntology); for (OWLClassExpression type : types) { String fragment = type.asOWLClass().getIRI().getFragment(); if (ADV_DELIVERY.equals(fragment)) { return ServiceType.ADVANCED_DATA_DELIVERY; } else if (MIGRATION.equals(fragment)) { return ServiceType.DATA_MIGRATION; } else if (CONVERSION.equals(fragment)) { return ServiceType.DATA_CONVERSION; } else { throw new EntryCreationException("Unrecognized service type, malformed semantic descriptor."); } } throw new RuntimeException("Unrecognized service type."); }
/** * Finds the service address in the given WSDL using the information contained in semantic descriptor. * * @param ontology * currently browsed ontology. * @param technicalDesc * individual from the ontology representing technical descriptor. * @param techDescriptorUrl * location of technical descriptor. * @return URL specifying the service address (location). * @throws EntryCreationException * should any problems with parsing WSDL document occur. */ private String getServiceUrlFromWsdl(OWLOntology ontology, OWLIndividual technicalDesc, String techDescriptorUrl) throws EntryCreationException { Set<OWLIndividual> operationRefs = technicalDesc.getObjectPropertyValues(ontologyManager.getOWLDataFactory() .getOWLObjectProperty(IRI.create(WSDL_GROUNDING_PREFIX + "wsdlOperation")), ontology); for (OWLIndividual operationRef : operationRefs) { Set<OWLLiteral> operations = operationRef.getDataPropertyValues(ontologyManager.getOWLDataFactory() .getOWLDataProperty(IRI.create(WSDL_GROUNDING_PREFIX + "operation")), ontology); for (OWLLiteral operation : operations) { String[] split = operation.getLiteral().split("#"); String id = split[split.length - 1].trim(); String xpath = "//" + TechnicalNamespaceContext.WSDL_PREFIX + ":service/" + TechnicalNamespaceContext.WSDL_PREFIX + ":port/" + TechnicalNamespaceContext.WSDL_SOAP_PREFIX + ":address"; NodeList nodes = getNode(techDescriptorUrl, xpath); String path = findOperationUrl(techDescriptorUrl, nodes, id); return path; } } throw new EntryCreationException("Could not find location of the service specified in grounding."); }
/** * Finds the service address in the given WADL using the information contained in semantic descriptor. * * @param ontology * currently browsed ontology. * @param technicalDesc * individual from the ontology representing technical descriptor. * @param techDescriptorUrl * location of technical descriptor. * @return URL specifying the service address (location). * @throws EntryCreationException * should any problems with parsing WADL document occur. */ private String getServiceUrlFromWadl(OWLOntology ontology, OWLIndividual technicalDesc, String techDescriptorUrl) throws EntryCreationException { Set<OWLIndividual> resourceMethods = technicalDesc.getObjectPropertyValues(ontologyManager.getOWLDataFactory() .getOWLObjectProperty(IRI.create(WADL_GROUNDING_PREFIX + "wadlResourceMethod")), ontology); for (OWLIndividual resourceMethod : resourceMethods) { Set<OWLLiteral> resources = resourceMethod.getDataPropertyValues(ontologyManager.getOWLDataFactory() .getOWLDataProperty(IRI.create(WADL_GROUNDING_PREFIX + "resource")), ontology); for (OWLLiteral resource : resources) { String[] split = resource.getLiteral().split("#"); String id = split[split.length - 1].trim(); String xpath = "//" + TechnicalNamespaceContext.WADL_PREFIX + ":resource[@id='" + id + "']"; NodeList nodes = getNode(techDescriptorUrl, xpath); String path = constructUrl(nodes.item(0)); return path; } } throw new EntryCreationException("Could not find location of the service specified in grounding."); }
public void visit(OWLClassAssertionAxiom classAssertion) { OWLIndividual individual = classAssertion.getIndividual(); OWLClassExpression classExpression = classAssertion.getClassExpression(); if (!classExpression.isAnonymous()) { OWLClass namedClass = classExpression.asOWLClass(); writer.print(namedClass.getIRI().getFragment()); writer.print("("); writer.print(IRI.create(individual.toStringID()).getFragment()); writer.print(").\n"); } else { } }
public static void randomizeClassAssertions(OWLOntology ont, int num) { Set<OWLClassAssertionAxiom> caas = new HashSet<OWLClassAssertionAxiom>(); Set<OWLClassAssertionAxiom> caasNew = new HashSet<OWLClassAssertionAxiom>(); Set<OWLNamedIndividual> inds = ont.getIndividualsInSignature(Imports.INCLUDED); OWLNamedIndividual[] indArr = (OWLNamedIndividual[]) inds.toArray(); for (OWLNamedIndividual ind : inds) { caas.addAll( ont.getClassAssertionAxioms(ind) ); } for (OWLClassAssertionAxiom caa : caas) { OWLIndividual randomIndividual = null; caasNew.add(ont.getOWLOntologyManager().getOWLDataFactory().getOWLClassAssertionAxiom(caa.getClassExpression(), randomIndividual)); } ont.getOWLOntologyManager().removeAxioms(ont, caas); ont.getOWLOntologyManager().addAxioms(ont, caasNew); }
public static JComboBox getConceptSchemeComboBox(OWLEditorKit owlEditorKit) { final Comparator<OWLObject> comp = owlEditorKit.getModelManager().getOWLObjectComparator(); List<OWLIndividual> sorted; Collections.sort(sorted = new ArrayList<OWLIndividual>(getConceptSchemes(owlEditorKit)), new OWLObjectComparatorAdapter<OWLIndividual>(comp) { public int compare(OWLIndividual o1, OWLIndividual o2) { return super.compare(o1,o2); } }); JComboBox schemaBox = new JComboBox(sorted.toArray()); schemaBox.setRenderer(new OWLCellRendererSimple(owlEditorKit)); if(!getConceptSchemes(owlEditorKit).isEmpty()) { schemaBox.setSelectedIndex(0); } return schemaBox; }
public void visit(OWLObjectSomeValuesFrom object) { OWLClassExpression filler=object.getFiller(); if (filler instanceof OWLObjectOneOf) { for (OWLIndividual individual : ((OWLObjectOneOf)filler).getIndividuals()) { Variable z=nextZ(); m_bodyAtoms.add(Atom.create(getConceptForNominal(individual),z)); m_headAtoms.add(getRoleAtom(object.getProperty(),X,z)); } } else { LiteralConcept toConcept=getLiteralConcept(filler); Role onRole=getRole(object.getProperty()); AtLeastConcept atLeastConcept=AtLeastConcept.create(1,onRole,toConcept); if (!atLeastConcept.isAlwaysFalse()) m_headAtoms.add(Atom.create(atLeastConcept,X)); } }
public boolean isSatisfiable(OWLClassExpression classExpression) { checkPreConditions(classExpression); if (!isConsistent()) return false; if (classExpression instanceof OWLClass && m_atomicConceptHierarchy != null) { AtomicConcept concept = H((OWLClass) classExpression); HierarchyNode<AtomicConcept> node = m_atomicConceptHierarchy .getNodeForElement(concept); return node != m_atomicConceptHierarchy.getBottomNode(); } else { OWLDataFactory factory = getDataFactory(); OWLIndividual freshIndividual = factory .getOWLAnonymousIndividual("fresh-individual"); OWLClassAssertionAxiom assertClassExpression = factory .getOWLClassAssertionAxiom(classExpression, freshIndividual); Tableau tableau = getTableau(assertClassExpression); return tableau.isSatisfiable(true, null, null, null, null, null, ReasoningTaskDescription .isConceptSatisfiable(classExpression)); } }
protected boolean isReflexive(OWLObjectPropertyExpression propertyExpression) { checkPreConditions(propertyExpression); if (!m_isConsistent) return true; OWLDataFactory factory = getDataFactory(); OWLClass pseudoNominal = factory.getOWLClass(IRI .create("internal:pseudo-nominal")); OWLClassExpression allNotPseudoNominal = factory .getOWLObjectAllValuesFrom(propertyExpression, pseudoNominal.getObjectComplementOf()); OWLIndividual freshIndividual = factory .getOWLAnonymousIndividual("fresh-individual"); OWLAxiom pseudoNominalAssertion = factory.getOWLClassAssertionAxiom( pseudoNominal, freshIndividual); OWLAxiom allNotPseudoNominalAssertion = factory .getOWLClassAssertionAxiom(allNotPseudoNominal, freshIndividual); Tableau tableau = getTableau(pseudoNominalAssertion, allNotPseudoNominalAssertion); boolean result = tableau.isSatisfiable(true, null, null, null, null, null, new ReasoningTaskDescription(true, "symmetry of {0}", H(propertyExpression))); tableau.clearAdditionalDLOntology(); return !result; }
protected boolean isAsymmetric( OWLObjectPropertyExpression propertyExpression) { checkPreConditions(propertyExpression); if (!m_isConsistent) return true; OWLDataFactory factory = getDataFactory(); OWLIndividual freshIndividualA = factory .getOWLAnonymousIndividual("fresh-individual-A"); OWLIndividual freshIndividualB = factory .getOWLAnonymousIndividual("fresh-individual-B"); OWLAxiom assertion1 = factory.getOWLObjectPropertyAssertionAxiom( propertyExpression, freshIndividualA, freshIndividualB); OWLAxiom assertion2 = factory.getOWLObjectPropertyAssertionAxiom( propertyExpression.getInverseProperty(), freshIndividualA, freshIndividualB); Tableau tableau = getTableau(assertion1, assertion2); boolean result = tableau.isSatisfiable(true, null, null, null, null, null, new ReasoningTaskDescription(true, "asymmetry of {0}", H(propertyExpression))); tableau.clearAdditionalDLOntology(); return !result; }
/** * Params: id * @throws OWLOntologyCreationException * @throws OWLOntologyStorageException * @throws IOException * @throws OWLParserException */ public void getAxiomsCommand() throws OWLOntologyCreationException, OWLOntologyStorageException, IOException, OWLParserException { headerOWL(); boolean direct = getParamAsBoolean(Param.direct, false); OWLObject obj = this.resolveEntity(); LOG.info("finding axioms about: "+obj); Set<OWLAxiom> axioms = new HashSet<OWLAxiom>(); if (obj instanceof OWLClass) { axioms.addAll(graph.getSourceOntology().getAxioms((OWLClass)obj, Imports.EXCLUDED)); } if (obj instanceof OWLIndividual) { axioms.addAll(graph.getSourceOntology().getAxioms((OWLIndividual)obj, Imports.EXCLUDED)); } if (obj instanceof OWLObjectProperty) { axioms.addAll(graph.getSourceOntology().getAxioms((OWLObjectProperty)obj, Imports.EXCLUDED)); } for (OWLAxiom ax : axioms) { output(ax); } }
@Deprecated public void deleteFactCommand() throws IOException, OWLOntologyCreationException, OWLOntologyStorageException, UnknownOWLClassException { if (isHelp()) { info("generates ClassAssertion"); return; } OWLOntology ont = resolveOntology(Param.ontology); OWLIndividual i = resolveIndividual(Param.individualId); OWLIndividual j = resolveIndividual(Param.fillerId); OWLObjectProperty p = resolveObjectProperty(Param.propertyId); for (OWLObjectPropertyAssertionAxiom ax : ont.getAxioms(AxiomType.OBJECT_PROPERTY_ASSERTION)) { if (ax.getSubject().equals(i)) { if (p == null || ax.getProperty().equals(p)) { if (j == null || ax.getObject().equals(j)) { removeAxiom(ont, graph.getDataFactory().getOWLObjectPropertyAssertionAxiom(p, i, j)); } } } } String jsonStr = ""; response.getWriter().write(jsonStr); }
public Boolean visit(OWLDifferentIndividualsAxiom axiom) { // see OWL 2 Syntax, Sec 11.2 // No axiom in Ax of the following form contains anonymous individuals: // SameIndividual, DifferentIndividuals, NegativeObjectPropertyAssertion, and NegativeDataPropertyAssertion. ArrayList<OWLIndividual> list=new ArrayList<OWLIndividual>(axiom.getIndividuals()); for (OWLIndividual i : list) { if (i.isAnonymous()) { throw new IllegalArgumentException("OWLDifferentIndividualsAxiom axioms are not allowed to be used "+"with anonymous individuals (see OWL 2 Syntax Sec 11.2) but the axiom "+axiom+" cotains an anonymous individual. "); } } for (int i=0;i<list.size()-1;i++) { OWLNamedIndividual head=list.get(i).asOWLNamedIndividual(); for (int j=i+1;j<list.size();j++) { OWLNamedIndividual next=list.get(j).asOWLNamedIndividual(); if (!reasoner.hasType(head,factory.getOWLObjectComplementOf(factory.getOWLObjectOneOf(next)),false)) return Boolean.FALSE; } } return Boolean.TRUE; }
public void visit(OWLClassAssertionAxiom axiom) { if (axiom.getClassExpression().isOWLThing()) return; OWLIndividual node=axiom.getIndividual(); if (!node.isAnonymous()) { namedNodes.add(node.asOWLNamedIndividual()); } else { nodes.add(node.asOWLAnonymousIndividual()); if (nodelLabels.containsKey(node)) { nodelLabels.get(node).add(axiom.getClassExpression()); } else { Set<OWLClassExpression> label=new HashSet<OWLClassExpression>(); label.add(axiom.getClassExpression()); nodelLabels.put(node.asOWLAnonymousIndividual(),label); } } }
protected void makeHasPhenotypeInstancesDirect() { // x Type has_phenotype some C ==> x Type C LOG.info("x Type has_phenotype some C ==> x Type C"); OWLObjectProperty hasPhenotype = getOWLObjectPropertyViaOBOSuffix(HAS_PHENOTYPE); Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>(); Set<OWLAxiom> newAxioms = new HashSet<OWLAxiom>(); for (OWLClassAssertionAxiom caa : outputOntology.getAxioms(AxiomType.CLASS_ASSERTION)) { OWLClassExpression ex = caa.getClassExpression(); OWLIndividual i = caa.getIndividual(); if (ex instanceof OWLObjectSomeValuesFrom) { OWLObjectSomeValuesFrom svf = (OWLObjectSomeValuesFrom)ex; if (svf.getProperty().equals(hasPhenotype)) { rmAxioms.add(caa); newAxioms.add(getOWLDataFactory().getOWLClassAssertionAxiom(svf.getFiller(), i)); } } } LOG.info("making instances direct: +"+newAxioms.size()+ " -"+rmAxioms.size()); addAxiomsToOutput(newAxioms, false); removeAxiomsFromOutput(rmAxioms, false); }
public void render(OWLGraphEdge e) { OWLObject s = e.getSource(); OWLClassExpression x = (OWLClassExpression) graph.edgeToTargetExpression(e); OWLAxiom ax; if (s instanceof OWLClassExpression) { ax = graph.getDataFactory().getOWLSubClassOfAxiom((OWLClassExpression)s, x); } else if (s instanceof OWLIndividual) { ax = graph.getDataFactory().getOWLClassAssertionAxiom(x, (OWLIndividual) s); } else { ax = null; } if (ax != null) { stream.print(ax.toString()); } }
public SolrInputDocument collect(OWLObject obj, OWLGraphWrapper graph) { SolrInputDocument cls_doc = new SolrInputDocument(); // General for all ontology objects. cls_doc.addField("id", graph.getIdentifier(obj)); cls_doc.addField("label", graph.getLabel(obj)); cls_doc.addField("description", graph.getDef(obj)); if (obj instanceof OWLClass) collectClass(cls_doc, graph, (OWLClass)obj); else if (obj instanceof OWLIndividual) collectIndividual(cls_doc, (OWLIndividual)obj); else if (obj instanceof OWLProperty) collectProperty(cls_doc, (OWLProperty)obj); return cls_doc; }
@Override public void addToOntology() { OWLObjectProperty property = featurePool.getExclusiveProperty(":objectHasValueProperty"); OWLIndividual value = factory.getOWLNamedIndividual(":ObjectHasValue_Individual", pm); OWLObjectHasValue restriction = factory.getOWLObjectHasValue(property, value); OWLClass hasValue = featurePool.getExclusiveClass(":ObjectHasValue"); addAxiomToOntology(factory.getOWLSubClassOfAxiom(hasValue, restriction)); }
public Map<OWLIndividual, List<NLGElement>> verbalize(Set<OWLIndividual> individuals, OWLClass nc, String namespace, double threshold, Cooccurrence cooccurrence, HardeningType hType) { resource2Triples = new HashMap<Resource, Collection<Triple>>(); // first get graph for nc try { WeightedGraph wg = graphGenerator.generateGraph(nc, threshold, namespace, cooccurrence); // then cluster the graph BorderFlowX bf = new BorderFlowX(wg); Set<Set<Node>> clusters = bf.cluster(); // then harden the results List<Set<Node>> sortedPropertyClusters = HardeningFactory.getHardening(hType).harden(clusters, wg); // logger.info("Cluster = " + sortedPropertyClusters); Map<OWLIndividual, List<NLGElement>> verbalizations = new HashMap<OWLIndividual, List<NLGElement>>(); for (OWLIndividual ind : individuals) { // finally generateSentencesFromClusters List<NLGElement> result = generateSentencesFromClusters(sortedPropertyClusters, ResourceFactory.createResource(ind.toStringID()), nc, true); Triple t = Triple.create(ResourceFactory.createResource(ind.toStringID()).asNode(), ResourceFactory.createProperty(RDF.type.getURI()).asNode(), ResourceFactory.createResource(nc.toStringID()).asNode()); Collections.reverse(result); result.add(generateSimplePhraseFromTriple(t)); Collections.reverse(result); verbalizations.put(ind, result); resource2Triples.get(ResourceFactory.createResource(ind.toStringID())).add(t); } return verbalizations; } catch (NoGraphAvailableException e) { e.printStackTrace(); } return null; }
/** * Returns a textual summary of the given entity. * * @return */ public String summarize(OWLIndividual individual) { // compute the most specific type first OWLClass cls = getMostSpecificType(individual); // logger.info("cls" + cls.toString()); return summarize(individual, cls); }
/** * Returns a textual summary of the given entity. * * @return */ public String getSummary(OWLIndividual individual, OWLClass nc, double threshold, Cooccurrence cooccurrence, HardeningType hType) { List<NLGElement> elements = verbalize(individual, nc, null, threshold, cooccurrence, hType); String summary = realize(elements); summary = summary.replaceAll("\\s?\\((.*?)\\)", ""); summary = summary.replace(" , among others,", ", among others,"); return summary; }
private void getInvdividual2RDFType2ClassAxioms(OWLIndividual src, OWLClass dest) { // Set<OWLAxiom> tmpaxioms = new HashSet<OWLAxiom>(); OWLAxiom axiom; axiom = owlDataFactory.getOWLClassAssertionAxiom(dest, src); classAssertionAxioms.add(axiom); }
public OWLClassExpression visit(OWLObjectComplementOf object) { if (isNominal(object.getOperand())) { OWLObjectOneOf objectOneOf=(OWLObjectOneOf)object.getOperand(); OWLClass definition=getDefinitionForNegativeNominal(objectOneOf,m_alreadyExists); if (!m_alreadyExists[0]) { for (OWLIndividual individual : objectOneOf.getIndividuals()) { addFact(m_factory.getOWLClassAssertionAxiom(definition,individual)); } } return m_factory.getOWLObjectComplementOf(definition); } else return object; }
/** * return all individuals i where x is reachable from i * @param x * @return set of individual {@link OWLObject}s */ public Set<OWLObject> getIndividualDescendants(OWLObject x) { Set<OWLObject> descs = new HashSet<OWLObject>(); for (OWLGraphEdge e : getIncomingEdgesClosure(x)) { OWLObject s = e.getSource(); if (s instanceof OWLIndividual) descs.add(s); } return descs; }
public void visit(SWRLClassAtom atom) { if (!(atom.getArgument() instanceof SWRLIndividualArgument)) throw new IllegalArgumentException("A SWRL rule contains a head atom "+atom+" with a variable that does not occur in the body. "); OWLIndividual ind=((SWRLIndividualArgument)atom.getArgument()).getIndividual(); if (ind.isAnonymous()) throwAnonIndError(atom); if (!isSimple(atom.getPredicate())) { OWLClassExpression definition=getDefinitionFor(atom.getPredicate(),m_alreadyExists); if (!m_alreadyExists[0]) m_newInclusions.add(new OWLClassExpression[] { negative(definition),atom.getPredicate() }); addFact(m_factory.getOWLClassAssertionAxiom(definition,ind.asOWLNamedIndividual())); } else addFact(m_factory.getOWLClassAssertionAxiom(atom.getPredicate(),ind.asOWLNamedIndividual())); }
/** * Adds a ClassAssertion, where the class expression instantiated is an * ObjectSomeValuesFrom expression * * Example: Individual: i Type: enabledBy some PRO_123 * * @param model * @param i * @param p * @param filler * @param metadata */ void addType(ModelContainer model, OWLIndividual i, OWLObjectPropertyExpression p, OWLClassExpression filler, METADATA metadata) { if (LOG.isDebugEnabled()) { LOG.debug("Adding "+i+ " type "+p+" some "+filler); } OWLDataFactory f = model.getOWLDataFactory(); OWLObjectSomeValuesFrom c = f.getOWLObjectSomeValuesFrom(p, filler); OWLClassAssertionAxiom axiom = f.getOWLClassAssertionAxiom(c, i); addAxiom(model, axiom, metadata); }
/** * remove ClassAssertion(c,i) from the model * * @param model * @param i * @param ce * @param metadata */ public void removeType(ModelContainer model, OWLIndividual i, OWLClassExpression ce, METADATA metadata) { Set<OWLClassAssertionAxiom> allAxioms = model.getAboxOntology().getClassAssertionAxioms(i); // use search to remove also axioms with annotations for (OWLClassAssertionAxiom ax : allAxioms) { if (ce.equals(ax.getClassExpression())) { removeAxiom(model, ax, metadata); } } }
void removeType(ModelContainer model, OWLIndividual i, OWLObjectPropertyExpression p, OWLClassExpression filler, METADATA metadata) { OWLDataFactory f = model.getOWLDataFactory(); OWLClassAssertionAxiom axiom = f.getOWLClassAssertionAxiom(f.getOWLObjectSomeValuesFrom(p, filler), i); removeAxiom(model, axiom, metadata); }