Search in sources :

Example 91 with TripleImpl

use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.

the class EnhancementEngineHelper method createTopicEnhancement.

/**
     * Create a new instance with the types enhancer:Enhancement and
     * enhancer:TopicAnnotation in the parsed graph along with default properties
     * (dc:creator, dc:created and enhancer:extracted-form) and return
     * the IRI of the extraction so that engines can further add.
     *
     * @param metadata the graph
     * @param engine the engine
     * @param contentItemId the id
     *
     * @return the URI of the new enhancement instance
     */
public static IRI createTopicEnhancement(Graph metadata, EnhancementEngine engine, IRI contentItemId) {
    IRI enhancement = createEnhancement(metadata, engine, contentItemId);
    metadata.add(new TripleImpl(enhancement, RDF_TYPE, ENHANCER_TOPICANNOTATION));
    return enhancement;
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)

Example 92 with TripleImpl

use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.

the class EnhancementEngineHelper method createEntityEnhancement.

/**
     * Create a new instance with the types enhancer:Enhancement and
     * enhancer:EntityAnnotation in the parsed graph along with default properties
     * (dc:creator, dc:created and enhancer:extracted-form) and return
     * the IRI of the extraction so that engines can further add.
     *
     * @param metadata the graph
     * @param engine the engine
     * @param contentItemId the id
     *
     * @return the URI of the new enhancement instance
     */
public static IRI createEntityEnhancement(Graph metadata, EnhancementEngine engine, IRI contentItemId) {
    IRI enhancement = createEnhancement(metadata, engine, contentItemId);
    metadata.add(new TripleImpl(enhancement, RDF_TYPE, ENHANCER_ENTITYANNOTATION));
    return enhancement;
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)

Example 93 with TripleImpl

use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.

the class EnhancementEngineHelper method createEnhancement.

/**
     * Create a new enhancement instance in the metadata-graph of the content
     * item along with default properties (dc:creator and dc:created) and return
     * the IRI of the extraction so that engines can further add. <p>
     * <i>NOTE:</i> This method was protected prior to <code>0.12.1</code> (see
     * <a href="https://issues.apache.org/jira/browse/STANBOL-1321">STANBOL-1321</a>)
     *
     * @param ci the ContentItem being under analysis
     * @param engine the Engine performing the analysis
     *
     * @return the URI of the new enhancement instance
     * @since 0.12.1
     */
public static IRI createEnhancement(Graph metadata, EnhancementEngine engine, IRI contentItemId) {
    LiteralFactory literalFactory = LiteralFactory.getInstance();
    IRI enhancement = new IRI("urn:enhancement-" + EnhancementEngineHelper.randomUUID());
    //add the Enhancement Type
    metadata.add(new TripleImpl(enhancement, RDF_TYPE, ENHANCER_ENHANCEMENT));
    //add the extracted from content item
    metadata.add(new TripleImpl(enhancement, ENHANCER_EXTRACTED_FROM, contentItemId));
    // creation date
    metadata.add(new TripleImpl(enhancement, DC_CREATED, literalFactory.createTypedLiteral(new Date())));
    // the engines that extracted the data
    // TODO: add some kind of versioning info for the extractor?
    // TODO: use a public dereferencing URI instead? that would allow for
    // explicit versioning too
    /* NOTE (Rupert Westenthaler 2010-05-26):
         * The Idea is to use the  ComponentContext in the activate() method of
         * an Enhancer to get the bundle name/version and use that as an
         * URI for the creator.
         * We would need to add getEnhancerID() method to the enhancer interface
         * to access this information
          */
    metadata.add(new TripleImpl(enhancement, DC_CREATOR, literalFactory.createTypedLiteral(engine.getClass().getName())));
    return enhancement;
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl) Date(java.util.Date) LiteralFactory(org.apache.clerezza.rdf.core.LiteralFactory)

Example 94 with TripleImpl

use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.

the class EnhancementEngineHelper method createNewExtraction.

/**
     * Create a new extraction instance in the metadata-graph of the content
     * item along with default properties (dc:creator and dc:created) and return
     * the IRI of the extraction so that engines can further add
     *
     * @param ci the ContentItem being under analysis
     * @param engine the Engine performing the analysis
     * @return the URI of the new extraction instance
     * @deprecated will be remove with 1.0
     * @see EnhancementEngineHelper#createEntityEnhancement(ContentItem, EnhancementEngine)
     * @see EnhancementEngineHelper#createTextEnhancement(ContentItem, EnhancementEngine)
     */
