Java Code Examples for com.hp.hpl.jena.rdf.model.Model#createProperty()

The following examples show how to use com.hp.hpl.jena.rdf.model.Model#createProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CSPARQLAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) throws NumberFormatException, IOException {
	Model m = ModelFactory.createDefaultModel();
	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type,
	// m.createResource(RDFFileManager.saoPrefix + "StreamData"));
	Resource serviceID = m.createResource(ed.getServiceId());
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// Resource property = m.createResource(s.split("\\|")[2]);
	// property.addProperty(RDF.type, m.createResource(s.split("\\|")[0]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
	// Literal l;
	// System.out.println("Annotating: " + observedProperty.toString());
	// if (observedProperty.contains("AvgSpeed"))
	observation.addLiteral(hasValue, ((AarhusParkingObservation) so).getVacancies());
	// observation.addLiteral(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
	// ((AarhusParkingObservation) so).getGarageCode());
	return m.listStatements().toList();
}
 
Example 2
Source File: Mapping.java    From xcurator with Apache License 2.0 6 votes vote down vote up
public static Set<String> getAllTypes(Model model, String typePrefix) {
    Resource rootResource = model.createResource(typePrefix);

    com.hp.hpl.jena.rdf.model.Property classProperty = model.createProperty("http://dblab.cs.toronto.edu/project/xcurator/0.1#classes");
    Bag classBag = model.createBag("http://dblab.cs.toronto.edu/project/xcurator/0.1#classBag");
    model.add(rootResource, classProperty, classBag);

    Set<String> ret = new HashSet<String>();

    NodeIterator iterator = classBag.iterator();
    while (iterator.hasNext()) {
        Resource resource = (Resource) iterator.next();
        ret.add(resource.getURI());
    }

    return ret;
}
 
Example 3
Source File: RDFFileManager.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
private static void createSelections(Resource patternNode, Model m, EventPattern ep) {
	Property hasSelection = m.createProperty(cesPrefix + "hasSelection");
	Property hasNodeId = m.createProperty(cesPrefix + "hasNodeId");
	Property hasSelectedProperty = m.createProperty(cesPrefix + "selectedProperty");
	// System.out.p rintln("Creating selections:------------");
	for (Selection sel : ep.getSelections()) {
		// System.out.println("SEL: " + sel.toString());
		Resource pName = m.createResource(sel.getPropertyName());
		String nodeId = sel.getProvidedBy();
		// Resource pType = m.createResource(sel.getPropertyType());
		// EventDeclaration ed;
		// if (ep.isQuery() && sel.getOriginalED() != null)
		// ed = sel.getOriginalED();
		// Resource foi = m.createResource(sel.getFoi());
		patternNode.addProperty(
				hasSelection,
				m.createResource().addProperty(RDF.type, m.createResource(cesPrefix + "Selection"))
						.addProperty(hasNodeId, m.createLiteral(nodeId)).addProperty(hasSelectedProperty, pName));
		// if (ep.isQuery()) {// add property type and foi for query
		// pName.addProperty(RDF.type, pType).addProperty(m.createProperty(ssnPrefix + "isPropertyOf"), foi);
		// }
	}
}
 
Example 4
Source File: CQELSAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation wo) throws NumberFormatException, IOException {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + wo.getObId() + UUID.randomUUID());
			// wo.setObId(observation.toString());
			CityBench.obMap.put(observation.toString(), wo);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			if (s.contains("Temperature"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getTemperature());
			else if (s.toString().contains("Humidity"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getHumidity());
			else if (s.toString().contains("WindSpeed"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getWindSpeed());
		}
	return m.listStatements().toList();
}
 
Example 5
Source File: CQELSAarhusPollutionStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
			// so.setObId(RDFFileManager.defaultPrefix + observation.toString());
			CityBench.obMap.put(observation.toString(), so);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			observation.addLiteral(hasValue, ((PollutionObservation) so).getApi());
		}
	return m.listStatements().toList();
}
 
Example 6
Source File: CQELSAarhusParkingStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) {
	Model m = ModelFactory.createDefaultModel();
	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type,
	// m.createResource(RDFFileManager.saoPrefix + "StreamData"));
	Resource serviceID = m.createResource(ed.getServiceId());
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// Resource property = m.createResource(s.split("\\|")[2]);
	// property.addProperty(RDF.type, m.createResource(s.split("\\|")[0]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
	// Literal l;
	// System.out.println("Annotating: " + observedProperty.toString());
	// if (observedProperty.contains("AvgSpeed"))
	observation.addLiteral(hasValue, ((AarhusParkingObservation) so).getVacancies());
	// observation.addLiteral(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
	// ((AarhusParkingObservation) so).getGarageCode());
	return m.listStatements().toList();
}
 
