本文整理汇总了Java中org.apache.jena.rdf.model.Model.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Model.getProperty方法的具体用法?Java Model.getProperty怎么用?Java Model.getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jena.rdf.model.Model
的用法示例。
在下文中一共展示了Model.getProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillTrie
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
@Override
protected void fillTrie(Logger logger, Trie<Resource> trie, Corpus corpus) throws IOException, ModuleException {
Model model = createModel(logger);
Property typeProp = model.getProperty("http://www.w3.org/1999/02/22-rdf-syntax-ns#type");
Property[] labelPropertyProps = getProperties(model, labelURIs);
int nEntries = 0;
for (String resourceTypeURI : resourceTypeURIs) {
Property resourceType = model.getProperty(model.expandPrefix(resourceTypeURI));
for (Resource res : Iterators.loop(model.listSubjectsWithProperty(typeProp , resourceType))) {
if (res.isAnon()) {
continue;
}
for (Property prop : labelPropertyProps) {
for (RDFNode node : Iterators.loop(model.listObjectsOfProperty(res, prop))) {
String label = getNodeValue(node);
trie.addEntry(label, res);
nEntries++;
}
}
}
}
logger.info("Entries: " + nEntries);
}
示例2: getIntProperty
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
public int getIntProperty(Model model, Resource res, String name) {
Property anIntProperty = model.getProperty("http://example.com/owl/csvtupler/map2sparql#",name);
Statement aStatement = res.getProperty(anIntProperty);
if (aStatement != null) {
return aStatement.getObject().asLiteral().getInt();
}
return -1;
}
示例3: getBooleanProperty
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
public boolean getBooleanProperty(Model model, Resource res, String name) {
Property aBooleanProperty = model.getProperty("http://example.com/owl/csvtupler/map2sparql#",name);
Statement aStatement = res.getProperty(aBooleanProperty);
if (aStatement != null) {
return aStatement.getObject().asLiteral().getBoolean();
}
return false;
}
示例4: getStringProperty
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
public String getStringProperty(Model model, Resource res, String name) {
Property aStringProperty = model.getProperty("http://example.com/owl/csvtupler/map2sparql#",name);
Statement aStatement = res.getProperty(aStringProperty);
if (aStatement != null) {
return aStatement.getObject().asLiteral().getString();
}
return null;
}
示例5: getProperties
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
private static Property[] getProperties(Model model, String[] uris) {
Property[] result = new Property[uris.length];
for (int i = 0; i < result.length; ++i) {
result[i] = model.getProperty(model.expandPrefix(uris[i]));
}
return result;
}
示例6: handleMatch
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
@Override
protected void handleMatch(Resource value, Annotation a) {
a.addFeature(uriFeatureName, value.getURI());
Model model = value.getModel();
for (Map.Entry<String,String> e : labelFeatures.entrySet()) {
String propURI = e.getValue();
Property prop = model.getProperty(model.expandPrefix(propURI));
for (RDFNode node : Iterators.loop(model.listObjectsOfProperty(value, prop))) {
a.addFeature(e.getKey(), getNodeValue(node));
}
}
}
示例7: buildTree
import org.apache.jena.rdf.model.Model; //导入方法依赖的package包/类
public static Node buildTree(Model model, List<Node> nodes) throws Exception {
Property hasChildProperty = model.getProperty("http://example.com/owl/csvtupler/map2sparql#","hasChild");
Property rootProperty = model.getProperty("http://example.com/owl/csvtupler/map2sparql#","root");
Node root = null;
for (Node node : nodes) {
Statement rootStatement = node.getResource().getProperty(rootProperty);
if (rootStatement != null && rootStatement.getObject().asLiteral().getBoolean() == true) {
if (root != null)
throw new Exception("Can't have multiple root nodes");
node.setRoot(true);
root = node;
}
StmtIterator hasChildStatementIterator = node.getResource().listProperties(hasChildProperty);
while (hasChildStatementIterator.hasNext()) {
Statement hasChildStatement = hasChildStatementIterator.next();
Resource childRes = hasChildStatement.getObject().asResource();
for (Node sNode : nodes) {
if (sNode != node) {
if (resourcesEqual(sNode.getResource(), childRes)) {
node.addChild(sNode);
}
}
}
}
}
if (root == null)
throw new Exception("Must have a root node");
Deque<Node> path = new ArrayDeque<Node>();
path.add(root);
if (checkCycles(root, path) == true)
throw new Exception("Can't have cycles in node tree");
else
return root;
}