• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java NonLiteral类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.clerezza.rdf.core.NonLiteral的典型用法代码示例。如果您正苦于以下问题:Java NonLiteral类的具体用法?Java NonLiteral怎么用?Java NonLiteral使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NonLiteral类属于org.apache.clerezza.rdf.core包,在下文中一共展示了NonLiteral类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getResourceValue

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
private String getResourceValue(NonLiteral nl, Map<BNode, String> bNodeMap) {
    if (nl == null) {
        return null;
    } else if (nl instanceof UriRef) {
        return ((UriRef) nl).getUnicodeString();
    } else if (nl instanceof BNode) {
        String bNodeId = bNodeMap.get(nl);
        if (bNodeId == null) {
            bNodeId = Integer.toString(bNodeMap.size());
            bNodeMap.put((BNode) nl, bNodeId);
        }
        return new StringBuilder("_:b").append(bNodeId).toString();
    } else {
        throw new IllegalStateException("Unknwon NonLiteral type " + nl.getClass().getName()
                + "!");
    }
}
 
开发者ID:jsonld-java,项目名称:jsonld-java-clerezza,代码行数:18,代码来源:ClerezzaRDFParser.java


示例2: cleanFiseEnhancement

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
/**
    * Cleans triples in the metadata of the {@link ContentItem} of 
    * the transformed <code>fise:Enhancement</code>
    * @param anno the annotation to clean.
    */
