本文整理汇总了Java中gate.creole.ontology.OConstants.OWL_CLASS属性的典型用法代码示例。如果您正苦于以下问题:Java OConstants.OWL_CLASS属性的具体用法?Java OConstants.OWL_CLASS怎么用?Java OConstants.OWL_CLASS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gate.creole.ontology.OConstants
的用法示例。
在下文中一共展示了OConstants.OWL_CLASS属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRestrictionValue
/**
* Gets the cardinality value specified on the given restriction uri.
*
* @param restrictionURI
* @param restrictionType
* - either of the following constants from the OConstants -
* ALL_VALUES_FROM_RESTRICTION, SOME_VALUES_FROM_RESTRICTION, and
* HAS_VALUE_RESTRICTION
* @return
*/
public ResourceInfo getRestrictionValue(
String restrictionURI, byte restrictionType)
{
System.out.println("getRestrictionValue for "+restrictionURI);
URI whatValueURI = null;
switch (restrictionType) {
case OConstants.ALL_VALUES_FROM_RESTRICTION:
whatValueURI = OWL.ALLVALUESFROM;
break;
case OConstants.HAS_VALUE_RESTRICTION:
whatValueURI = OWL.HASVALUE;
break;
case OConstants.SOME_VALUES_FROM_RESTRICTION:
whatValueURI = OWL.SOMEVALUESFROM;
break;
default:
throw new GateOntologyException("Invalid restriction type:" + restrictionType + " for the restriction " + restrictionURI);
}
String resourceURI;
try {
RepositoryResult<Statement> iter =
repositoryConnection.getStatements(string2SesameResource(restrictionURI), whatValueURI,
null, true);
if (iter.hasNext()) {
resourceURI = iter.next().getObject().toString();
Resource res = getResource(resourceURI);
boolean isRestriction =
repositoryConnection.hasStatement(
res,
RDF.TYPE,
OWL.RESTRICTION,
true);
byte classType = OConstants.OWL_CLASS;
if (isRestriction) {
if (repositoryConnection.hasStatement(res, OWL.HASVALUE, null, true)) {
classType = OConstants.HAS_VALUE_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.SOMEVALUESFROM, null, true)) {
classType = OConstants.SOME_VALUES_FROM_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.ALLVALUESFROM, null, true)) {
classType = OConstants.ALL_VALUES_FROM_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.CARDINALITY, null, true)) {
classType = OConstants.CARDINALITY_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.MINCARDINALITY, null, true)) {
classType = OConstants.MIN_CARDINALITY_RESTRICTION;
} else if (repositoryConnection.hasStatement(res, OWL.MAXCARDINALITY, null, true)) {
classType = OConstants.MAX_CARDINALITY_RESTRICTION;
}
}
if (classType == OConstants.OWL_CLASS) {
if (res instanceof BNode) {
classType = OConstants.ANNONYMOUS_CLASS;
} else {
// check if it is an instance
if (isIndividual(resourceURI)) {
classType = OConstants.INSTANCE;
}
}
}
return new ResourceInfo(resourceURI, classType);
}
} catch (Exception e) {
throw new GateOntologyException("Problem getting restriction value for "+restrictionURI,e);
}
return null;
}
示例2: getClassType
/**
* This method tells what type of restriction the given uri refers to. If the
* given URI is not a restriction, the method returns -1. Otherwise one of the
* following values from the OConstants class. OWL_CLASS,
* CARDINALITY_RESTRICTION, MIN_CARDINALITY_RESTRICTION,
* MAX_CARDINALITY_RESTRICTION, HAS_VALUE_RESTRICTION,
* ALL_VALUES_FROM_RESTRICTION.
*
* @param restrictionURI
* @return
*/
// TODO: !!! how does this relate to getRestrictionForONodeID
public byte getClassType(String restrictionURI)
{
Resource res = getResource(restrictionURI);
logger.debug("Converted to resource: " + res);
String rep1 = "<" + restrictionURI + ">";
if (res instanceof BNode) {
logger.debug("is an instance of Bnode: " + res);
rep1 = restrictionURI;
}
if (res instanceof BNode) {
logger.debug("is an instance of Bnode: " + res);
String query = "select * from {" + rep1 + "} owl:hasValue {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.HAS_VALUE_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:someValuesFrom {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.SOME_VALUES_FROM_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:allValuesFrom {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.ALL_VALUES_FROM_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:cardinality {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.CARDINALITY_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:minCardinality {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.MIN_CARDINALITY_RESTRICTION;
}
query = "select * from {" + rep1 + "} owl:maxCardinality {B}";
if (hasSerqlQueryResultRows(query)) {
return OConstants.MAX_CARDINALITY_RESTRICTION;
}
}
if (res instanceof BNode) {
logger.debug("is an instance of Bnode: " + res);
return OConstants.ANNONYMOUS_CLASS;
} else {
logger.debug("is an ordinary class: " + res);
return OConstants.OWL_CLASS;
}
}