本文整理匯總了Java中com.hp.hpl.jena.query.Dataset.getNamedModel方法的典型用法代碼示例。如果您正苦於以下問題:Java Dataset.getNamedModel方法的具體用法?Java Dataset.getNamedModel怎麽用?Java Dataset.getNamedModel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.hp.hpl.jena.query.Dataset
的用法示例。
在下文中一共展示了Dataset.getNamedModel方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAllEntityEvents
import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
static ArrayList<String> getAllEntityEvents (Dataset dataset, String entity) {
ArrayList<String> events = new ArrayList<String>();
Iterator<String> it = dataset.listNames();
while (it.hasNext()) {
String name = it.next();
if (!name.equals(instanceGraph) && (!name.equals(provenanceGraph))) {
Model namedModel = dataset.getNamedModel(name);
StmtIterator siter = namedModel.listStatements();
while (siter.hasNext()) {
Statement s = siter.nextStatement();
String object = getObjectValue(s).toLowerCase();
if (object.indexOf(entity.toLowerCase()) > -1) {
String subject = s.getSubject().getURI();
if (!events.contains(subject)) {
events.add(subject);
}
}
}
}
}
return events;
}
示例2: readSemTrig
import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
static public HashMap<String, String> readSemTrig (ArrayList<String> eventIdentifierArray,String trigFolder) {
HashMap<String, String> tokenIdMap = new HashMap<String, String>();
ArrayList<File> trigFiles = Util.makeRecursiveFileList(new File(trigFolder), ".trig");
// System.out.println("trigFiles.size() = " + trigFiles.size());
for (int i = 0; i < trigFiles.size(); i++) {
File file = trigFiles.get(i);
Dataset dataset = TDBFactory.createDataset();
dataset = RDFDataMgr.loadDataset(file.getAbsolutePath());
Iterator<String> it = dataset.listNames();
while (it.hasNext()) {
String name = it.next();
if (name.equals(instanceGraph)) {
Model namedModel = dataset.getNamedModel(name);
StmtIterator siter = namedModel.listStatements();
while (siter.hasNext()) {
Statement s = siter.nextStatement();
updateTokenMap(eventIdentifierArray, tokenIdMap, s);
}
}
}
dataset.close();
}
return tokenIdMap;
}
示例3: getAllEsoEvents
import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
static ArrayList<String> getAllEsoEvents (Dataset dataset, ArrayList<String> esoTypes) {
ArrayList<String> events = new ArrayList<String>();
Iterator<String> it = dataset.listNames();
while (it.hasNext()) {
String name = it.next();
if (name.equals(instanceGraph)) {
Model namedModel = dataset.getNamedModel(name);
StmtIterator siter = namedModel.listStatements();
while (siter.hasNext()) {
Statement s = siter.nextStatement();
// System.out.println("s.toString() = " + s.toString());
if (s.getPredicate().toString().endsWith("#type")) {
for (int i = 0; i < esoTypes.size(); i++) {
String esoType = esoTypes.get(i);
if (s.getObject().toString().endsWith(esoType)) {
String subject = s.getSubject().getURI();
if (!events.contains(subject)) {
events.add(subject);
}
break;
}
}
}
}
}
}
return events;
}
示例4: addToJenaDataSet
import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
public void addToJenaDataSet (Dataset ds, Model provenanceModel) {
Model relationModel = ds.getNamedModel(this.id);
Resource subject = relationModel.createResource(this.getSubject());
Resource object = relationModel.createResource(this.getObject());
/// since we no longer distinguish places from actors, we now check the predicates for propbank AM-LOC
/// if so we use sem:hasPlace otherwise we take the semType value from the hassem predicate
Property semProperty = null;
boolean PLACE = false;
boolean ACTOR = false;
for (int i = 0; i < predicates.size(); i++) {
String predicate = predicates.get(i);
if (predicate.equalsIgnoreCase("hasFactBankValue")) {
Property factProperty = relationModel.createProperty(ResourcesUri.nwrvalue + predicate);
subject.addProperty(factProperty, this.getObject()); /// creates the literal as value
}
else {
semProperty = getSemRelationProperty(predicate);
if (semProperty!=null
&& semProperty != Sem.hasSubType
/// unknown
&& semProperty!=Sem.hasPlace && semProperty!=Sem.hasActor)
//// we decide next if the role is that of an actor or a place
{
subject.addProperty(semProperty, object);
}
else {
if (semProperty.equals(Sem.hasSubType)) {
predicate = getRoleRelation(predicate);
if (!predicate.isEmpty()) {
Property srlProperty = relationModel.createProperty(predicate);
subject.addProperty(srlProperty, object);
String predicateValue = predicate;
int idx = predicateValue.lastIndexOf("/");
if (idx > -1) predicateValue = predicateValue.substring(idx + 1);
if (RoleLabels.isLOCATION(predicateValue)) {
PLACE = true;
} else {
ACTOR = true;
}
}
}
}
}
}
//// if at the end of the loop we detected a location role
if (PLACE) {
subject.addProperty(Sem.hasPlace, object);
}
//// if at the end of the loop we detect an actor role
if (ACTOR) {
subject.addProperty(Sem.hasActor, object);
}
Resource provenanceResource = provenanceModel.createResource(this.id);
for (int i = 0; i < nafMentions.size(); i++) {
NafMention nafMention = nafMentions.get(i);
Property property = provenanceModel.createProperty(ResourcesUri.gaf+"denotedBy");
Resource targetResource = provenanceModel.createResource(nafMention.toString());
provenanceResource.addProperty(property, targetResource);
}
}
示例5: getQualityMetadataObservations
import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
/**
* Extract all observations from a dataset
* @param dataset URI
* @return a HashMap with the metric type being the key and a list of observations
*/
public static Map<String,List<Observation>> getQualityMetadataObservations(String datasetMetadataUri){
Dataset d = RDFDataMgr.loadDataset(datasetMetadataUri);
Resource graph = d.getDefaultModel().listSubjectsWithProperty(RDF.type, DAQ.QualityGraph).next();
Model qualityMD = d.getNamedModel(graph.getURI());
Map<String,List<Observation>> map = new HashMap<String,List<Observation>>(); // metric resource, list<observations>
ResIterator iter = qualityMD.listResourcesWithProperty(RDF.type, CUBE.Observation);
while(iter.hasNext()){
Resource res = iter.next();
//get metric uri
Resource metricURI = qualityMD.listObjectsOfProperty(res, DAQ.metric).next().asResource();
//get metric type
Resource metricType = qualityMD.listObjectsOfProperty(metricURI, RDF.type).next().asResource();
//get datetime
Date date = null;
try {
date = toDateFormat(qualityMD.listObjectsOfProperty(res, DC.date).next().asLiteral().getValue().toString());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//get value
Double value = qualityMD.listObjectsOfProperty(res, DAQ.value).next().asLiteral().getDouble();
//get computedOn
Resource computedOn = qualityMD.listObjectsOfProperty(res,DAQ.computedOn).next().asResource();
//data cube
Resource cubeDS = qualityMD.listObjectsOfProperty(res, CUBE.dataSet).next().asResource();
Observation obs = new Observation(res, date, value, null,computedOn, cubeDS);
if (!(map.containsKey(metricType.toString()))){
map.put(metricType.toString(), new ArrayList<Observation>());
}
map.get(metricType.toString()).add(obs);
}
return map;
}
示例6: tdbload
import com.hp.hpl.jena.query.Dataset; //導入方法依賴的package包/類
public void tdbload() {
Dataset dataset = TDBFactory.createDataset("tdb");
Model model = dataset.getNamedModel("fdg");
model.read("category_labels_en.nq");
if (model.READ){
System.out.println("right!!");
}
Query q = QueryFactory.create(query);
QueryExecution qe = QueryExecutionFactory.create(q, model);
ResultSet rs = qe.execSelect();
ResultSetFormatter.out(rs);
}