本文整理匯總了Java中org.semanticweb.owlapi.model.OWLClassExpression類的典型用法代碼示例。如果您正苦於以下問題:Java OWLClassExpression類的具體用法?Java OWLClassExpression怎麽用?Java OWLClassExpression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
OWLClassExpression類屬於org.semanticweb.owlapi.model包,在下文中一共展示了OWLClassExpression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createIndividualInternal
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
private static Pair<OWLNamedIndividual, Set<OWLAxiom>> createIndividualInternal(IRI iri, OWLOntology abox, OWLClassExpression ce, Set<OWLAnnotation> annotations) {
LOG.info("Generating individual for IRI: "+iri);
OWLDataFactory f = abox.getOWLOntologyManager().getOWLDataFactory();
OWLNamedIndividual i = f.getOWLNamedIndividual(iri);
// create axioms
Set<OWLAxiom> axioms = new HashSet<OWLAxiom>();
// declaration
axioms.add(f.getOWLDeclarationAxiom(i));
// annotation assertions
if(annotations != null) {
for(OWLAnnotation annotation : annotations) {
axioms.add(f.getOWLAnnotationAssertionAxiom(iri, annotation));
}
}
if (ce != null) {
OWLClassAssertionAxiom typeAxiom = createType(f, i, ce);
if (typeAxiom != null) {
axioms.add(typeAxiom);
}
}
return Pair.of(i, axioms);
}
示例2: replace
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
/**
* Replace inx using m
*
* @param inx
* @param m
* @return
*/
private OWLClassExpression replace(OWLClassExpression inx,
Mapping m) {
LOG.info("Testing: "+inx+" for mapping using "+m);
// test to see if there is a match between the src pattern in
// the mapping and the input expression
BindingSet bset = unifyAll(inx, m.src, m.vars);
if (bset == null) {
// no match
LOG.info("No match for: "+inx);
return null;
}
LOG.info("Unified. Bindings: "+bset);
return replaceVariables(inx, bset);
}
示例3: buildSimpleDefMap
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
private void buildSimpleDefMap() {
simpleDefMap = new HashMap<OWLClass,Set<OWLClassExpression>>();
OWLOntology o = getGraph().getSourceOntology();
for (OWLClass c : o.getClassesInSignature()) {
for (OWLEquivalentClassesAxiom eca : o.getEquivalentClassesAxioms(c)) {
Set<OWLClassExpression> elts = new HashSet<OWLClassExpression>();
for (OWLClassExpression x : eca.getClassExpressions()) {
// assume one logical definitionper class - otherwise choose arbitrary
if (x instanceof OWLObjectIntersectionOf) {
if (getReachableOWLClasses(x, elts) && elts.size() > 0) {
//LOG.info(c+" def= "+elts);
simpleDefMap.put(c, elts);
}
}
}
}
}
}
示例4: makeExpression
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
public Expression makeExpression(OWLClassExpression x) {
if (x.isAnonymous()) {
if (x instanceof OWLObjectIntersectionOf) {
return makeIntersectionOf((OWLObjectIntersectionOf)x);
}
else if (x instanceof OWLObjectSomeValuesFrom) {
return makeSomeValuesFrom((OWLObjectSomeValuesFrom)x);
}
else {
return null;
}
}
else {
return makeClassStub(x);
}
}
示例5: visit
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
@Override
public HandlerResult visit(OWLObjectMaxCardinality ce) {
if (ce.getCardinality() == 0) {
// remove the ce if the max cardinality is zero
return HandlerResult.remove();
}
final OWLClassExpression filler = ce.getFiller();
final HandlerResult recursive = filler.accept(this);
OWLObjectSomeValuesFrom newCE;
if (recursive == null) {
newCE = factory.getOWLObjectSomeValuesFrom(ce.getProperty(), filler);
}
else if (recursive.remove) {
return HandlerResult.remove();
}
else {
newCE = factory.getOWLObjectSomeValuesFrom(ce.getProperty(), recursive.modified);
}
return HandlerResult.modified(newCE);
}
示例6: 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()));
}
}
}
示例7: visit
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
public void visit(OWLDataPropertyAssertionAxiom axiom) {
if (!axiom.getSubject().isAnonymous()) {
return; // not interesting for the anonymous individual forest
}
OWLAnonymousIndividual sub=axiom.getSubject().asOWLAnonymousIndividual();
nodes.add(sub);
OWLClassExpression c=factory.getOWLDataHasValue(axiom.getProperty(),axiom.getObject());
if (nodelLabels.containsKey(sub)) {
nodelLabels.get(sub).add(c);
}
else {
Set<OWLClassExpression> labels=new HashSet<OWLClassExpression>();
labels.add(c);
nodelLabels.put(sub,labels);
}
}
示例8: getSuperClassExpressions
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
/**
* note that this is not a standard reasoner method
*
* @param ce
* @param direct
* @return all superclasses, where superclasses can include anon class expressions
* @throws InconsistentOntologyException
* @throws ClassExpressionNotInProfileException
* @throws FreshEntitiesException
* @throws ReasonerInterruptedException
* @throws TimeOutException
*/
public Set<OWLClassExpression> getSuperClassExpressions(OWLClassExpression ce,
boolean direct) throws InconsistentOntologyException,
ClassExpressionNotInProfileException, FreshEntitiesException,
ReasonerInterruptedException, TimeOutException {
Set<OWLClassExpression> result = new HashSet<OWLClassExpression>();
Set<OWLObject> supers = gw.getSubsumersFromClosure(ce);
for (OWLObject sup : supers) {
if (sup instanceof OWLClassExpression) {
result.add((OWLClassExpression) sup);
}
else {
}
}
return result;
}
示例9: findDescendants
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
protected Set<OWLClass> findDescendants(OWLReasoner r, String expr, Integer numExpected) throws TimeOutException, FreshEntitiesException, InconsistentOntologyException, ClassExpressionNotInProfileException, ReasonerInterruptedException, OWLParserException {
System.out.println("Query: "+expr);
OWLClassExpression qc = parseOMN(expr);
Set<OWLClass> clzs = r.getSubClasses(qc, false).getFlattened();
clzs.remove(r.getRootOntology().getOWLOntologyManager().getOWLDataFactory().getOWLNothing());
if (!qc.isAnonymous())
clzs.add((OWLClass) qc);
System.out.println("NumD:"+clzs.size());
for (OWLClass c : clzs) {
System.out.println(" D:"+c);
}
if (numExpected != null) {
assertEquals(numExpected.intValue(), clzs.size());
}
return clzs;
}
示例10: testParseClazzNoCheckLiteralIds
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
@Test
public void testParseClazzNoCheckLiteralIds() throws Exception {
JsonOwlObject expression = new JsonOwlObject();
expression.type = JsonOwlObjectType.Class;
expression.id = "GO:23"; // valid prefix, not a known class
// create a parser that explicitly disables checking so-called literal ids
OWLClassExpression ce = new M3ExpressionParser(false, curieHandler).parse(graph, expression, null);
// check the retrieved class is the same as the input
// note: we don't use the owltools getClass method directly, as that depends on the class
// being known
IRI iri = graph.getIRIByIdentifier("GO:23");
assertEquals(iri, ce.asOWLClass().getIRI());
}
示例11: getSuperClasses
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
public NodeSet<OWLClass> getSuperClasses(OWLClassExpression ce,
boolean direct) throws InconsistentOntologyException,
ClassExpressionNotInProfileException, FreshEntitiesException,
ReasonerInterruptedException, TimeOutException {
DefaultNodeSet<OWLClass> result = new OWLClassNodeSet();
Set<OWLObject> supers = gw.getSubsumersFromClosure(ce);
for (OWLObject sup : supers) {
if (sup instanceof OWLClassExpression) {
if (sup instanceof OWLClass) {
result.addEntity((OWLClass) sup);
}
else {
}
}
else {
}
}
return result;
}
示例12: getOneOfAuxiliaryClass
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
/**
* For a One-of Object {a,b,c,...} create and auxiliary class oo1, and
* and axiom <code>oo1 subSetOf guard_i_a or guard_i_b or ...</code>
* @param objectOneOf
* @return
*/
private OWLClass getOneOfAuxiliaryClass(OWLObjectOneOf objectOneOf) {
if (oneOfAuxClasses.containsKey(objectOneOf))
return oneOfAuxClasses.get(objectOneOf);
OWLClass auxOneOf = new OWLClassImpl(IRI.create(INTERNAL_IRI_PREFIX + "#oneOfaux" + (oneOfAuxClasses.size()+1)));
OWLClassExpression[] inclusion = new OWLClassExpression[2];
inclusion[0] = new OWLObjectComplementOfImpl(auxOneOf);
inclusion[1] = objectOneOf;
//translateInclusion(inclusion);
newInclusions.add(inclusion);
// add to the set of class which needs to be guessed
// auxClasses.add(auxOneOf);
oneOfAuxClasses.put(objectOneOf, auxOneOf);
return auxOneOf;
}
示例13: visit
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
public OWLClassExpression visit(OWLObjectOneOf object) {
//CHANGED
OWLClass definition=getDefinitionForNegativeNominal(object,m_alreadyExists);
if (!m_alreadyExists[0]) {
for (OWLIndividual individual : object.getIndividuals()) {
addFact(m_factory.getOWLClassAssertionAxiom(definition,individual));
}
}
return definition;
/*
for (OWLIndividual ind : object.getIndividuals())
if (ind.isAnonymous())
throw new IllegalArgumentException("Error: The class expression "+object+" contains anonymous individuals, which is not allowed in OWL 2 (erratum in first OWL 2 spec, to be fixed with next publication of minor corrections). ");
return object;
*/
}
示例14: parse
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
static OWLClassExpression parse(OWLGraphWrapper g, JsonOwlObject[] expressions, JsonOwlObjectType type)
throws Exception {
if (expressions.length == 0) {
throw new Exception("Missing expressions: empty expression list is not allowed.");
}
if (expressions.length == 1) {
return parse(g, expressions[0]);
}
Set<OWLClassExpression> clsExpressions = new HashSet<OWLClassExpression>();
for (JsonOwlObject m3Expression : expressions) {
OWLClassExpression ce = parse(g, m3Expression);
clsExpressions.add(ce);
}
if (type == JsonOwlObjectType.UnionOf) {
return g.getDataFactory().getOWLObjectUnionOf(clsExpressions);
}
else if (type == JsonOwlObjectType.IntersectionOf) {
return g.getDataFactory().getOWLObjectIntersectionOf(clsExpressions);
}
else {
throw new UnknownIdentifierException("Unsupported expression type: "+type);
}
}
示例15: removeDangningAnnotations
import org.semanticweb.owlapi.model.OWLClassExpression; //導入依賴的package包/類
@CLIMethod("--remove-dangling-annotations")
public void removeDangningAnnotations(Opts opts) throws Exception {
OWLOntology ont = g.getSourceOntology();
int n = 0;
Set<OWLAxiom> rmAxioms = new HashSet<OWLAxiom>();
for (OWLNamedIndividual i : ont.getIndividualsInSignature()) {
for (OWLClassAssertionAxiom ca : ont.getClassAssertionAxioms(i)) {
OWLClassExpression cx = ca.getClassExpression();
if (cx instanceof OWLClass) {
OWLClass c = (OWLClass) cx;
String label = g.getLabel(c);
if (label == null)
rmAxioms.add(ca);
else
n++;
}
}
}
LOG.info("Removing " + rmAxioms.size() + " axioms");
ont.getOWLOntologyManager().removeAxioms(ont, rmAxioms);
LOG.info("Remaining: " + n + " axioms");
}