本文整理汇总了Java中org.apache.clerezza.rdf.core.TripleCollection类的典型用法代码示例。如果您正苦于以下问题:Java TripleCollection类的具体用法?Java TripleCollection怎么用?Java TripleCollection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TripleCollection类属于org.apache.clerezza.rdf.core包,在下文中一共展示了TripleCollection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: transform
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
/**
* Performs the actual transformation mapping the data extracted from OSM XML data to a Clerezza graph.
* @return
*/
public TripleCollection transform(){
TripleCollection resultGraph = new SimpleMGraph();
processXmlBinary();
for(String wayId: osmWayNodeMap.keySet()) {
OsmWay wayObj = osmWayNodeMap.get(wayId);
UriRef wayUri = new UriRef("http://fusepoolp3.eu/osm/way/" + wayId);
resultGraph.add(new TripleImpl(wayUri, RDF.type, new UriRef("http://schema.org/PostalAddress")));
resultGraph.add(new TripleImpl(wayUri, new UriRef("http://schema.org/streetAddress"), new PlainLiteralImpl(wayObj.getTagName())));
UriRef geometryUri = new UriRef("http://fusepoolp3.eu/osm/geometry/" + wayId);
resultGraph.add(new TripleImpl(wayUri, new UriRef("http://www.opengis.net/ont/geosparql#geometry"), geometryUri));
String linestring = getWktLineString(wayObj.getNodeReferenceList());
resultGraph.add(new TripleImpl(geometryUri, new UriRef("http://www.opengis.net/ont/geosparql#asWKT"), new PlainLiteralImpl(linestring)));
}
return resultGraph;
}
开发者ID:fusepoolP3,项目名称:p3-osm-transformer,代码行数:21,代码来源:OsmXmlParser.java
示例2: testTransform
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
@Test
public void testTransform() throws IOException {
String osmDataUrl = RestAssured.baseURI + "/data/" + MOCK_OSM_SERVER_DATA ;
parser = new OsmXmlParser(osmDataUrl);
long startTime = System.currentTimeMillis();
System.out.println("transform() Start time: " + startTime);
TripleCollection graph = parser.transform();
Iterator<Triple> igraph = graph.iterator();
while(igraph.hasNext()){
Triple t = igraph.next();
System.out.println(t.getSubject() + " " + t.getPredicate() + " " + t.getObject());
}
long stopTime = System.currentTimeMillis();
System.out.println("transform() Stop time: " + stopTime);
double time = (stopTime - startTime) / 1000.0;
System.out.println("transform() Elapsed time: " + time + " sec." );
System.out.println();
}
开发者ID:fusepoolP3,项目名称:p3-osm-transformer,代码行数:21,代码来源:OsmXmlParserTest.java
示例3: hasValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
/**
* Checks if the value is parsed of the parsed triple filter.
* IMPARTANT: This method expects that exactly one of subject, predicate and
* object is <code>null</code>
* @param source the triple collection
* @param sub subject filter (<code>null</code> for wildcard)
* @param pred predicate filter (<code>null</code> for wildcard)
* @param obj Object filter (<code>null</code> for wildcard)
* @param value the value
* @return <code>true</code> if the parsed value is part of the triples selected
* by the parsed triple pattern.
*/
public boolean hasValue(TripleCollection source, NonLiteral sub, UriRef pred, Resource obj, Resource value){
if(value == null){
return false;
}
Iterator<Triple> it = source.filter(sub, pred, obj);
while(it.hasNext()){
Triple t = it.next();
Resource act = sub == null ? t.getSubject() : pred == null
? t.getPredicate() : t.getObject();
if(act.equals(value)){
return true;
}
}
return false;
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:28,代码来源:Fise2FamEngine.java
示例4: assertOptValues
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private <T extends Resource> Set<T> assertOptValues(TripleCollection graph,
NonLiteral subject, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(subject, property, null);
if(!it.hasNext()){
return Collections.emptySet();
}
Set<T> values = new HashSet<T>();
while(it.hasNext()){
Resource value = it.next().getObject();
assertTrue(type.getSimpleName()+" expected but value "+ value +
" had the type "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
values.add(type.cast(value));
}
return values;
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:17,代码来源:Fise2FamEngineTest.java
示例5: generateRdf
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
/**
* Get SIOC content from the RDF as text and return it.
*
* @param entity
* @return
* @throws IOException
*/
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
String text = "";
Graph graph = Parser.getInstance().parse(entity.getData(), "text/turtle");
Iterator<Triple> triples = graph.filter(null, SIOC.content, null);
if (triples.hasNext()) {
Literal literal = (Literal) triples.next().getObject();
text = literal.getLexicalForm();
}
final TripleCollection result = new SimpleMGraph();
final Resource resource = entity.getContentLocation() == null
? new BNode()
: new UriRef(entity.getContentLocation().toString());
final GraphNode node = new GraphNode(resource, result);
node.addProperty(RDF.type, TEXUAL_CONTENT);
node.addPropertyValue(SIOC.content, text);
node.addPropertyValue(new UriRef("http://example.org/ontology#textLength"), text.length());
return result;
}
开发者ID:fusepoolP3,项目名称:p3-pipeline-transformer,代码行数:28,代码来源:SimpleRdfConsumingTransformer.java
示例6: generateRdf
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
String rdfDataFormat = SupportedFormat.TURTLE;
InputStream configIn = null;
String queryString = entity.getRequest().getQueryString();
log.info("Query string: " + queryString);
//String configUri = getRequestParamValue(queryString, "config");
String configUri = entity.getRequest().getParameter("config");
log.info("Config file URI: " + configUri);
if(configUri != null) {
configIn = getRemoteConfigFile(configUri);
}
final InputStream inputRdfData = entity.getData();
TripleCollection duplicates = findSameEntities(inputRdfData, rdfDataFormat, configIn);
return duplicates;
}
开发者ID:fusepoolP3,项目名称:p3-silkdedup,代码行数:19,代码来源:DuplicatesTransformer.java
示例7: getPoint
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
/**
* Extracts one spatial point or event from the client data.
* @param graph
* @return
* @throws ParseException
*/
public WGS84Point getPoint(TripleCollection graph) {
WGS84Point point = new WGS84Point();
NonLiteral pointRef = graph.filter(null, geo_lat, null).next().getSubject();
String latitude = ( (TypedLiteral) graph.filter(pointRef, geo_lat, null).next().getObject() ).getLexicalForm();
String longitude = ( (TypedLiteral) graph.filter(pointRef, geo_long, null).next().getObject() ).getLexicalForm();
point.setUri(pointRef.toString());
point.setLat(Double.valueOf(latitude));
point.setLong(Double.valueOf(longitude));
// look for events linked to places
if(graph.filter(null, schema_startDate, null).hasNext()){
String startDate = ( (TypedLiteral) graph.filter(null, schema_startDate, null).next().getObject()).getLexicalForm();
String endDate = ( (TypedLiteral) graph.filter(null, schema_endDate, null).next().getObject()).getLexicalForm();
point.setStartDate(startDate);
point.setEndDate(endDate);
}
return point;
}
开发者ID:fusepoolP3,项目名称:p3-geo-enriching-transformer,代码行数:24,代码来源:SpatialDataEnhancer.java
示例8: reconcileCommand
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
/**
* Reconciles a source graph with a target graph. The result of the
* reconciliation is an equivalence set stored in the interlink graph of the
* pipe. The graph used as source is the source rdf graph.
*/
private void reconcileCommand(DataSet dataSet, UriRef sourceGraphRef, UriRef targetGraphRef, String selectedInterlinker) {
if (graphExists(sourceGraphRef)) {
// Get the source graph from the triple store
LockableMGraph sourceGraph = dataSet.getSourceGraph();
// reconcile the source graph with the target graph
Interlinker interlinker = interlinkers.get(selectedInterlinker);
TripleCollection owlSameAs = interlinker.interlink(sourceGraph, targetGraphRef);
if (owlSameAs.size() > 0) {
LockableMGraph sameAsGraph = dataSet.getInterlinksGraph();
sameAsGraph.addAll(owlSameAs);
// add a reference of the equivalence set to the source graph
dlcGraphProvider.getDlcGraph().add(new TripleImpl(dataSet.getInterlinksGraphRef(), DLC.subjectsTarget, sourceGraphRef));
// add a reference of the equivalence set to the target graph
dlcGraphProvider.getDlcGraph().add(new TripleImpl(dataSet.getInterlinksGraphRef(), DLC.objectsTarget, targetGraphRef));
}
}
}
开发者ID:fusepool,项目名称:datalifecycle,代码行数:29,代码来源:SourcingAdmin.java
示例9: parse
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
@Override
public RDFDataset parse(Object input) throws JsonLdError {
count = 0;
final Map<BNode, String> bNodeMap = new HashMap<BNode, String>(1024);
final RDFDataset result = new RDFDataset();
if (input instanceof TripleCollection) {
for (final Triple t : ((TripleCollection) input)) {
handleStatement(result, t, bNodeMap);
}
}
bNodeMap.clear(); // help gc
return result;
}
开发者ID:jsonld-java,项目名称:jsonld-java-clerezza,代码行数:14,代码来源:ClerezzaRDFParser.java
示例10: getAddress
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private Address getAddress(TripleCollection inputGraph) {
Address addr = new Address();
Iterator<Triple> itriple = inputGraph.filter(null,schema_streetAddress,null);
while ( itriple.hasNext() ) {
Triple triple = itriple.next();
UriRef addressUri = (UriRef) triple.getSubject();
addr.setStreetAddress( ((PlainLiteralImpl) triple.getObject()).getLexicalForm() );
// get locality
Iterator<Triple> addresslocalityIter = inputGraph.filter(addressUri, schema_addressLocality, null) ;
if ( addresslocalityIter != null ) {
while ( addresslocalityIter.hasNext() ) {
String locality = ((PlainLiteralImpl) addresslocalityIter.next().getObject()).getLexicalForm();
if ( ! "".equals(locality) ) {
addr.setLocality( locality );
}
}
}
// get country code
Iterator<Triple> addressCountryIter = inputGraph.filter(addressUri, schema_addressCountry, null) ;
if ( addressCountryIter != null ) {
while ( addressCountryIter.hasNext() ) {
String countryCode = ((PlainLiteralImpl) addressCountryIter.next().getObject()).getLexicalForm();
if ( ! "".equals( countryCode ) ) {
addr.setCountryCode( countryCode );
}
}
}
}
return addr;
}
开发者ID:fusepoolP3,项目名称:p3-osm-transformer,代码行数:33,代码来源:OsmRdfTransformer.java
示例11: assertOASelector
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private void assertOASelector(ContentItem contentItem, UriRef selector){
TripleCollection graph = contentItem.getMetadata();
Set<UriRef> types = assertHasValues(graph, selector, RDF_TYPE, UriRef.class);
assertTrue(types.contains(OA_TEXT_POSITION_SELECTOR));
assertTrue(types.contains(OA_TEXT_QUOTE_SELECTOR));
TypedLiteral startIndex = assertSingleValue(graph, selector, OA_START, TypedLiteral.class);
assertEquals(XSD.int_, startIndex.getDataType());
int start = lf.createObject(Integer.class, startIndex);
TypedLiteral endIndex = assertSingleValue(graph, selector, OA_END, TypedLiteral.class);
assertEquals(XSD.int_, endIndex.getDataType());
int end = lf.createObject(Integer.class, endIndex);
assertTrue(end > start);
//assert the selector URI
assertSelectorUri(contentItem, selector, start, end);
PlainLiteral exact = assertSingleValue(graph, selector, OA_EXACT, PlainLiteral.class);
if(exact != null){
assertEquals(CONTENT_LANGUAGE, exact.getLanguage());
assertEquals(CONTENT.substring(start,end), exact.getLexicalForm());
}
PlainLiteral prefix = assertSingleValue(graph, selector, OA_PREFIX, PlainLiteral.class);
if(prefix != null){
assertEquals(CONTENT_LANGUAGE, prefix.getLanguage());
assertTrue(CONTENT.substring(0,start).endsWith(prefix.getLexicalForm()));
}
PlainLiteral suffix = assertSingleValue(graph, selector, OA_SUFIX, PlainLiteral.class);
if(suffix != null){
assertNotNull("if oa:suffix is present also oa:prefix is expected!",prefix);
assertEquals(CONTENT_LANGUAGE, suffix.getLanguage());
assertTrue(CONTENT.substring(end,CONTENT.length()).startsWith(suffix.getLexicalForm()));
} else {
assertNull("if oa:prefix is present als oa:suffix is expected!",prefix);
}
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:39,代码来源:Fise2FamEngineTest.java
示例12: assertHasValues
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private <T extends Resource> Set<T> assertHasValues(TripleCollection graph,
NonLiteral subject, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(subject, property, null);
assertTrue("missing value for property "+property+ "on subject "+subject, it.hasNext());
Set<T> values = new HashSet<T>();
while(it.hasNext()){
Resource value = it.next().getObject();
assertTrue(type.getSimpleName()+" expected but value "+ value +
" had the type "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
values.add(type.cast(value));
}
return values;
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:15,代码来源:Fise2FamEngineTest.java
示例13: assertHasInvValues
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private <T extends Resource> Set<T> assertHasInvValues(TripleCollection graph, NonLiteral object,
UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(null, property, object);
assertTrue("missing incoming value for property "+property+ "on object "+object, it.hasNext());
Set<T> values = new HashSet<T>();
while(it.hasNext()){
Resource value = it.next().getSubject();
assertTrue(type.getSimpleName()+" expected but value "+ value +
" had the type "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
values.add(type.cast(value));
}
return values;
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:15,代码来源:Fise2FamEngineTest.java
示例14: assertSingleValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private <T extends Resource> T assertSingleValue(TripleCollection graph, NonLiteral subject, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(subject, property, null);
assertTrue("missing value for property "+property+ "on subject "+subject, it.hasNext());
Resource value = it.next().getObject();
assertFalse("multi values for property "+property+ "on subject "+subject, it.hasNext());
assertTrue(type.getSimpleName()+" expected but was "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
return type.cast(value);
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:10,代码来源:Fise2FamEngineTest.java
示例15: assertOptValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private <T extends Resource> T assertOptValue(TripleCollection graph, NonLiteral subject, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(subject, property, null);
if(!it.hasNext()){
return null;
}
Resource value = it.next().getObject();
assertFalse("multi values for property "+property+ "on subject "+subject, it.hasNext());
assertTrue(type.getSimpleName()+" expected but was "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
return type.cast(value);
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:12,代码来源:Fise2FamEngineTest.java
示例16: assertSingleInvValue
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private <T extends Resource> T assertSingleInvValue(TripleCollection graph, Resource object, UriRef property, Class<T> type) {
Iterator<Triple> it = graph.filter(null, property, object);
assertTrue("missing value for property "+property+ "on object "+object, it.hasNext());
Resource value = it.next().getSubject();
assertFalse("multi values for property "+property+ "on object "+object, it.hasNext());
assertTrue(type.getSimpleName()+" expected but was "+value.getClass().getSimpleName()+"!",
type.isAssignableFrom(value.getClass()));
return type.cast(value);
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:10,代码来源:Fise2FamEngineTest.java
示例17: logRdf
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
private static void logRdf(String title, TripleCollection graph) {
if(log.isDebugEnabled()){
ByteArrayOutputStream out = new ByteArrayOutputStream();
rdfSerializer.serialize(out, graph, SupportedFormat.TURTLE);
try {
log.debug("{} {}",title == null ? "RDF:\n" : title, out.toString("UTF8"));
} catch (UnsupportedEncodingException e) {/*ignore*/}
}
}
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:10,代码来源:Fise2FamEngineTest.java
示例18: generateRdf
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
final String text = IOUtils.toString(entity.getData(), "UTF-8");
final TripleCollection result = new SimpleMGraph();
final Resource resource = entity.getContentLocation() == null
? new BNode()
: new UriRef(entity.getContentLocation().toString());
final GraphNode node = new GraphNode(resource, result);
node.addProperty(RDF.type, TEXUAL_CONTENT);
node.addPropertyValue(SIOC.content, text);
node.addPropertyValue(new UriRef("http://example.org/ontology#textLength"), text.length());
return result;
}
开发者ID:fusepoolP3,项目名称:p3-pipeline-transformer,代码行数:14,代码来源:SimpleRdfProducingTransformer.java
示例19: generateRdf
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
/**
* Takes the RDF data sent by the client and the graph name (url) of the knowledge base to search
* for points of interest nearby the locations described in the client graph and sends it back enriched with
* information about the points of interest that have been found. It looks for the knowledge base name in the triple store
* before fetching the data from the url.
*/
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
TripleCollection resultGraph = null;
String mediaType = entity.getType().toString();
Parser parser = Parser.getInstance();
TripleCollection requestGraph = parser.parse( entity.getData(), mediaType);
resultGraph = spatialDataEnhancer.enhance(kbDataUrl, requestGraph);
return resultGraph;
}
开发者ID:fusepoolP3,项目名称:p3-geo-enriching-transformer,代码行数:18,代码来源:GeoEnrichingTransformer.java
示例20: getCircle
import org.apache.clerezza.rdf.core.TripleCollection; //导入依赖的package包/类
/**
* Returns a circle object with the geo coordinate and radius of the circle centered around a position.
* @param positionRef
* @param graph
* @return
*/
public Circle getCircle(TripleCollection graph) {
Circle circle = new Circle();
if (graph.filter(null, schema_circle, null).hasNext()) {
String circleTxt = ((PlainLiteralImpl) graph.filter(null, schema_circle, null).next().getObject()).getLexicalForm();
String [] circleData = circleTxt.split(" ");
circle.centerLat = Double.parseDouble(circleData[0]);
circle.centerLong = Double.parseDouble(circleData[1]);
if (circleData[2] != null && ! "".equals(circleData[2]) ) {
circle.radius = Double.parseDouble(circleData[2]);
}
}
return circle;
}
开发者ID:fusepoolP3,项目名称:p3-geo-enriching-transformer,代码行数:20,代码来源:SpatialDataEnhancer.java
注:本文中的org.apache.clerezza.rdf.core.TripleCollection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论