@Deprecated
public static IRI createNewExtraction(ContentItem ci, EnhancementEngine engine) {
    LiteralFactory literalFactory = LiteralFactory.getInstance();
    Graph metadata = ci.getMetadata();
    IRI extraction = new IRI("urn:extraction-" + EnhancementEngineHelper.randomUUID());
    metadata.add(new TripleImpl(extraction, RDF_TYPE, ENHANCER_EXTRACTION));
    // relate the extraction to the content item
    metadata.add(new TripleImpl(extraction, ENHANCER_RELATED_CONTENT_ITEM, new IRI(ci.getUri().getUnicodeString())));
    // creation date
    metadata.add(new TripleImpl(extraction, DC_CREATED, literalFactory.createTypedLiteral(new Date())));
    // the engines that extracted the data
    // TODO: add some kind of versioning info for the extractor?
    // TODO: use a public dereferencing URI instead? that would allow for
    // explicit versioning too
    metadata.add(new TripleImpl(extraction, DC_CREATOR, literalFactory.createTypedLiteral(engine.getClass().getName())));
    return extraction;
}
Also used : IRI(org.apache.clerezza.commons.rdf.IRI) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) Graph(org.apache.clerezza.commons.rdf.Graph) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl) Date(java.util.Date) LiteralFactory(org.apache.clerezza.rdf.core.LiteralFactory)

Example 95 with TripleImpl

use of org.apache.clerezza.commons.rdf.impl.utils.TripleImpl in project stanbol by apache.

the class ExecutionMetadataHelper method createChainExecutionNode.

public static BlankNodeOrIRI createChainExecutionNode(Graph graph, BlankNodeOrIRI executionPlan, IRI ciUri, boolean defaultChain) {
    BlankNodeOrIRI node = new BlankNode();
    graph.add(new TripleImpl(node, RDF_TYPE, EXECUTION));
    graph.add(new TripleImpl(node, RDF_TYPE, CHAIN_EXECUTION));
    graph.add(new TripleImpl(node, ENHANCES, ciUri));
    graph.add(new TripleImpl(ciUri, ENHANCED_BY, node));
    graph.add(new TripleImpl(node, STATUS, STATUS_SCHEDULED));
    graph.add(new TripleImpl(node, EXECUTION_PLAN, executionPlan));
    graph.add(new TripleImpl(node, IS_DEFAULT_CHAIN, lf.createTypedLiteral(defaultChain)));
    return node;
}
Also used : BlankNode(org.apache.clerezza.commons.rdf.BlankNode) BlankNodeOrIRI(org.apache.clerezza.commons.rdf.BlankNodeOrIRI) TripleImpl(org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)

Aggregations

TripleImpl (org.apache.clerezza.commons.rdf.impl.utils.TripleImpl)143 IRI (org.apache.clerezza.commons.rdf.IRI)104 PlainLiteralImpl (org.apache.clerezza.commons.rdf.impl.utils.PlainLiteralImpl)69 Graph (org.apache.clerezza.commons.rdf.Graph)66 BlankNodeOrIRI (org.apache.clerezza.commons.rdf.BlankNodeOrIRI)49 Triple (org.apache.clerezza.commons.rdf.Triple)41 RDFTerm (org.apache.clerezza.commons.rdf.RDFTerm)26 EngineException (org.apache.stanbol.enhancer.servicesapi.EngineException)23 HashMap (java.util.HashMap)20 Language (org.apache.clerezza.commons.rdf.Language)20 Literal (org.apache.clerezza.commons.rdf.Literal)20 LiteralFactory (org.apache.clerezza.rdf.core.LiteralFactory)20 IOException (java.io.IOException)18 SimpleGraph (org.apache.clerezza.commons.rdf.impl.utils.simple.SimpleGraph)17 Test (org.junit.Test)16 ContentItem (org.apache.stanbol.enhancer.servicesapi.ContentItem)15 IndexedGraph (org.apache.stanbol.commons.indexedgraph.IndexedGraph)14 HashSet (java.util.HashSet)13 StringSource (org.apache.stanbol.enhancer.servicesapi.impl.StringSource)13 BlankNode (org.apache.clerezza.commons.rdf.BlankNode)11