Example 7
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
public static List<Statement> getAarhusParkingStatements(SensorObservation so, EventDeclaration ed) {
	Model m = ModelFactory.createDefaultModel();
	Resource observation = m.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
	CityBench.obMap.put(observation.toString(), so);
	observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
	// observation.addProperty(RDF.type,
	// m.createResource(RDFFileManager.saoPrefix + "StreamData"));
	Resource serviceID = m.createResource(ed.getServiceId());
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
	// Resource property = m.createResource(s.split("\\|")[2]);
	// property.addProperty(RDF.type, m.createResource(s.split("\\|")[0]));
	observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
			m.createResource(ed.getPayloads().get(0).split("\\|")[2]));
	Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
	// Literal l;
	// System.out.println("Annotating: " + observedProperty.toString());
	// if (observedProperty.contains("AvgSpeed"))
	observation.addLiteral(hasValue, ((AarhusParkingObservation) so).getVacancies());
	// observation.addLiteral(m.createProperty(RDFFileManager.ssnPrefix + "featureOfInterest"),
	// ((AarhusParkingObservation) so).getGarageCode());
	return m.listStatements().toList();
}
 
Example 8
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
public static List<Statement> getAarhusWeatherStatements(SensorObservation wo, EventDeclaration ed) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + wo.getObId() + UUID.randomUUID());
			// wo.setObId(observation.toString());
			CityBench.obMap.put(observation.toString(), wo);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			if (s.contains("Temperature"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getTemperature());
			else if (s.toString().contains("Humidity"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getHumidity());
			else if (s.toString().contains("WindSpeed"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getWindSpeed());
		}
	return m.listStatements().toList();
}
 
Example 9
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
public static List<Statement> getAarhusPollutionStatement(SensorObservation so, EventDeclaration ed) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
			// so.setObId(RDFFileManager.defaultPrefix + observation.toString());
			CityBench.obMap.put(observation.toString(), so);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			observation.addLiteral(hasValue, ((PollutionObservation) so).getApi());
		}
	return m.listStatements().toList();
}
 
Example 10
Source File: CSPARQLAarhusPollutionStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation so) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + so.getObId() + UUID.randomUUID());
			// so.setObId(RDFFileManager.defaultPrefix + observation.toString());
			CityBench.obMap.put(observation.toString(), so);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			observation.addLiteral(hasValue, ((PollutionObservation) so).getApi());
		}
	return m.listStatements().toList();
}
 
