本文整理汇总了Java中gate.creole.ontology.OConstants类的典型用法代码示例。如果您正苦于以下问题:Java OConstants类的具体用法?Java OConstants怎么用?Java OConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OConstants类属于gate.creole.ontology包,在下文中一共展示了OConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeSubClass
import gate.creole.ontology.OConstants; //导入依赖的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);
}
示例2: readOntologies
import gate.creole.ontology.OConstants; //导入依赖的package包/类
private void readOntologies(Set<String> filenames, String baseURI,
boolean asImport, String dirName) throws OWLOntologyCreationException, FileNotFoundException {
boolean isBaseURIset = true;
if (baseURI == null || baseURI.length() == 0) {
isBaseURIset = false;
baseURI = OConstants.ONTOLOGY_DEFAULT_BASE_URI;
}
String defaultUri = ((OWLOntologyServiceImpl) ontologyService).readOntologyData(filenames, dirName);
setDefaultNameSpace(defaultUri);
if (!asImport) {
if (isBaseURIset && getDefaultNameSpace() == null) {
setDefaultNameSpace(baseURI);
}
Set<OURI> us = addOntologyURIs();
int n = us.size();
if (n != 1) {
Utils.warning("Found 0 or more than 1 ontology in " + filenames.toString());
} else {
setDefaultNameSpaceFromOntologyURI();
}
}
}
示例3: addAnnotationProperty
import gate.creole.ontology.OConstants; //导入依赖的package包/类
public AnnotationProperty addAnnotationProperty(OURI aPropertyURI) {
RDFProperty exists = getProperty(aPropertyURI);
if (exists != null) {
if (exists instanceof DatatypeProperty) {
Utils.warning(aPropertyURI.toString() + " already exists");
return (AnnotationProperty) exists;
}
Utils.warning(aPropertyURI.toString() + " already exists but is not an annotation property");
return null;
}
ontologyService.addAnnotationProperty(aPropertyURI
.toString());
AnnotationProperty ap =
(AnnotationProperty) Utils.createOProperty(this,
ontologyService, aPropertyURI.toString(), OConstants.ANNOTATION_PROPERTY);
fireOntologyResourceAdded(ap);
if (doSetAutoLabel) {
ap.setLabel(aPropertyURI.getResourceName(), null);
}
return ap;
}
示例4: addHasValueRestriction
import gate.creole.ontology.OConstants; //导入依赖的package包/类
/**
* Adds a new HasValue Restriction to the ontology. It automatically creates a
* randon anonymous class, which it uses to denote the restriction.
*
* @param onProperty - Specifies the property for which the restriction is being set.
* @param hasValue - a resource or a literal used as a value for hasValue element of
* the restriction.
* @return
*/
public HasValueRestriction addHasValueRestriction(RDFProperty onProperty,
OResource hasValue) {
String restId = getAutoGeneratedRestrictionName();
ontologyService.addClass(restId,
OConstants.HAS_VALUE_RESTRICTION);
ontologyService.setOnPropertyValue(restId, onProperty
.getOURI().toString());
String valueString =
hasValue instanceof Literal
? ((Literal) hasValue).getValue()
: ((OResource) hasValue).getONodeID().toString();
ontologyService.setRestrictionValue(restId,
OConstants.HAS_VALUE_RESTRICTION, valueString);
HasValueRestriction hvr =
(HasValueRestriction) Utils.createOClass(this,
ontologyService, restId, OConstants.HAS_VALUE_RESTRICTION);
fireOntologyResourceAdded(hvr);
return hvr;
}
示例5: getSetObjectProperties
import gate.creole.ontology.OConstants; //导入依赖的package包/类
/**
* This method returns the object properties set on this resource.
*
* @return
*/
public Set<ObjectProperty> getSetObjectProperties() {
Property[] properties = ontologyService.getObjectProperties(
this.nodeId.toString());
Set<ObjectProperty> objectProps = new HashSet<ObjectProperty>();
for(int i = 0; i < properties.length; i++) {
if(properties[i].getType() != OConstants.OBJECT_PROPERTY) {
throw new GateOntologyException("The property :"
+ properties[i].getUri()
+ " returned from the repository is not an ObjectProperty");
}
String propUri = properties[i].getUri();
OResource resource = new ObjectPropertyImpl(ontology.createOURI(propUri),
this.ontology, ontologyService);
objectProps.add((ObjectProperty)resource);
}
return objectProps;
}
示例6: readOntologyData
import gate.creole.ontology.OConstants; //导入依赖的package包/类
public void readOntologyData(InputStream in, String baseURI,
OntologyFormat format, boolean asImport) {
Reader input;
try {
input = new InputStreamReader(in, "UTF-8");
} catch (IOException ex) {
throw new GateOntologyException("Problem reading the input stream.", ex);
}
boolean isBaseURIset = true;
if(baseURI == null || baseURI.length() == 0) {
isBaseURIset = false;
baseURI = OConstants.ONTOLOGY_DEFAULT_BASE_URI;
}
((OntologyServiceImplSesame) ontologyService).readOntologyData(input,
baseURI, format, asImport);
if(!asImport) {
if(isBaseURIset && getDefaultNameSpace() == null) {
setDefaultNameSpace(baseURI);
} else {
setDefaultNameSpaceFromRepository();
}
}
}
示例7: getInverseProperties
import gate.creole.ontology.OConstants; //导入依赖的package包/类
public Set<ObjectProperty> getInverseProperties() {
Property[] properties = ontologyService.getInverseProperties(
this.nodeId.toString());
Set<ObjectProperty> set = new HashSet<ObjectProperty>();
for(int i = 0; i < properties.length; i++) {
byte type = properties[i].getType();
if(type != OConstants.OBJECT_PROPERTY
&& type != OConstants.SYMMETRIC_PROPERTY
&& type != OConstants.TRANSITIVE_PROPERTY)
throw new GateOntologyException(
"Invalid Property type returned as an inverse property");
set.add((ObjectProperty)Utils.createOProperty(
this.ontology, this.ontologyService, properties[i].getUri(), properties[i]
.getType()));
}
return set;
}
示例8: addRDFPropertyValue
import gate.creole.ontology.OConstants; //导入依赖的package包/类
public void addRDFPropertyValue(RDFProperty aProperty, OResource value)
throws InvalidValueException {
// we need to check if the current instance is a valid domain for
// the property
if (!aProperty.isValidDomain(this)) {
Utils.error(this.getOURI().toTurtle()
+ " is not a valid domain for the property "
+ aProperty.getOURI().toString());
return;
}
// we need to check if the current instance is a valid domain for
// the property
if (!aProperty.isValidRange(value)) {
Utils.error(value.getONodeID().toTurtle()
+ " is not a valid range for the property "
+ aProperty.getOURI().toTurtle());
return;
}
ontologyService.addRDFPropertyValue(this.nodeId.toString(),
aProperty.getOURI().toString(), value.getONodeID().toString());
ontology.fireResourcePropertyValueChanged(this, aProperty,
value, OConstants.RDF_PROPERTY_VALUE_ADDED_EVENT);
}
示例9: addAllValuesFromRestriction
import gate.creole.ontology.OConstants; //导入依赖的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;
}
示例10: addObjectPropertyValue
import gate.creole.ontology.OConstants; //导入依赖的package包/类
public void addObjectPropertyValue(ObjectProperty aProperty, OInstance value)
throws InvalidValueException {
// we need to check if the current instance is a valid domain for
// the property
if (!aProperty.isValidDomain(this)) {
Utils.error(this.getOURI().toTurtle()
+ " is not a valid domain for the property "
+ aProperty.getOURI().toTurtle());
return;
}
// we need to check if the current instance is a valid domain for
// the property
if (!aProperty.isValidRange(value)) {
Utils.error(value.getOURI().toTurtle()
+ " is not a valid range for the property "
+ aProperty.getOURI().toTurtle());
return;
}
ontologyService.addObjectPropertyValue(this.nodeId.toString(),
aProperty.getOURI().toString(), value.getOURI().toString());
ontology.fireResourcePropertyValueChanged(this, aProperty, value, OConstants.OBJECT_PROPERTY_VALUE_ADDED_EVENT);
}
示例11: getRDFProperties
import gate.creole.ontology.OConstants; //导入依赖的package包/类
/**
* Gets the RDF properties set on the specified resource
*
* @param theResourceURI
* @return
*/
public Property[] getRDFProperties(String theResourceURI)
{
List<Property> list = new ArrayList<Property>();
String queryRep = string2Turtle(theResourceURI);
String query =
"Select distinct X FROM {X} rdf:type {<" + RDF.PROPERTY.toString() + ">} WHERE EXISTS (SELECT * FROM {" + queryRep + "} X {Z})";
UtilTupleQueryIterator result = performSerqlQuery(query);
while (result.hasNext()) {
LiteralOrONodeID tmp = result.nextFirst();
OURI propuri = (OURI)tmp.getONodeID();
if (isAnnotationProperty(propuri) || isDatatypeProperty(propuri) ||
isObjectProperty(propuri) || isTransitiveProperty(propuri) ||
isSymmetricProperty(propuri)) {
continue;
}
list.add(new Property(OConstants.RDF_PROPERTY, propuri.toString()));
}
result.close();
return listToPropertyArray(list);
}
示例12: createPropertyObject
import gate.creole.ontology.OConstants; //导入依赖的package包/类
private Property createPropertyObject(String uri)
throws GateOntologyException {
OURI ouri = ontology.createOURI(uri);
byte type = OConstants.ANNOTATION_PROPERTY;
if (isAnnotationProperty(ouri)) {
type = OConstants.ANNOTATION_PROPERTY;
} else if (isObjectProperty(ouri)) {
type = OConstants.OBJECT_PROPERTY;
} else if (isDatatypeProperty(ouri)) {
type = OConstants.DATATYPE_PROPERTY;
} else if (isTransitiveProperty(ouri)) {
type = OConstants.TRANSITIVE_PROPERTY;
} else if (isSymmetricProperty(ouri)) {
type = OConstants.SYMMETRIC_PROPERTY;
} else if (isRDFProperty(ouri)) {
type = OConstants.RDF_PROPERTY;
} else {
return null;
}
return new Property(type, uri);
}
示例13: addSubClass
import gate.creole.ontology.OConstants; //导入依赖的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);
}
示例14: getAnnotationProperties
import gate.creole.ontology.OConstants; //导入依赖的package包/类
/**
* Gets the annotation properties set on the specified resource
*
* @param theResourceURI
* @return
*/
public Property[] getAnnotationProperties(String theResourceURI)
{
List<Property> list = new ArrayList<Property>();
String queryRep = string2Turtle(theResourceURI);
String query =
"Select DISTINCT X FROM {X} rdf:type {<" + OWL.ANNOTATIONPROPERTY + ">} WHERE EXISTS (SELECT * FROM {" + queryRep + "} X {Z})";
UtilTupleQueryIterator result = performSerqlQuery(query);
while (result.hasNext()) {
list.add(new Property(OConstants.ANNOTATION_PROPERTY, result.nextFirstAsString()));
}
result.close();
boolean allowSystemStatements = this.returnSystemStatements;
this.returnSystemStatements = true;
Property[] props = listToPropertyArray(list);
this.returnSystemStatements = allowSystemStatements;
return props;
}
示例15: getSuperClassesVSDistance
import gate.creole.ontology.OConstants; //导入依赖的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;
}