private void cleanFiseEnhancement(Annotation anno) {
	MGraph metadata = anno.ctx.ci.getMetadata();
   	//delete outgoing (incl. bNodes)
	List<NonLiteral> nodes = new ArrayList<NonLiteral>();
	nodes.add(anno.enh);
	while(!nodes.isEmpty()){
    	Iterator<Triple> outgoing = metadata.filter(
    			nodes.remove(nodes.size()-1), null, null);
		while(outgoing.hasNext()){
			Triple t = outgoing.next();
			if(t.getObject() instanceof BNode){
				nodes.add((BNode)t.getObject());
			}
			outgoing.remove();
		}
	}
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:23,代码来源:Fise2FamEngine.java


示例3: transformTextAnnotation

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
private void transformTextAnnotation(Annotation anno) {
    //we need to distinquish different types of fise:TextAnnotations
    //(1) Language Annotations
    Set<UriRef> dcTypes = asSet(getReferences(anno.ctx.src, anno.enh, DC_TYPE));
    if (dcTypes.contains(DC_LINGUISTIC_SYSTEM)) { // this is a language annotation
        transformLanguageAnnotation(anno);
        return;
    }
    //(2) Sentiment Annotation
    //Sentiment Annotations do use ?enh dct:type fise:Sentiment
    if(dcTypes.contains(FISE_SENTIMENT_TYPE)){
        transformSentimentAnnotation(anno);
        return;
    }
    //(3) Topic Annotations
    Iterator<Triple> relation = anno.ctx.src.filter(null, DC_RELATION, anno.enh);
    while (relation.hasNext()) {
        NonLiteral related = relation.next().getSubject();
        if(hasValue(anno.ctx.src, related, RDF_TYPE, null, ENHANCER_TOPICANNOTATION)){
            transformTopicClassification(anno);
            return;
        }
    }
    //(4) Entity Mention Annotations (all remaining)
    transformEntityMentionAnnotation(anno);
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:27,代码来源:Fise2FamEngine.java


示例4: transformTopicAnnotation

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
private void transformTopicAnnotation(Annotation anno) {
	Iterator<Triple> relation = anno.ctx.src.filter(anno.enh, DC_RELATION, null);
	while(relation.hasNext()){
		Resource o = relation.next().getObject();
		if(o instanceof NonLiteral){
			NonLiteral related = (NonLiteral)o;
			if(hasValue(anno.ctx.src, related, RDF_TYPE, null, ENHANCER_TEXTANNOTATION)){
				anno.addReated(related); //add this as a related annotation
				anno.ctx.tar.add(new TripleImpl(related, OA_ITEM, anno.getBody()));
			} //else dc:relation to an none fise:TextAnnotation
		} //else dc:relation to an Literal ... ignore
	}
	if(!anno.getRelated().isEmpty()){
		anno.ctx.tar.add(new TripleImpl(anno.getBody(), RDF_TYPE, FAM.TopicAnnotation));
		copyValue(anno.ctx, anno.enh, ENHANCER_ENTITY_REFERENCE, anno.getBody(), FAM.topic_reference);
		copyValue(anno.ctx, anno.enh, ENHANCER_ENTITY_LABEL, anno.getBody(), FAM.topic_label);
		copyValue(anno.ctx, anno.enh, ENTITYHUB_SITE, anno.getBody(), ENTITYHUB_SITE);
		
	}//else ignore Topic Annotations without a Topic Classification
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:21,代码来源:Fise2FamEngine.java


示例5: hasValue

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的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


示例6: assertOptValues

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的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


示例7: getPoint

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的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: triple

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
private void triple(String s, String p, String o, String graph) {
    if (s == null || p == null || o == null) {
        // TODO: i don't know what to do here!!!!
        return;
    }

    final NonLiteral subject = getNonLiteral(s);
    final UriRef predicate = new UriRef(p);
    final NonLiteral object = getNonLiteral(o);
    mGraph.add(new TripleImpl(subject, predicate, object));
}
 
开发者ID:jsonld-java,项目名称:jsonld-java-clerezza,代码行数:12,代码来源:ClerezzaTripleCallback.java


示例9: getNonLiteral

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
private NonLiteral getNonLiteral(String s) {
    if (s.startsWith("_:")) {
        return getBNode(s);
    } else {
        return new UriRef(s);
    }
}
 
开发者ID:jsonld-java,项目名称:jsonld-java-clerezza,代码行数:8,代码来源:ClerezzaTripleCallback.java


示例10: handleStatement

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
private void handleStatement(RDFDataset result, Triple t, Map<BNode, String> bNodeMap) {
    final String subject = getResourceValue(t.getSubject(), bNodeMap);
    final String predicate = getResourceValue(t.getPredicate(), bNodeMap);
    final Resource object = t.getObject();

    if (object instanceof Literal) {

        final String value = ((Literal) object).getLexicalForm();
        final String language;
        final String datatype;
        if (object instanceof TypedLiteral) {
            language = null;
            datatype = getResourceValue(((TypedLiteral) object).getDataType(), bNodeMap);
        } else if (object instanceof PlainLiteral) {
            // we use RDF 1.1 literals so we do set the RDF_LANG_STRING
            // datatype
            datatype = RDF_LANG_STRING;
            final Language l = ((PlainLiteral) object).getLanguage();
            if (l == null) {
                language = null;
            } else {
                language = l.toString();
            }
        } else {
            throw new IllegalStateException("Unknown Literal class "
                    + object.getClass().getName());
        }
        result.addTriple(subject, predicate, value, datatype, language);
        count++;
    } else {
        result.addTriple(subject, predicate, getResourceValue((NonLiteral) object, bNodeMap));
        count++;
    }

}
 
开发者ID:jsonld-java,项目名称:jsonld-java-clerezza,代码行数:36,代码来源:ClerezzaRDFParser.java


示例11: addReated

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
protected void addReated(NonLiteral enh){
	if(enh == null){
		return;
	}
	if(related == null){
		related = new HashSet<NonLiteral>(4);
	}
	related.add(enh);
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:10,代码来源:Annotation.java


示例12: transformEntityAnnotation

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
/**
    * Implements the transformation rules as specified by 
    * <a href="https://github.com/fusepoolP3/overall-architecture/blob/master/wp3/fp-anno-model/fp-anno-model.md#fiseentityannotation-transformation">
    * <code>fise:EntityAnnotation</code> transformation</a>
    * @param source
    * @param target
    * @param enh
    * @return
    */
   private void transformEntityAnnotation(Annotation anno) {
   	//TODO: This does currently not support creating fise:LinkedEntity
   	//      annotations in cases where only a single Entity is suggested
   	//      for a fise:TextAnnotation (fam:EntityMention)
   	//      supporting this would need an additional pass through already
   	//      transformed fise:Enthancements, as one needs to ensure that
   	//      all fise:TextAnnotation are already transformed
   	
	Iterator<Triple> mentions = anno.ctx.src.filter(anno.enh, DC_RELATION, null);
	while(mentions.hasNext()){
		Resource o = mentions.next().getObject();
		if(o instanceof NonLiteral){
			NonLiteral mention = (NonLiteral)o;
			if(hasValue(anno.ctx.src, mention, RDF_TYPE, null, ENHANCER_TEXTANNOTATION)){
				anno.addReated(mention); //add this as a related annotation
				//adapt EntityMention
				anno.ctx.tar.add(new TripleImpl(mention, RDF_TYPE, OA_CHOICE));
				anno.ctx.tar.add(new TripleImpl(mention, RDF_TYPE, FAM.EntityLinkingChoice));
				anno.ctx.tar.add(new TripleImpl(mention,OA_ITEM, anno.getBody()));
			}
		} //dc:relation to an Literal ... ignore
	}
	//add the RDF types to the entity annotation
   	anno.ctx.tar.add(new TripleImpl(anno.getBody(), RDF_TYPE, FAM.EntityAnnotation));
	if(!anno.getRelated().isEmpty()){ //if there is a fam:EntityMention linked
		//this is also a fam:EntitySuggestion
		anno.ctx.tar.add(new TripleImpl(anno.getBody(), RDF_TYPE, FAM.EntitySuggestion));
	}
	//direct mappings for fise:EntityAnnotation
	copyValue(anno.ctx, anno.enh, ENHANCER_ENTITY_REFERENCE, anno.getBody(), FAM.entity_reference);
	copyValue(anno.ctx, anno.enh, ENHANCER_ENTITY_LABEL, anno.getBody(), FAM.entity_label);
	copyValue(anno.ctx, anno.enh, ENHANCER_ENTITY_TYPE, anno.getBody(), FAM.entity_type);
	copyValue(anno.ctx, anno.enh, ENTITYHUB_SITE, anno.getBody(), ENTITYHUB_SITE);
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:44,代码来源:Fise2FamEngine.java


示例13: createSelectorRessource

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
/**
    * Creates a <a href="http://tools.ietf.org/html/rfc5147">RFC 5147</a> encoded
    * Selector URI if the parsed annotation defines a selection. If not this
    * method returns <code>null</code>
    * @param anno the transformed annotation
    * @return the URI or <code>null</code> if no selection is present for the
    * parsed annotation
    */
private UriRef createSelectorRessource(Annotation anno) {
	NonLiteral enh = anno.getEnhancement();
	Integer start = get(anno.ctx.src, enh, ENHANCER_START,Integer.class, lf);
	Integer end = get(anno.ctx.src, enh, ENHANCER_END,Integer.class, lf);
	if(start != null && end != null){
	    return createRFC5147URI(anno.getExtractedFrom(), start, end);
	} else {//no selection present
		return null;
	}
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:19,代码来源:Fise2FamEngine.java


示例14: copyValue

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
/**
 * Copies values from the source (graph, node, property) to the target (graph,
 * node, property).
 * @param ctx the {@link TransformationContext}
 * @param sourceNode the source node
 * @param sourceProp the source property
 * @param targetNode the target node
 * @param targetProp the target property
 * @return the number of values copied
 */
private int copyValue(TransformationContext ctx, NonLiteral sourceNode,
        UriRef sourceProp, NonLiteral targetNode,
        UriRef targetProp) {
    Iterator<Triple> it = ctx.src.filter(sourceNode, sourceProp, null);
    int i = 0;
    while(it.hasNext()){
        Resource val = it.next().getObject();
        ctx.tar.add(new TripleImpl(targetNode,targetProp,val));
        i++;
    }
    return i;
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:23,代码来源:Fise2FamEngine.java


示例15: assertHasValues

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的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


示例16: assertHasInvValues

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的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


示例17: assertSingleValue

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的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


示例18: assertOptValue

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的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


示例19: Annotation

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
public Annotation(TransformationContext ctx, NonLiteral enh) {
    this.ctx = ctx;
    this.enh = enh;
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:5,代码来源:Annotation.java


示例20: getEnhancement

import org.apache.clerezza.rdf.core.NonLiteral; //导入依赖的package包/类
public NonLiteral getEnhancement() {
    return enh;
}
 
开发者ID:fusepoolP3,项目名称:p3-stanbol-engine-fam,代码行数:4,代码来源:Annotation.java



注:本文中的org.apache.clerezza.rdf.core.NonLiteral类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TieHandler类代码示例发布时间:2022-05-23
下一篇:
Java PerturbFilter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap