当前位置: 首页>>代码示例>>Java>>正文


Java Closure类代码示例

本文整理汇总了Java中gate.creole.ontology.OConstants.Closure的典型用法代码示例。如果您正苦于以下问题:Java Closure类的具体用法?Java Closure怎么用?Java Closure使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Closure类属于gate.creole.ontology.OConstants包,在下文中一共展示了Closure类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getIndividuals

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
/**
 * The method returns all member instances of the provided class. It returns
 * only the direct instances if the boolean parameter direct is set to true.
 * 
 * @param superClassURI
 * @param direct
 */
public String[] getIndividuals(String superClassURI,
    Closure direct) {
  String queryRep = string2Turtle(superClassURI);

  // A -> B -> I1

  String query = "";
  if (direct == OConstants.Closure.DIRECT_CLOSURE) {
    query = "Select distinct X from {X} serql:directType {" + queryRep +"}";
  } else {
    query = "Select distinct X from {X} rdf:type {" + queryRep +"}";
  }
  //System.out.println("getIndividuals query: "+query);
  List<String> list = new ArrayList<String>();
  addSerqlQueryResultToCollection(query, list);
  return listToArray(list);
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:25,代码来源:OntologyServiceImplSesame.java

示例2: getOInstances

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public Set<OInstance> getOInstances(OClass theClass, Closure closure) {
//    String[] oInsts =
//      ontologyService.getIndividuals(theClass.getONodeID()
//        .toString(), closure);
//    Set<OInstance> set = new HashSet<OInstance>();
//
//    if(!containsOClass(theClass.getONodeID())) {
//      Utils.warning("GetOInstances: "+theClass.getONodeID() + " does not exist");
//      return set;
//    }
//
//    for(int i = 0; i < oInsts.length; i++) {
//      set.add(Utils.createOInstance(this, this.ontologyService,
//        oInsts[i]));
//    }
//    return set;
    Set<OInstance> theInstances = new HashSet<OInstance>();
    ClosableIterator<OInstance> ii =
        ontologyService.getInstancesIterator(theClass.getONodeID(), closure);
    while(ii.hasNext()) {
      OInstance i = ii.next();
      //System.out.println("Adding to result: "+i);
      theInstances.add(i);
    }
    return theInstances;
  }
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:27,代码来源:AbstractOntologyImpl.java

示例3: addSubClass

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public void addSubClass(OClass subClass) {
  // lets first check if the current class is a subclass of the
  // subClass. If so,
  // we don't allow this.
  if(this.equals(subClass)) {
    Utils
            .warning("addSubClass(subClass) : The super and sub classes are same.");
    return;
  }

  if(this.isSubClassOf(subClass, OConstants.Closure.TRANSITIVE_CLOSURE)) {
    Utils.warning(subClass.getONodeID().toString() + " is a super class of "
            + this.getONodeID().toTurtle());
    return;
  }

  if(this.isSuperClassOf(subClass, OConstants.Closure.DIRECT_CLOSURE)) {
    Utils.warning(subClass.getONodeID().toString()
            + " is already a sub class of " + this.getONodeID().toTurtle());
    return;
  }

  ontologyService.addSubClass(this.nodeId.toString(), subClass.getONodeID()
          .toString());
  ontology.fireResourceRelationChanged(this, subClass, OConstants.SUB_CLASS_ADDED_EVENT);
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:27,代码来源:OClassImpl.java

示例4: removeSubClass

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public void removeSubClass(OClass subClass) {

    if(this.equals(subClass)) {
      Utils
              .warning("addSubClass(subClass) : The super and sub classes are same.");
      return;
    }

    if(!subClass.isSubClassOf(this, OConstants.Closure.DIRECT_CLOSURE)) {
      Utils.warning(subClass.getONodeID().toString()
              + " is not a direct subclass of " + this.getONodeID().toTurtle());
      return;
    }

    ontologyService.removeSubClass(this.nodeId.toString(), subClass
            .getONodeID().toString());
    ontology.fireResourceRelationChanged(this, subClass, OConstants.SUB_CLASS_REMOVED_EVENT);  
  }
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:19,代码来源:OClassImpl.java

示例5: getSuperClassesVSDistance

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
/**
 * Gets the super classes, and returns them in an array list where on
 * each index there is a collection of the super classes at distance -
 * the index.
 * @return
 */
public ArrayList<Set<OClass>> getSuperClassesVSDistance() {
  ArrayList<Set<OClass>> result = new ArrayList<Set<OClass>>();
  Set<OClass> set;
  int level = 0;
  OClass c;
  Set<OClass> levelSet = new HashSet<OClass>();
  levelSet.add(this);
  boolean rollon = (0 < ontologyService.getSuperClasses(this.nodeId.toTurtle(),
          OConstants.Closure.DIRECT_CLOSURE).length);
  while(rollon) {
    set = new HashSet<OClass>();
    Iterator<OClass> li = levelSet.iterator();
    while(li.hasNext()) {
      c = li.next();
      set.addAll(c.getSuperClasses(OConstants.Closure.DIRECT_CLOSURE));
    }
    if(0 < set.size()) {
      result.add(level++, set);
    }
    levelSet = set;
    rollon = 0 < levelSet.size();
  }
  return result;
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:31,代码来源:OClassImpl.java

示例6: getInstancesIterator

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public ClosableIterator<OInstance> getInstancesIterator(
    ONodeID aClass, OConstants.Closure closure) {
  // if aClass is null: all instances
  // if aClass is not null: instances of that class either 
  //   direct or transitive
  // once we have that, remove  unneeded classes and re-implement
  // getOInstance and has OInstance in abstractOntologyimpl
  UtilResourceQueryIterator ret = null;
  if(aClass == null) {
     ret = new UtilResourceQueryIterator<OInstance>(
      this, qp_getInstancesAll, OInstance.class);
  } else if(closure == OConstants.Closure.DIRECT_CLOSURE) {
      ret = new UtilResourceQueryIterator<OInstance>(
      this, qp_getInstancesDirectFor, OInstance.class);
      ret.setBinding("yyy1", new LiteralOrONodeIDImpl(aClass));

  } else {
     ret = new UtilResourceQueryIterator<OInstance>(
      this, qp_getInstancesAllFor, OInstance.class);
      ret.setBinding("yyy1", new LiteralOrONodeIDImpl(aClass));
 }
  return ret;
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:24,代码来源:OntologyServiceImplSesame.java

示例7: getClassesOfIndividual

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
/**
 * For the given individual, the method returns a set of classes for which the
 * individual is registered as instance of
 * 
 * @param individualURI
 */
public ResourceInfo[] getClassesOfIndividual(String individualURI, Closure direct) throws GateOntologyException {
  if (debug) {
    logger.debug("getClassesOfIndividual");
  }
  String query = "";
  if (direct == OConstants.Closure.DIRECT_CLOSURE) {
    query =
        "Select DISTINCT B from {X} serql:directType {B} WHERE X=<" + individualURI + ">";
  } else {
    query =
        "Select DISTINCT B from {X} rdf:type {B} WHERE X=<" + individualURI + ">";
  }

  List<String> list = new ArrayList<String>();
  addSerqlQueryResultToCollection(query, list);
  return listToResourceInfoArray(list);
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:24,代码来源:OntologyServiceImplSesame.java

示例8: isValidDomain

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public boolean isValidDomain(OResource aResource) {
  if(aResource instanceof OInstance) {
    Set<OResource> domainResources = this.getDomain();
    Set<OClass> domainClasses = new HashSet<OClass>();
    for(OResource dr : domainResources) {
      if(dr instanceof OClass) {
        domainClasses.add((OClass)dr);
      }        
    }
    if(domainClasses.size() == 0) return true;
    Set<OClass> instanceClassClosure = 
      ((OInstance)aResource).getOClasses(Closure.TRANSITIVE_CLOSURE);
    return instanceClassClosure.containsAll(domainClasses);
  } else {
    return false;
  }
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:18,代码来源:RDFPropertyImpl.java

示例9: expandAllClasses

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public void expandAllClasses(Set<OClass> classes, Set<ONodeID> allIDs, int depth) {
  depth = depth + 1;
  if(depth > 9) {
    // TODO: print everything about the node that gets us into a loop here!
    assertTrue("Depth must not exceed 9",false);
  }
  if(classes.size() == 0) {
    return;
  }
  //System.out.println("Expanding set: "+classes);
  for (OClass c : classes) {
    //System.out.println("Processing class: "+c);
    ONodeID n = c.getONodeID();
    if(allIDs.contains(n)) {

      //System.err.println("Node ID already found: "+n.toTurtle());
    }
    allIDs.add(n);
    // get the set of direct subclasses of this class
    Set<OClass> subclasses = c.getSubClasses(OConstants.Closure.DIRECT_CLOSURE);
    //System.out.println("Subclasses for "+c+": "+subclasses);
    expandAllClasses(subclasses,allIDs,depth);
  }
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:25,代码来源:Test_W3Tests.java

示例10: expandAllClasses

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public void expandAllClasses(Set<OClass> classes, int depth) {
   if(depth > 20) {
    assertTrue("Depth must not exceed 20",false);
  }
  if(classes.isEmpty()) return;  // there are no classes to expand!
  // number of new classes found
  Set<OClass> addclasses = new HashSet<OClass>();
  for (OClass c : classes) {
    Set<OClass> subclasses = c.getSubClasses(OConstants.Closure.DIRECT_CLOSURE);
    if(subclasses.contains(c)) {
      System.out.println("Subclass of itself: "+c);
      assertTrue(false);
    }
    addclasses.addAll(subclasses);
  }
  if(classes.addAll(addclasses)) expandAllClasses(classes,depth+1);
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:18,代码来源:Test_OntoWine.java

示例11: getStoredSubConcepts

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public Set<ONodeID> getStoredSubConcepts(ONodeID superClassURI, Closure direct) {
        if (Closure.DIRECT_CLOSURE.equals(direct))
            return getStoredSubConcepts(superClassURI);
        else {
            int depth = 0;
            Set<ONodeID> allSubClasses = new HashSet<ONodeID>();
            Set<ONodeID> newsubclasses = new HashSet<ONodeID>();
            newsubclasses = getStoredSubConcepts(superClassURI);
            while (!newsubclasses.isEmpty()) {
                Set<ONodeID> classesToRemove = new HashSet<ONodeID>();
                for (ONodeID cl : newsubclasses) {
                    if (!allSubClasses.contains(cl)) {
                        allSubClasses.add(cl);
                    } else {
                        classesToRemove.add(cl);
                    }
                }
                newsubclasses.removeAll(classesToRemove);
                newsubclasses = getNextLevelSubclasses(newsubclasses);
                depth++;
//        if(depth>707){
//          System.out.println("depth too large!");
//        }
            }
            return allSubClasses;
        }
    }
 
开发者ID:naditina,项目名称:gate-semano,代码行数:28,代码来源:OntologyParser.java

示例12: getSuperClasses

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
private Set<ONodeID> getSuperClasses(OWLClass cls, Closure closure) {
        Set<ONodeID> sups = new HashSet<ONodeID>();
        Set<OWLClassExpression> superclassesAll = new HashSet<OWLClassExpression>();
        superclassesAll.add(cls);
        boolean proceed = true;
        while (proceed) {
            if (!Closure.TRANSITIVE_CLOSURE.equals(closure)) {
                proceed = false;
            }
            boolean foundNew = false;
            Set<OWLClassExpression> superclasses = new HashSet<OWLClassExpression>();
            for (OWLClassExpression c : superclassesAll) {
                if (c instanceof OWLClass)
                    superclasses.addAll(((OWLClass) c).getSuperClasses(ontologies));
            }
            for (OWLClassExpression cl : superclasses) {
                if (cl instanceof OWLClass) {
                    if (!superclassesAll.contains(cl)) {
                        foundNew = true;
                        ONodeID nodeId = registerNode((OWLClass) cl);
                        if (nodeId != null && nodeId.toString() != null) {
                            sups.add(nodeId);
                        }
                        superclassesAll.add(cl);
                    }
                }
            }
            if (!foundNew)
                proceed = false;
        }


//    if(sups.toString().contains("aterial")){
//      System.out.println();
//    }
        return sups;
    }
 
开发者ID:naditina,项目名称:gate-semano,代码行数:38,代码来源:OntologyParser.java

示例13: getInstances

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public Set<OInstance> getInstances(ONodeID aClass, OConstants.Closure closure) {
  //System.out.println("Running service.getInstances()");
  Set<OInstance> theInstances = new HashSet<OInstance>();
  ClosableIterator<OInstance> ii = getInstancesIterator(aClass, closure);
  while(ii.hasNext()) {
    OInstance i = ii.next();
    //System.out.println("Adding to result: "+i);
    theInstances.add(i);
  }
  return theInstances;
}
 
开发者ID:Network-of-BioThings,项目名称:GettinCRAFTy,代码行数:12,代码来源:OntologyServiceImplSesame.java

示例14: isSubClassOf

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public boolean isSubClassOf(String theSuperClassURI, String theSubClassURI,
        Closure closure) {
  OWLClass owlsuperClass = getOWLClass(theSuperClassURI);
  if(closure.equals(Closure.TRANSITIVE_CLOSURE) && classify){
   OWLOntology o = entities2Ontologies.get(owlsuperClass);
   return OWLreasoners.get(o).getSubClasses(owlsuperClass, false).containsEntity(getOWLClass(theSubClassURI));        
  }
  return getSuperClasses(getOWLClass(theSubClassURI),  closure).contains(owlsuperClass);
}
 
开发者ID:naditina,项目名称:gate-semano,代码行数:10,代码来源:OntologyParser.java

示例15: getOClasses

import gate.creole.ontology.OConstants.Closure; //导入依赖的package包/类
public Set<OClass> getOClasses(Closure closure) {
    ResourceInfo[] oClasses = ontologyService.getClassesOfIndividual(
            this.nodeId.toString(), closure);
    Set<OClass> set = new HashSet<OClass>();
    for (int i = 0; i < oClasses.length; i++) {
        set.add(Utils.createOClass(this.ontology,
                this.ontologyService, oClasses[i].getUri(),
                oClasses[i].getClassType()));
    }
    return set;
}
 
开发者ID:naditina,项目名称:gate-semano,代码行数:12,代码来源:OInstanceImpl.java


注:本文中的gate.creole.ontology.OConstants.Closure类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。