本文整理汇总了Java中org.apache.clerezza.rdf.core.LiteralFactory类的典型用法代码示例。如果您正苦于以下问题:Java LiteralFactory类的具体用法?Java LiteralFactory怎么用?Java LiteralFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LiteralFactory类属于org.apache.clerezza.rdf.core包,在下文中一共展示了LiteralFactory类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import org.apache.clerezza.rdf.core.LiteralFactory; //导入依赖的package包/类
@BeforeClass
public static void init(){
LiteralFactory lf = LiteralFactory.getInstance();
UriRef pers1 = new UriRef("http://www.example.org/test#pers1");
UriRef pers2 = new UriRef("http://www.example.org/test#pers2");
MGraph data = new SimpleMGraph();
//NOTE: This test a language literal with and without language as
// well as a xsd:string typed literal. To test correct handling of
// RDF1.1
data.add(new TripleImpl(pers1, RDF.type, FOAF.Person));
data.add(new TripleImpl(pers1, FOAF.name, new PlainLiteralImpl("Rupert Westenthaler",
new Language("de"))));
data.add(new TripleImpl(pers1, FOAF.nick, new PlainLiteralImpl("westei")));
data.add(new TripleImpl(pers1, FOAF.mbox, lf.createTypedLiteral("[email protected]")));
data.add(new TripleImpl(pers1, FOAF.age, lf.createTypedLiteral(38)));
data.add(new TripleImpl(pers1, FOAF.knows, pers2));
data.add(new TripleImpl(pers2, FOAF.name, new PlainLiteralImpl("Reto Bachmann-Gmür")));
rdfData = data.getGraph();
}
开发者ID:jsonld-java,项目名称:jsonld-java-clerezza,代码行数:20,代码来源:ClerezzaJsonLdParserSerializerTest.java
示例2: verifyEnhancement
import org.apache.clerezza.rdf.core.LiteralFactory; //导入依赖的package包/类
private void verifyEnhancement(String text) throws IOException, EngineException {
final ContentItem ci = prepareContentItem(text);
try {
annotateEngine.computeEnhancements(ci);
} catch (EngineException e) {
RemoteServiceHelper.checkServiceUnavailable(e);
}
logEnhancements(ci);
HashMap<UriRef,Resource> expectedValues = new HashMap<UriRef,Resource>();
expectedValues.put(
Properties.ENHANCER_EXTRACTED_FROM,
ci.getUri()
);
expectedValues.put(
Properties.DC_CREATOR,
LiteralFactory.getInstance().createTypedLiteral(annotateEngine.getClass().getName())
);
EnhancementStructureHelper.validateAllTextAnnotations(ci.getMetadata(), text, expectedValues);
EnhancementStructureHelper.validateAllEntityAnnotations(ci.getMetadata(), expectedValues);
//we do expect three topics
Assert.assertEquals(3, EnhancementStructureHelper.validateAllTopicAnnotations(ci.getMetadata(), expectedValues));
}
开发者ID:michelemostarda,项目名称:machinelinking-stanbol-enhancement-engine,代码行数:25,代码来源:MLAnnotateEnhancementEngineTest.java
示例3: testEngine
import org.apache.clerezza.rdf.core.LiteralFactory; //导入依赖的package包/类
@Test
public void testEngine() throws EngineException, IOException {
final String text = "President Barack Obama pushes Senate for military action in Syria.";
ContentItem ci = ciFactory.createContentItem(new StringSource(text));
Assert.assertNotNull(ci);
AnalysedText at = atFactory.createAnalysedText(ci, ci.getBlob());
Assert.assertNotNull(at);
Assert.assertEquals(
"Cannot enhance Test ContentItem", EnhancementEngine.ENHANCE_ASYNC, engine.canEnhance(ci)
);
try {
engine.computeEnhancements(ci);
} catch (EngineException e) {
RemoteServiceHelper.checkServiceUnavailable(e);
}
logEnhancements(ci);
HashMap<UriRef,Resource> expectedValues = new HashMap<UriRef,Resource>();
expectedValues.put(Properties.ENHANCER_EXTRACTED_FROM, ci.getUri());
expectedValues.put(
Properties.DC_CREATOR,
LiteralFactory.getInstance().createTypedLiteral(engine.getClass().getName())
);
expectedValues.put(Properties.DC_LANGUAGE, LiteralFactory.getInstance().createTypedLiteral("en"));
EnhancementStructureHelper.validateAllTextAnnotations(
ci.getMetadata(), text, expectedValues
);
EnhancementStructureHelper.validateAllEntityAnnotations(
ci.getMetadata(), expectedValues
);
}
开发者ID:michelemostarda,项目名称:machinelinking-stanbol-enhancement-engine,代码行数:35,代码来源:MLLanguageIdentifierEnhancementEngineTest.java
示例4: addSubjects
import org.apache.clerezza.rdf.core.LiteralFactory; //导入依赖的package包/类
/**
* Add dc:subject property to items pointing to entities extracted by NLP
* engines in the default chain. Given a node and a TripleCollection
* containing fise:Enhancements about that node dc:subject properties are
* added to an item pointing to entities referenced by those enhancements if
* the enhancement confidence value is above a threshold.
*
* @param node
* @param metadata
*/
private void addSubjects(MGraph targetGraph, UriRef itemRef, TripleCollection metadata) {
final GraphNode enhancementType = new GraphNode(TechnicalClasses.ENHANCER_ENHANCEMENT, metadata);
final Set<UriRef> entities = new HashSet<UriRef>();
// get all the enhancements
final Iterator<GraphNode> enhancements = enhancementType.getSubjectNodes(RDF.type);
while (enhancements.hasNext()) {
final GraphNode enhhancement = enhancements.next();
final Iterator<Literal> confidenceLiterals = enhhancement.getLiterals(org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_CONFIDENCE);
//look the confidence value for each enhancement
double enhancementConfidence = confidenceLiterals.hasNext() ?
LiteralFactory.getInstance().createObject(Double.class,
(TypedLiteral) confidenceLiterals.next()) : 1;
if (enhancementConfidence >= confidenceThreshold) {
// get entities referenced in the enhancement
final Iterator<Resource> referencedEntities = enhhancement.getObjects(org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_ENTITY_REFERENCE);
while (referencedEntities.hasNext()) {
final UriRef entity = (UriRef) referencedEntities.next();
// Add dc:subject to the patent for each referenced entity
targetGraph.add(new TripleImpl(itemRef, DC.subject, entity));
entities.add(entity);
}
}
}
for (UriRef uriRef : entities) {
// We don't get the entity description directly from metadata
// as the context there would include
addResourceDescription(uriRef, targetGraph);
}
}
开发者ID:fusepool,项目名称:datalifecycle,代码行数:41,代码来源:SourcingAdmin.java
注:本文中的org.apache.clerezza.rdf.core.LiteralFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论