Example 11
Source File: CSPARQLAarhusWeatherStream.java    From Benchmark with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation wo) throws NumberFormatException, IOException {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String s : ed.getPayloads()) {
			Resource observation = m
					.createResource(RDFFileManager.defaultPrefix + wo.getObId() + UUID.randomUUID());
			// wo.setObId(observation.toString());
			CityBench.obMap.put(observation.toString(), wo);
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));
			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(s.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			if (s.contains("Temperature"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getTemperature());
			else if (s.toString().contains("Humidity"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getHumidity());
			else if (s.toString().contains("WindSpeed"))
				observation.addLiteral(hasValue, ((WeatherObservation) wo).getWindSpeed());
		}
	return m.listStatements().toList();
}
 
Example 12
Source File: CQELSAarhusTrafficStream.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected List<Statement> getStatements(SensorObservation data) throws NumberFormatException, IOException {
	// return DataWrapper.getAarhusTrafficStatements((AarhusTrafficObservation) data, ed);
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String pStr : ed.getPayloads()) {
			// if (s.contains("EstimatedTime")) {
			// Resource observedProperty = m.createResource(s);
			data = (AarhusTrafficObservation) data;
			String obId = data.getObId();
			Resource observation = m.createResource(RDFFileManager.defaultPrefix + obId + UUID.randomUUID());
			CityBench.obMap.put(observation.toString(), data);
			// data.setObId(observation.toString());
			// System.out.println("OB: " + observation.toString());
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(pStr.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			// System.out.println("Annotating: " + observedProperty.toString());
			if (pStr.contains("AvgSpeed"))
				observation.addLiteral(hasValue, ((AarhusTrafficObservation) data).getAverageSpeed());
			else if (pStr.contains("VehicleCount")) {
				double value = ((AarhusTrafficObservation) data).getVehicle_count();
				observation.addLiteral(hasValue, value);
			} else if (pStr.contains("MeasuredTime"))
				observation.addLiteral(hasValue, ((AarhusTrafficObservation) data).getAvgMeasuredTime());
			else if (pStr.contains("EstimatedTime"))
				observation.addLiteral(hasValue, ((AarhusTrafficObservation) data).getEstimatedTime());
			else if (pStr.contains("CongestionLevel"))
				observation.addLiteral(hasValue, ((AarhusTrafficObservation) data).getCongestionLevel());
			// break;
			// }
		}
	return m.listStatements().toList();
}
 
Example 13
Source File: DataWrapper.java    From Benchmark with GNU General Public License v3.0 5 votes vote down vote up
public static List<Statement> getAarhusTrafficStatements(AarhusTrafficObservation data, EventDeclaration ed) {
	Model m = ModelFactory.createDefaultModel();
	if (ed != null)
		for (String pStr : ed.getPayloads()) {
			// if (s.contains("EstimatedTime")) {
			// Resource observedProperty = m.createResource(s);
			String obId = data.getObId();
			Resource observation = m.createResource(RDFFileManager.defaultPrefix + obId + UUID.randomUUID());
			CityBench.obMap.put(observation.toString(), data);
			// data.setObId(observation.toString());
			// System.out.println("OB: " + observation.toString());
			observation.addProperty(RDF.type, m.createResource(RDFFileManager.ssnPrefix + "Observation"));

			Resource serviceID = m.createResource(ed.getServiceId());
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedBy"), serviceID);
			observation.addProperty(m.createProperty(RDFFileManager.ssnPrefix + "observedProperty"),
					m.createResource(pStr.split("\\|")[2]));
			Property hasValue = m.createProperty(RDFFileManager.saoPrefix + "hasValue");
			// System.out.println("Annotating: " + observedProperty.toString());
			if (pStr.contains("AvgSpeed"))
				observation.addLiteral(hasValue, data.getAverageSpeed());
			else if (pStr.contains("VehicleCount")) {
				double value = data.getVehicle_count();
				observation.addLiteral(hasValue, value);
			} else if (pStr.contains("MeasuredTime"))
				observation.addLiteral(hasValue, data.getAvgMeasuredTime());
			else if (pStr.contains("EstimatedTime"))
				observation.addLiteral(hasValue, data.getEstimatedTime());
			else if (pStr.contains("CongestionLevel"))
				observation.addLiteral(hasValue, data.getCongestionLevel());
			// break;
			// }
		}
	return m.listStatements().toList();
	// return null;

}
 
Example 14
Source File: SemRelation.java    From EventCoreference with Apache License 2.0 5 votes vote down vote up
public void addToJenaDataSetSimple (HashMap<String, String> rename, Dataset ds) {

        Model relationModel = ds.getNamedModel(this.id);
        if (rename.containsKey(this.getSubject())) { this.setSubject(rename.get(this.getSubject())); }
        if (rename.containsKey(this.getObject())) { this.setObject(rename.get(this.getObject())); }
        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;
        for (int i = 0; i < predicates.size(); i++) {
            String predicate = predicates.get(i);
            semProperty = getSemRelationProperty(predicate);
            if (isTemporalSemRelationProperty(predicate)) {
                    subject.addProperty(semProperty, object);
            }
            else {
                if (!semProperty.getLocalName().equals(Sem.hasActor.getLocalName()) &&
                    !semProperty.getLocalName().equals(Sem.hasPlace.getLocalName())) {
                    predicate = getSimpleRoleRelation(predicate);
                    //System.err.println("predicate:"+predicate);
                    //predicate = getFramenetRoleRelation(predicates.get(i));
                    if (!predicate.isEmpty()) {
                        Property srlProperty = relationModel.createProperty(predicate);
                        subject.addProperty(srlProperty, object);
                    }
                }
            }
        }

    }
 
Example 15
Source File: SemObject.java    From EventCoreference with Apache License 2.0 5 votes vote down vote up
public void addToJenaOldBaileySimpleModel(SimpleTaxonomy simpleTaxonomy, HashMap<String, String> rename, Model model, Resource type) {
        Resource resource = model.createResource(this.getURI());
        Resource conceptResource = model.createResource(ResourcesUri.nwrontology+this.type);
        resource.addProperty(RDF.type, conceptResource);

        //// Top phrase
        String topLabel = this.getTopPhraseAsLabel();
        if (!topLabel.isEmpty()) {
            //Property property = model.createProperty(ResourcesUri.skos+SKOS.PREF_LABEL.getLocalName());
            //resource.addProperty(property, model.createLiteral(this.getTopPhraseAsLabel()));
            //// instead of

            if (type.equals(SemObject.EVENT) ) {
                resource = model.createResource(this.getURI() + "_" + topLabel);
                rename.put(this.getURI(), this.getURI() + "_" + topLabel);
            }
            for (int i = 0; i < phraseCounts.size(); i++) {
                PhraseCount phraseCount = phraseCounts.get(i);
                // resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhraseCount()));
/*                if (!phraseCount.getPhrase().equalsIgnoreCase(getTopPhraseAsLabel()) && goodPhrase(phraseCount)) {
                    resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
                }*/
                if (goodPhrase(phraseCount)) {
                    resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
                }
            }
        }

        addAllConceptsToResourceForOldBailey(simpleTaxonomy, rename, resource, model);
        for (int i = 0; i < nafMentions.size(); i++) {
           NafMention nafMention = nafMentions.get(i);
           Property property = model.createProperty(ResourcesUri.gaf + "denotedBy");
           Resource targetResource = null;
           targetResource = model.createResource(nafMention.toStringFull());
           resource.addProperty(property, targetResource);
        }
    }
 
Example 16
Source File: SemTime.java    From EventCoreference with Apache License 2.0 5 votes vote down vote up
public void addToJenaModelTimeInstant(Model model, OwlTime owlTime) {
    this.getOwlTime().addToJenaModelOwlTimeInstant(model);

    Resource resource = model.createResource(this.getURI());
    for (int i = 0; i < this.getPhraseCounts().size(); i++) {
        PhraseCount phraseCount = this.getPhraseCounts().get(i);
        if (!phraseCount.getPhrase().isEmpty()) {
            resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
        }
    }

    resource.addProperty(RDF.type, Sem.Time);

    Resource aResource = model.createResource(ResourcesUri.owltime + "Instant");
    resource.addProperty(RDF.type, aResource);

    Resource value = model.createResource(owlTime.getDateStringURI());
    Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
    resource.addProperty(property, value);

    for (int i = 0; i < this.getNafMentions().size(); i++) {
        NafMention nafMention = this.getNafMentions().get(i);
        Property gaf = model.createProperty(ResourcesUri.gaf + "denotedBy");
        Resource targetResource = model.createResource(nafMention.toString());
        resource.addProperty(gaf, targetResource);
    }
}
 
Example 17
Source File: SemTime.java    From EventCoreference with Apache License 2.0 5 votes vote down vote up
public void addToJenaModelDocTimeInstant(Model model) {

        this.getOwlTime().addToJenaModelOwlTimeInstant(model);

        Resource resource = model.createResource(this.getURI());
        if (!this.getTopPhraseAsLabel().isEmpty()) {
            resource.addProperty(RDFS.label, model.createLiteral(this.getTopPhraseAsLabel()));
        }

        /*for (int i = 0; i < phraseCounts.size(); i++) {
            PhraseCount phraseCount = phraseCounts.get(i);
            resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
        }*/

        //resource.addProperty(RDF.type, Sem.Time);
        // System.out.println("this.getOwlTime().toString() = " + this.getOwlTime().toString());
        Resource interval = model.createResource(ResourcesUri.owltime + "Instant");
        resource.addProperty(RDF.type, interval);

        Resource value = model.createResource(this.getOwlTime().getDateStringURI());
        Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
        resource.addProperty(property, value);

        for (int i = 0; i < this.getNafMentions().size(); i++) {
            NafMention nafMention = this.getNafMentions().get(i);
            Property gaf = model.createProperty(ResourcesUri.gaf + "denotedBy");
            Resource targetResource = model.createResource(nafMention.toString());
            resource.addProperty(gaf, targetResource);

        }
    }
 
Example 18
Source File: SemTime.java    From EventCoreference with Apache License 2.0 5 votes vote down vote up
public void addToJenaModelTimeInterval(Model model) {
    this.getOwlTime().addToJenaModelOwlTimeInstant(model);

    Resource resource = model.createResource(this.getURI());
    for (int i = 0; i < this.getPhraseCounts().size(); i++) {
        PhraseCount phraseCount = this.getPhraseCounts().get(i);
        if (!phraseCount.getPhrase().isEmpty()) {
            resource.addProperty(RDFS.label, model.createLiteral(phraseCount.getPhrase()));
        }
    }

    resource.addProperty(RDF.type, Sem.Time);

    Resource interval = model.createResource(ResourcesUri.owltime + "Interval");
    resource.addProperty(RDF.type, interval);

    Resource value = model.createResource(this.getOwlTime().getDateStringURI());
    Property property = model.createProperty(ResourcesUri.owltime + "inDateTime");
    resource.addProperty(property, value);

    for (int i = 0; i < this.getNafMentions().size(); i++) {
        NafMention nafMention = this.getNafMentions().get(i);
        Property gaf = model.createProperty(ResourcesUri.gaf + "denotedBy");
        Resource targetResource = model.createResource(nafMention.toString());
        resource.addProperty(gaf, targetResource);

    }

}
 
Example 19
Source File: RDFFileManager.java    From Benchmark with GNU General Public License v3.0 4 votes vote down vote up
private static Map<String, List<Filter>> extractFilterMap(String nodeId, List<RDFNode> filters, Model m,
		EventPattern ep) {
	Map<String, List<Filter>> results = new HashMap<String, List<Filter>>();
	// if (!nodeId.equals(""))
	// results.put(nodeId, new ArrayList<Filter>());
	for (RDFNode filterNode : filters) {
		// RDFNode filterNode = filters.next();
		RDFNode payload = m.getProperty((Resource) filterNode, m.createProperty(cesPrefix + "onPayload"))
				.getObject();
		int op = 0;
		Object val;
		Property lt = m.createProperty(emvoPrefix + "lessThan");
		Property leq = m.createProperty(emvoPrefix + "lessOrEqualThan");
		Property gt = m.createProperty(emvoPrefix + "greaterThan");
		Property geq = m.createProperty(emvoPrefix + "greaterOrEqualThan");
		Property eq = m.createProperty(emvoPrefix + "equals");
		if (m.contains((Resource) filterNode, lt)) {
			op = Filter.lt;
			val = m.getProperty((Resource) filterNode, lt).getLiteral().getValue();
		} else if (m.contains((Resource) filterNode, leq)) {
			op = Filter.leq;
			val = m.getProperty((Resource) filterNode, leq).getLiteral().getValue();
		} else if (m.contains((Resource) filterNode, gt)) {
			op = Filter.gt;
			val = m.getProperty((Resource) filterNode, gt).getLiteral().getValue();
		} else if (m.contains((Resource) filterNode, geq)) {
			op = Filter.geq;
			val = m.getProperty((Resource) filterNode, geq).getLiteral().getValue();
		} else {
			op = Filter.eq;
			val = m.getProperty((Resource) filterNode, eq).getLiteral().getValue();
		}
		Filter f = new Filter(payload.toString(), val, op);
		// System.out.println("filter: " + f);
		// if (!nodeId.equals(""))
		// results.get(nodeId).add(f);
		// else {
		if (m.getProperty((Resource) filterNode, m.createProperty(cesPrefix + "onEvent")) != null) {
			RDFNode eventId = m.getProperty((Resource) filterNode, m.createProperty(cesPrefix + "onEvent"))
					.getObject();
			// if (eventId != null) {
			if (results.get(eventId) == null)
				results.put(eventId.toString(), new ArrayList<Filter>());
			results.get(eventId.toString()).add(f);
			// if(ep.getNodeById(eventId.toString())==null)
			// ep.getEds().add(extractEDByID(eventId))
		} else {
			if (results.get(nodeId) == null)
				results.put(nodeId, new ArrayList<Filter>());
			results.get(nodeId).add(f);
		}
		// }
	}
	return results;
}
 
Example 20
Source File: SemRelation.java    From EventCoreference with Apache License 2.0 4 votes vote down vote up
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 (isTemporalSemRelationProperty(predicate)) {
                        subject.addProperty(semProperty, object);
                        subject.addProperty(Sem.hasTime, object); /// additional hasTime relation to generalize
                }
                else {
                    if (!semProperty.getLocalName().equals(Sem.hasActor.getLocalName()) &&
                        !semProperty.getLocalName().equals(Sem.hasPlace.getLocalName())) {
                        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);

        }
    }