本文整理汇总了Java中gate.creole.ontology.OClass类的典型用法代码示例。如果您正苦于以下问题:Java OClass类的具体用法?Java OClass怎么用?Java OClass使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OClass类属于gate.creole.ontology包,在下文中一共展示了OClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: OntologyTreePanel
import gate.creole.ontology.OClass; //导入依赖的package包/类
/** Constructor */
public OntologyTreePanel(OntologyViewer ontoViewer) {
this.ontoViewer = ontoViewer;
this.textView = ontoViewer.documentTextualDocumentView;
this.ontologyViewerOptions = new OntologyViewerOptions(this);
ontology2ColorSchemesMap = new HashMap<Ontology, HashMap<String, Color>>();
ontology2PropValuesAndInstances2ClassesMap =
new HashMap<Ontology, HashMap<String, Set<OClass>>>();
ontology2OntoTreeModels = new HashMap<Ontology, OntoTreeModel>();
currentOResource2ColorMap = new HashMap<String, Color>();
ontology2OResourceSelectionMap =
new HashMap<Ontology, HashMap<String, Boolean>>();
currentOResource2IsSelectedMap = new HashMap<String, Boolean>();
ontology2PropertiesMap = new HashMap<Ontology, Set<RDFProperty>>();
colorGenerator = new ColorGenerator();
initGUI();
}
示例2: expandAllClasses
import gate.creole.ontology.OClass; //导入依赖的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);
}
示例3: getOInstances
import gate.creole.ontology.OClass; //导入依赖的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;
}
示例4: addAllValuesFromRestriction
import gate.creole.ontology.OClass; //导入依赖的package包/类
public AllValuesFromRestriction addAllValuesFromRestriction(
ObjectProperty onProperty, OClass hasValue) {
String restId = getAutoGeneratedRestrictionName();
ontologyService.addClass(restId,
OConstants.ALL_VALUES_FROM_RESTRICTION);
ontologyService.setOnPropertyValue(restId, onProperty
.getOURI().toString());
ontologyService.setRestrictionValue(restId,
OConstants.ALL_VALUES_FROM_RESTRICTION, hasValue.getONodeID().toString());
AllValuesFromRestriction avfr =
(AllValuesFromRestriction) Utils.createOClass(
this, ontologyService, restId, OConstants.ALL_VALUES_FROM_RESTRICTION);
fireOntologyResourceAdded(avfr);
return avfr;
}
示例5: getAllResources
import gate.creole.ontology.OClass; //导入依赖的package包/类
/**
* This method returns a list of OResources from the ontology. Please note
* that deleting an instance from this list (e.g. list.remove(int/Object))
* does not delete the resource from an ontology. One must use appropriate
* method from the Ontology interface to delete such resources.
*
* @return
*/
public List<OResource> getAllResources() {
//Utils.warnDeprecation("getAllResources");
// TODO: would love to make this Unsupported but at the moment
// it is still used by the ontology editor.
Set<OClass> cs = getOClasses(false);
Set<OInstance> is = getOInstances();
Set<RDFProperty> rs = getPropertyDefinitions();
List<OResource> toReturn = new ArrayList<OResource>();
for (OClass c : cs) {
toReturn.add(c);
}
for (OInstance i : is) {
toReturn.add(i);
}
for (RDFProperty r : rs) {
toReturn.add(r);
}
//Iterator<String> keys = resourceNamesToOResourcesMap.keySet().iterator();
//while(keys.hasNext()) {
// toReturn.addAll(resourceNamesToOResourcesMap.get(keys.next()));
//}
return toReturn;
//throw new UnsupportedOperationException("getAllResources not supported any more");
}
示例6: addSubClass
import gate.creole.ontology.OClass; //导入依赖的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);
}
示例7: removeSubClass
import gate.creole.ontology.OClass; //导入依赖的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);
}
示例8: createRestrictionFromURI
import gate.creole.ontology.OClass; //导入依赖的package包/类
private OClass createRestrictionFromURI(String uriString, ONodeID uri) {
if (uriString.equals("http://www.w3.org/2002/07/owl#cardinality")) {
return new CardinalityRestrictionImpl(uri, ontology, this);
} else if (uriString.equals("http://www.w3.org/2002/07/owl#allValuesFrom")) {
return new AllValuesFromRestrictionImpl(uri, ontology, this);
} else if (uriString.equals("http://www.w3.org/2002/07/owl#minCardinality")) {
return new MinCardinalityRestrictionImpl(uri, ontology, this);
} else if (uriString.equals("http://www.w3.org/2002/07/owl#maxCardinality")) {
return new MaxCardinalityRestrictionImpl(uri, ontology, this);
} else if (uriString.equals("http://www.w3.org/2002/07/owl#someValuesFrom")) {
return new SomeValuesFromRestrictionImpl(uri, ontology, this);
} else if (uriString.equals("http://www.w3.org/2002/07/owl#hasValue")) {
return new HasValueRestrictionImpl(uri, ontology, this);
} else if (uriString.equals("http://www.w3.org/2002/07/owl#oneOf")) {
System.out.println("Warning: restriction oneOf not yet implemented in createRestrictionFromURI"+uri);
return new AnonymousClassImpl(uri, ontology, this);
}
throw new GateOntologyException("createRestrictionFromURI not for this yet: " + uriString);
}
示例9: getClasses
import gate.creole.ontology.OClass; //导入依赖的package包/类
public Set<OClass> getClasses(boolean top) throws GateOntologyException {
Set<OClass> result = new HashSet<OClass>();
Collection<ONodeID> concepts = new HashSet<ONodeID>();
if (top) {
concepts = op.getTopConcepts();
} else {
concepts = op.getClasses();
}
for (ONodeID clas : concepts) {
if (clas != null) {
OClass oclass = new OClassImpl(clas, this.ontology, this);
result.add(oclass);
}
}
return result;
}
示例10: addSubClass
import gate.creole.ontology.OClass; //导入依赖的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);
}
示例11: getClassesByName
import gate.creole.ontology.OClass; //导入依赖的package包/类
public Set<OClass> getClassesByName(String name) {
String query;
Set<OClass> classes = new HashSet<OClass>();
UtilTupleQueryIterator q;
String qs = qs_getClassesByNameNoW3.replaceAll("yyy1", "\"[/#]"+name+"\\$\"");
q = new UtilTupleQueryIterator(
sesameManager, qs, ql_getClassesByNameNoW3);
while (q.hasNext()) {
Vector<Value> tuple = q.nextAsValue();
Value t1 = tuple.get(0);
String uristring = ((org.openrdf.model.URI) t1).toString();
OURI ourURI = ontology.createOURI(uristring);
classes.add(new OClassImpl(ourURI, ontology, this));
}
q.close();
return classes;
}
示例12: isValidDomain
import gate.creole.ontology.OClass; //导入依赖的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;
}
}
示例13: addOClass
import gate.creole.ontology.OClass; //导入依赖的package包/类
public OClass addOClass(OURI aURI, byte classType) {
OClass existing = this.getOClass(aURI);
if(existing != null) {
Utils.warning(aURI + " already exists");
return existing;
}
ontologyService.addClass(aURI);
OClass oClass =
Utils.createOClass(this, ontologyService, aURI.toString(),
classType);
fireOntologyResourceAdded(oClass);
if(doSetAutoLabel) {
oClass.setLabel(aURI.getResourceName(), null);
}
return oClass;
}
示例14: getOInstances
import gate.creole.ontology.OClass; //导入依赖的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;
}
示例15: addAllValuesFromRestriction
import gate.creole.ontology.OClass; //导入依赖的package包/类
public AllValuesFromRestriction addAllValuesFromRestriction(
ObjectProperty onProperty, OClass hasValue) {
String restId = getAutoGeneratedRestrictionName();
OBNodeID bnode = createOBNodeID(restId);
ontologyService.addRestriction(bnode);
ontologyService.setOnPropertyValue(bnode, onProperty.getOURI());
ontologyService.setRestrictionValue(bnode,
OURI_OWL_ALLVALUESFROM, hasValue.getONodeID());
AllValuesFromRestriction avfr =
(AllValuesFromRestriction)Utils.createOClass(
this, ontologyService, restId, OConstants.ALL_VALUES_FROM_RESTRICTION);
fireOntologyResourceAdded(avfr);
return avfr;
}