本文整理匯總了Java中org.semanticweb.owlapi.model.OWLClassExpression.asOWLClass方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLClassExpression.asOWLClass方法的具體用法?Java OWLClassExpression.asOWLClass怎麽用?Java OWLClassExpression.asOWLClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLClassExpression
的用法示例。
在下文中一共展示了OWLClassExpression.asOWLClass方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: handleIntersection
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
private void handleIntersection(List<CheckWarning> warnings, Set<OWLOntology> allOntologies,
OWLEquivalentClassesAxiom axiom, OWLObjectIntersectionOf intersection, OWLPrettyPrinter pp)
{
for(OWLClassExpression operand : intersection.getOperandsAsList()) {
OWLClass operandCls = null;
if (!operand.isAnonymous()) {
operandCls = operand.asOWLClass();
}
else if (operand instanceof OWLObjectSomeValuesFrom) {
OWLObjectSomeValuesFrom ristriction = (OWLObjectSomeValuesFrom) operand;
OWLClassExpression filler = ristriction.getFiller();
if (!filler.isAnonymous()) {
operandCls = filler.asOWLClass();
}
}
else {
// not translatable to OBO
handleGeneric(warnings, allOntologies, axiom, operand, pp);
}
if (operandCls != null && isDangling(operandCls, allOntologies)) {
final IRI iri = operandCls.getIRI();
String message = "Dangling reference "+iri+" in INTERSECTION_OF axiom: "+pp.render(axiom);
warnings.add(new CheckWarning(getID(), message , isFatal(), iri, OboFormatTag.TAG_INTERSECTION_OF.getTag()));
}
}
}
示例2: handleUnionOf
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
private void handleUnionOf(List<CheckWarning> warnings, Set<OWLOntology> allOntologies,
OWLEquivalentClassesAxiom axiom, OWLObjectUnionOf union, OWLPrettyPrinter pp)
{
List<OWLClassExpression> operands = union.getOperandsAsList();
for(OWLClassExpression operand : operands) {
if (!operand.isAnonymous()) {
OWLClass operandCls = operand.asOWLClass();
if (isDangling(operandCls, allOntologies)) {
final IRI iri = operandCls.getIRI();
String message = "Dangling reference "+iri+" in UNION_OF axiom: "+pp.render(axiom);
warnings.add(new CheckWarning(getID(), message , isFatal(), iri, OboFormatTag.TAG_UNION_OF.getTag()));
}
}
else {
// not translatable to OBO
handleGeneric(warnings, allOntologies, axiom, operand, pp);
}
}
}
示例3: visit
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
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 {
}
}
示例4: generateNewIRI
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
private IRI generateNewIRI(String type, OWLClassExpression ce) {
if( ce.isAnonymous() == false) {
OWLClass c = ce.asOWLClass();
String id = StringUtils.replace(curieHandler.getCuri(c), ":", "_");
type = type + "-" + id;
}
return IRI.create("http://geneontology.org/lego/"+type+"-"+UUID.randomUUID().toString());
}
示例5: getTypes
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
private Set<OWLClass> getTypes(OWLNamedIndividual i, OWLOntology model) {
Set<OWLClassAssertionAxiom> axioms = model.getClassAssertionAxioms(i);
Set<OWLClass> types = new HashSet<OWLClass>();
for (OWLClassAssertionAxiom axiom : axioms) {
OWLClassExpression ce = axiom.getClassExpression();
if (ce instanceof OWLClass) {
OWLClass cls = ce.asOWLClass();
if (cls.isBuiltIn() == false) {
types.add(cls);
}
}
}
return types;
}
示例6: getInstances
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
public NodeSet<OWLNamedIndividual> getInstances(OWLClassExpression ce, boolean direct) throws InconsistentOntologyException, ClassExpressionNotInProfileException, FreshEntitiesException, ReasonerInterruptedException, TimeOutException {
ensurePrepared();
DefaultNodeSet<OWLNamedIndividual> result = new OWLNamedIndividualNodeSet();
if (!ce.isAnonymous()) {
OWLClass cls = ce.asOWLClass();
Set<OWLClass> clses = new HashSet<OWLClass>();
clses.add(cls);
if (!direct) {
clses.addAll(getSubClasses(cls, false).getFlattened());
}
for (OWLOntology ontology : getRootOntology().getImportsClosure()) {
for (OWLClass curCls : clses) {
for (OWLClassAssertionAxiom axiom : ontology.getClassAssertionAxioms(curCls)) {
OWLIndividual individual = axiom.getIndividual();
if (!individual.isAnonymous()) {
if (getIndividualNodeSetPolicy().equals(IndividualNodeSetPolicy.BY_SAME_AS)) {
result.addNode(getSameIndividuals(individual.asOWLNamedIndividual()));
}
else {
result.addNode(new OWLNamedIndividualNode(individual.asOWLNamedIndividual()));
}
}
}
}
}
}
return result;
}
示例7: findFirstType
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
private OWLClass findFirstType(OWLNamedIndividual relevant) {
Set<OWLClassAssertionAxiom> axioms = model.getClassAssertionAxioms(relevant);
for (OWLClassAssertionAxiom axiom : axioms) {
OWLClassExpression ce = axiom.getClassExpression();
if (ce.isAnonymous() == false) {
return ce.asOWLClass();
}
}
return null;
}
示例8: updateRedundant
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
/**
* Update the set of redundant axioms for the given {@link OWLClass} cls.
*
* @param cls
* @param ontology
* @param redundantAxioms
* @param reasoner
* @param dataFactory
*/
protected static void updateRedundant(OWLClass cls, OWLOntology ontology, Set<OWLAxiom> redundantAxioms,
OWLReasoner reasoner, OWLDataFactory dataFactory)
{
final OWLClass owlThing = dataFactory.getOWLThing();
// get all direct super classes
final Set<OWLClass> direct = reasoner.getSuperClasses(cls, true).getFlattened();
direct.remove(owlThing);
// get all super classes (includes direct ones)
final Set<OWLClass> indirect = reasoner.getSuperClasses(cls, false).getFlattened();
indirect.remove(owlThing);
// remove direct super classes from all -> redundant super classes
indirect.removeAll(direct);
// rename
final Set<OWLClass> redundant = indirect;
// filter
// subclass of axioms, which have a super class in the redundant set
Set<OWLSubClassOfAxiom> axioms = ontology.getSubClassAxiomsForSubClass(cls);
for (OWLSubClassOfAxiom subClassOfAxiom : axioms) {
OWLClassExpression ce = subClassOfAxiom.getSuperClass();
if (!ce.isAnonymous()) {
OWLClass superClass = ce.asOWLClass();
if (redundant.contains(superClass)) {
redundantAxioms.add(subClassOfAxiom);
}
}
}
}
示例9: checkPotentialRedundantSubClassAxioms
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
/**
* Check all classes for potential redundant subClass axioms of type:
* <pre>
* A SubClassOf R some B
* and
* A SubClassOf B
* </pre>
*
* @return list of axiom pairs
*/
public List<PotentialRedundant> checkPotentialRedundantSubClassAxioms() {
List<PotentialRedundant> result = new ArrayList<PotentialRedundant>();
for(OWLClass cls : graph.getAllOWLClasses()) {
Set<OWLSubClassOfAxiom> axioms = graph.getAllOWLSubClassOfAxiomsForSubClass(cls);
if (axioms.size() > 1) {
// only check sets with more than one axiom
for (OWLSubClassOfAxiom main : axioms) {
OWLClassExpression mainSuperClassCE = main.getSuperClass();
if (mainSuperClassCE.isAnonymous()) {
continue;
}
OWLClass mainSuperClass = mainSuperClassCE.asOWLClass();
for (OWLSubClassOfAxiom current : axioms) {
if (main == current) {
continue;
}
OWLClassExpression currentSuperClass = current.getSuperClass();
if (currentSuperClass.isAnonymous() && currentSuperClass instanceof OWLObjectSomeValuesFrom) {
OWLObjectSomeValuesFrom someValuesFrom = (OWLObjectSomeValuesFrom) currentSuperClass;
final OWLClassExpression filler = someValuesFrom.getFiller();
if (mainSuperClass.equals(someValuesFrom.getFiller())) {
final OWLObjectPropertyExpression property = someValuesFrom.getProperty();
final OWLClassExpression subClass = current.getSubClass();
final PotentialRedundant redundant = new PotentialRedundant(main, current, subClass.asOWLClass(), property.asOWLObjectProperty(), filler.asOWLClass());
result.add(redundant);
}
}
}
}
}
}
if (!result.isEmpty()) {
return result;
}
return null;
}
示例10: visit
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
/**
* We assume that we deal with a normalized axioms, i.e. they are in NNF and structural transformation took place.
*
* Thereofre we test here whether the operand
* @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectComplementOf)
*/
public void visit(OWLObjectComplementOf objComplementOf) {
OWLClassExpression operand = objComplementOf.getOperand();
if (operand instanceof OWLClass) {
OWLClass owlClass = operand.asOWLClass();
String predicateName = mapper.getPredicateName(owlClass);
writer.print(predicateName);
writer.print(ASP2CoreSymbols.BRACKET_OPEN);
writer.print(var.currentVar());
writer.print(ASP2CoreSymbols.BRACKET_CLOSE);
if (isAuxiliaryClass(owlClass)) auxClasses.add(owlClass);
}
//
else if (operand instanceof OWLObjectHasSelf) {
OWLObjectHasSelf owlHasSelf = (OWLObjectHasSelf) operand;
OWLObjectProperty property = owlHasSelf.getProperty().asOWLObjectProperty();
String propertyName = mapper.getPredicateName(property);
String cVar = var.currentVar();
// r(X,X)
writer.print(propertyName);
writer.print(ASP2CoreSymbols.BRACKET_OPEN);
writer.print(cVar);
writer.print(ASP2CoreSymbols.ARG_SEPERATOR);
writer.print(cVar);
writer.print(ASP2CoreSymbols.BRACKET_CLOSE);
}
else if (operand instanceof OWLObjectOneOf) {
throw new NotImplementedException();
}
}
示例11: visit
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
/**
* We assume that we deal with a normalized axioms, i.e. they are in NNF and structural transformation took place.
*
* Thereofre we test here whether the operand
* @see org.semanticweb.owlapi.model.OWLClassExpressionVisitor#visit(org.semanticweb.owlapi.model.OWLObjectComplementOf)
*/
public void visit(OWLObjectComplementOf objComplementOf) {
OWLClassExpression operand = objComplementOf.getOperand();
if (operand instanceof OWLClass) {
OWLClass owlClass = operand.asOWLClass();
String predicateName = mapper.getPredicateName(owlClass);
writer.print(predicateName);
writer.print(ASP2CoreSymbols.BRACKET_OPEN);
writer.print(var.currentVar());
writer.print(ASP2CoreSymbols.BRACKET_CLOSE);
if (isAuxiliaryClass(owlClass)) auxClasses.add(owlClass);
}
else if (operand instanceof OWLObjectHasSelf) {
OWLObjectHasSelf owlHasSelf = (OWLObjectHasSelf) operand;
OWLObjectProperty property = owlHasSelf.getProperty().asOWLObjectProperty();
String propertyName = mapper.getPredicateName(property);
String cVar = var.currentVar();
// r(X,X)
writer.print(propertyName);
writer.print(ASP2CoreSymbols.BRACKET_OPEN);
writer.print(cVar);
writer.print(ASP2CoreSymbols.ARG_SEPERATOR);
writer.print(cVar);
writer.print(ASP2CoreSymbols.BRACKET_CLOSE);
}
else if (operand instanceof OWLObjectOneOf) {
throw new NotImplementedException();
}
}
示例12: expand
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
/**
* Create the GCIs for BioChEBI. Add the axioms into the given ontology.
*
* @param ontology
* @param ignoredClasses
*/
public void expand(OWLOntology ontology, Set<OWLClass> ignoredClasses) {
final OWLOntologyManager manager = ontology.getOWLOntologyManager();
final OWLDataFactory factory = manager.getOWLDataFactory();
// scan axioms
Set<OWLSubClassOfAxiom> axioms = ontology.getAxioms(AxiomType.SUBCLASS_OF, Imports.INCLUDED);
for (OWLSubClassOfAxiom axiom : axioms) {
OWLClassExpression superCE = axiom.getSuperClass();
OWLClassExpression subCE = axiom.getSubClass();
if (subCE.isAnonymous()) {
// sub class needs to be an named OWLClass
continue;
}
if (superCE instanceof OWLObjectSomeValuesFrom == false) {
continue;
}
OWLObjectSomeValuesFrom some = (OWLObjectSomeValuesFrom) superCE;
OWLObjectPropertyExpression expression = some.getProperty();
if (expression.isAnonymous()) {
// object property expression needs to be a named OWLObjectProperty
continue;
}
OWLObjectProperty p = (OWLObjectProperty) expression;
Set<OWLObjectProperty> expansions = expansionMap.get(p);
if (expansions == null) {
continue;
}
// get content for GCI
OWLClassExpression y = some.getFiller();
OWLClass x = subCE.asOWLClass();
if (ignoredClasses.contains(x)) {
continue;
}
for (OWLObjectProperty createProperty : expansions) {
OWLClassExpression ce1 = factory.getOWLObjectSomeValuesFrom(createProperty, x);
OWLClassExpression ce2 = factory.getOWLObjectSomeValuesFrom(createProperty, y);
OWLEquivalentClassesAxiom eq = factory.getOWLEquivalentClassesAxiom(ce1, ce2);
manager.addAxiom(ontology, eq);
}
}
Set<OWLOntology> imports = ontology.getImports();
StringBuilder sb = new StringBuilder();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
sb.append("Generated on ").append(dateFormat.format(new Date())).append(" using the following import chain:");
for (OWLOntology owlOntology : imports) {
OWLOntologyID ontologyID = owlOntology.getOntologyID();
sb.append(" ");
appendOntologyId(ontologyID, sb);
}
addComment(sb.toString(), ontology);
}
示例13: hasMatchingIntersection
import org.semanticweb.owlapi.model.OWLClassExpression; //導入方法依賴的package包/類
/**
* Search for the first class with a matching equivalent class definition.
*
* @param c
* @param genus
* @param relation
* @return match or null
*/
private OWLClass hasMatchingIntersection(OWLClass c, OWLClass genus, OWLObjectProperty relation) {
for(OWLOntology o : allOntologies) {
Set<OWLEquivalentClassesAxiom> eqAxioms = o.getEquivalentClassesAxioms(c);
for (OWLEquivalentClassesAxiom eqAxiom : eqAxioms) {
Set<OWLClassExpression> expressions = eqAxiom.getClassExpressionsMinus(c);
for (OWLClassExpression expression : expressions) {
if (expression instanceof OWLObjectIntersectionOf) {
OWLObjectIntersectionOf intersection = (OWLObjectIntersectionOf) expression;
OWLClass differentiaCls = null;
boolean matchesGenus = false;
boolean matchesRelation = false;
Set<OWLClassExpression> operands = intersection.getOperands();
if (operands.size() == 2) {
for (OWLClassExpression operand : operands) {
if (operand.isAnonymous() == false) {
OWLClass currentGenus = operand.asOWLClass();
if (genus.equals(currentGenus)) {
matchesGenus = true;
}
}
else if (operand instanceof OWLObjectSomeValuesFrom) {
OWLObjectSomeValuesFrom differentia = (OWLObjectSomeValuesFrom) operand;
if (relation.equals(differentia.getProperty())) {
matchesRelation = true;
OWLClassExpression filler = differentia.getFiller();
if (!filler.isAnonymous() && !filler.isOWLNothing() && !filler.isOWLThing()) {
differentiaCls = filler.asOWLClass();
}
}
}
}
if (matchesGenus && matchesRelation ) {
return differentiaCls;
}
}
}
}
}
}
return null;
}