当前位置: 首页>>代码示例>>Java>>正文


Java MGraph.filter方法代码示例

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


在下文中一共展示了MGraph.filter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: cleanFiseEnhancement

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

示例2: graphToJson

import org.apache.clerezza.rdf.core.MGraph; //导入方法依赖的package包/类
private JSONArray graphToJson(MGraph graph) throws JSONException{
	//JSONObject json = new JSONObject();
	JSONArray json = new JSONArray();
	
	//create the first 0 element "non assigné"
	json.put(getBudgetLineObject("0", "Non assigné", 0));
	
	//TODO : use ldpath for building this ones
	
	//1) get all budget lines
	Iterator<Triple> budgetLinesId = graph.filter(null, RDF.type,Onthology.budgetLineType.getUri());
	while(budgetLinesId.hasNext()){
		Triple budgetId = budgetLinesId.next();
		
		//getthe label
		Resource label = graph.filter(budgetId.getSubject(), SKOS.prefLabel, null).next().getObject();
		
		//get the value
		Triple valueId = graph.filter(null, Onthology.forBudgetLine.getUri(), budgetId.getSubject()).next();
		Resource percentage = graph.filter(valueId.getSubject(), Onthology.percentage.getUri(), null).next().getObject();
		
		json.put(getBudgetLineObject(budgetId.getSubject().toString(), ((Literal)label).getLexicalForm(), Double.parseDouble(((Literal)percentage).getLexicalForm())));
		
	}
	return json;
}
 
开发者ID:florent-andre,项目名称:CleverTaxes,代码行数:27,代码来源:SkosifierRootResource.java

示例3: generateDemoData

import org.apache.clerezza.rdf.core.MGraph; //导入方法依赖的package包/类
private void generateDemoData(MGraph graph, UriRef rootUri) {
   	
	generateTemplate(graph,rootUri);
	
   	String cityName = "demoCity";
   	
   	//TODO : create a real literal with a lang (cf importer in xplor)
   	graph.add(new TripleImpl(rootUri, SKOS.prefLabel, lf.createTypedLiteral(cityName) ));
   	
   	//create a fake budget plan
   	String userName = "fakeUser";
   	
   	UriRef rootFakeBudget = Entities.generateNewEntity();
   	graph.add(new TripleImpl(rootFakeBudget, RDF.type, Onthology.budgetPlanType.getUri()));
   	//TODO : create a real language object
   	graph.add(new TripleImpl(rootFakeBudget, Onthology.fromUser.getUri(), lf.createTypedLiteral(userName)));
   	
   	Random r = new Random();
   	
   	//get all "lines" of the budget
   	// TODO : get to 100% with random generation int maxPercentage = 100;
   	Iterator<Triple> lines = graph.filter(null, RDF.type, Onthology.budgetLineType.getUri());
   	List<Triple> trps = new ArrayList<Triple>();
   	while(lines.hasNext()){
   		Triple line = lines.next();
   		UriRef valueId = Entities.generateNewEntity();
   		
   		trps.add(new TripleImpl(valueId, RDF.type, Onthology.budgetPlanValueType.getUri()));
   		trps.add(new TripleImpl(valueId, Onthology.forBudgetLine.getUri(), line.getSubject()));
   		double amount = r.nextDouble() * (10 + r.nextDouble());
   		trps.add(new TripleImpl(valueId, Onthology.percentage.getUri(), lf.createTypedLiteral(r.nextDouble())));
   		
   		trps.add(new TripleImpl(rootFakeBudget, Onthology.hasBudgetPlanValue.getUri(), valueId));
   	}
   	
   	graph.addAll(trps);
}
 
开发者ID:florent-andre,项目名称:CleverTaxes,代码行数:38,代码来源:SkosifierRootResource.java

示例4: readDictionary

import org.apache.clerezza.rdf.core.MGraph; //导入方法依赖的package包/类
public static DictionaryStore readDictionary(InputStream inputStream) {
    Triple triple;
    Resource resource;
    String label, lang;

    DictionaryStore dictionary = new DictionaryStore();
    MGraph graph = new IndexedMGraph();
    Parser.getInstance().parse(graph, inputStream, "application/rdf+xml");
    Iterator<Triple> typeTriples = graph.filter(null, RDF.type, SKOS04.Concept);
    while (typeTriples.hasNext()) {
        NonLiteral s = typeTriples.next().getSubject();
        if (s instanceof UriRef) {
            UriRef concept = (UriRef) s;

            // getting prefLabels
            Iterator<Triple> prefTriples = graph.filter(concept, SKOS04.prefLabel, null);
            while (prefTriples.hasNext()) {
                triple = prefTriples.next();
                resource = triple.getObject();
                if (resource instanceof PlainLiteral) {
                    label = ((PlainLiteral) resource).getLexicalForm();
                    lang = ((PlainLiteral) resource).getLanguage() == null ? null : ((PlainLiteral) resource).getLanguage().toString();
                } else if (resource instanceof TypedLiteral && ((TypedLiteral) resource).getDataType().equals(XSD.string)) {
                    label = ((Literal) resource).getLexicalForm();
                    lang = null;
                } else {
                    label = null;
                    lang = null;
                }

                if (StringUtils.isNotBlank(label) && StringUtils.isNotBlank(concept.getUnicodeString())) {
                    dictionary.addOriginalElement(label, SKOS04.prefLabel, concept.getUnicodeString());
                }
            }

            // getting altLabels
            Iterator<Triple> altTriples = graph.filter(concept, SKOS04.altLabel, null);
            while (altTriples.hasNext()) {
                triple = altTriples.next();
                resource = triple.getObject();
                if (resource instanceof PlainLiteral) {
                    label = ((PlainLiteral) resource).getLexicalForm();
                    lang = ((PlainLiteral) resource).getLanguage() == null ? null : ((PlainLiteral) resource).getLanguage().toString();
                } else if (resource instanceof TypedLiteral && ((TypedLiteral) resource).getDataType().equals(XSD.string)) {
                    label = ((Literal) resource).getLexicalForm();
                    lang = null;
                } else {
                    label = null;
                    lang = null;
                }

                if (StringUtils.isNotBlank(label) && StringUtils.isNotBlank(concept.getUnicodeString())) {
                    dictionary.addOriginalElement(label, SKOS04.altLabel, concept.getUnicodeString());
                }
            }

        }
    }
    return dictionary;
}
 
开发者ID:fusepoolP3,项目名称:p3-dictionary-matcher-transformer,代码行数:61,代码来源:Reader.java


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