org.apache.stanbol.enhancer.servicesapi.helper
Class EnhancementEngineHelper

java.lang.Object
  extended by org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper

public class EnhancementEngineHelper
extends java.lang.Object


Field Summary
static java.util.Comparator<EnhancementEngine> EXECUTION_ORDER_COMPARATOR
          Comparator that allows to sort a list/array of EnhancementEngines based on there ServiceProperties.ENHANCEMENT_ENGINE_ORDERING.
protected static java.util.Random rng
           
 
Constructor Summary
EnhancementEngineHelper()
           
 
Method Summary
protected static org.apache.clerezza.rdf.core.UriRef createEnhancement(org.apache.clerezza.rdf.core.MGraph metadata, EnhancementEngine engine, org.apache.clerezza.rdf.core.UriRef contentItemId)
          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 UriRef of the extraction so that engines can further add.
static org.apache.clerezza.rdf.core.UriRef createEntityEnhancement(ContentItem ci, EnhancementEngine engine)
          Create a new instance with the types enhancer:Enhancement and enhancer:EntityAnnotation in the metadata-graph of the content item along with default properties (dc:creator and dc:created) and return the UriRef of the extraction so that engines can further add
static org.apache.clerezza.rdf.core.UriRef createEntityEnhancement(org.apache.clerezza.rdf.core.MGraph metadata, EnhancementEngine engine, org.apache.clerezza.rdf.core.UriRef contentItemId)
          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 UriRef of the extraction so that engines can further add.
static org.apache.clerezza.rdf.core.UriRef createNewExtraction(ContentItem ci, EnhancementEngine engine)
          Deprecated.  
static org.apache.clerezza.rdf.core.UriRef createTextEnhancement(ContentItem ci, EnhancementEngine engine)
          Create a new instance with the types enhancer:Enhancement and enhancer:TextAnnotation in the metadata-graph of the content item along with default properties (dc:creator and dc:created) and return the UriRef of the extraction so that engines can further add.
static org.apache.clerezza.rdf.core.UriRef createTextEnhancement(org.apache.clerezza.rdf.core.MGraph metadata, EnhancementEngine engine, org.apache.clerezza.rdf.core.UriRef contentItemId)
          Create a new instance with the types enhancer:Enhancement and enhancer:TextAnnotation in the parsed graph along with default properties (dc:creator, dc:created and enhancer:extracted-form) and return the UriRef of the extraction so that engines can further add.
static
<T> T
get(org.apache.clerezza.rdf.core.TripleCollection graph, org.apache.clerezza.rdf.core.NonLiteral resource, org.apache.clerezza.rdf.core.UriRef property, java.lang.Class<T> type, org.apache.clerezza.rdf.core.LiteralFactory literalFactory)
          Getter for the first typed literal value of the property for a resource.
static java.lang.Integer getEngineOrder(EnhancementEngine engine)
          Gets the ServiceProperties.ENHANCEMENT_ENGINE_ORDERING value for the parsed EnhancementEngine.
static org.apache.clerezza.rdf.core.UriRef getReference(org.apache.clerezza.rdf.core.TripleCollection graph, org.apache.clerezza.rdf.core.NonLiteral resource, org.apache.clerezza.rdf.core.UriRef property)
          Getter for the first value of the data type property for a resource
static java.util.Iterator<org.apache.clerezza.rdf.core.UriRef> getReferences(org.apache.clerezza.rdf.core.TripleCollection graph, org.apache.clerezza.rdf.core.NonLiteral resource, org.apache.clerezza.rdf.core.UriRef property)
          Getter for the values of the data type property for a resource.
static java.lang.String getString(org.apache.clerezza.rdf.core.TripleCollection graph, org.apache.clerezza.rdf.core.NonLiteral resource, org.apache.clerezza.rdf.core.UriRef property)
          Getter for the first String literal value the property for a resource
static java.util.Iterator<java.lang.String> getStrings(org.apache.clerezza.rdf.core.TripleCollection graph, org.apache.clerezza.rdf.core.NonLiteral resource, org.apache.clerezza.rdf.core.UriRef property)
          Getter for the string literal values the property for a resource
static
<T> java.util.Iterator<T>
getValues(org.apache.clerezza.rdf.core.TripleCollection graph, org.apache.clerezza.rdf.core.NonLiteral resource, org.apache.clerezza.rdf.core.UriRef property, java.lang.Class<T> type, org.apache.clerezza.rdf.core.LiteralFactory literalFactory)
          Getter for the typed literal values of the property for a resource
static java.util.UUID randomUUID()
          Random UUID generator with re-seedable RNG for the tests.
static void setSeed(long seed)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rng

protected static java.util.Random rng

EXECUTION_ORDER_COMPARATOR

public static final java.util.Comparator<EnhancementEngine> EXECUTION_ORDER_COMPARATOR
Comparator that allows to sort a list/array of EnhancementEngines based on there ServiceProperties.ENHANCEMENT_ENGINE_ORDERING.

Constructor Detail

EnhancementEngineHelper

public EnhancementEngineHelper()
Method Detail

setSeed

public static void setSeed(long seed)

createTextEnhancement

public static org.apache.clerezza.rdf.core.UriRef createTextEnhancement(ContentItem ci,
                                                                        EnhancementEngine engine)
Create a new instance with the types enhancer:Enhancement and enhancer:TextAnnotation in the metadata-graph of the content item along with default properties (dc:creator and dc:created) and return the UriRef of the extraction so that engines can further add.

Parameters:
ci - the ContentItem being under analysis
engine - the Engine performing the analysis
Returns:
the URI of the new enhancement instance

createTextEnhancement

public static org.apache.clerezza.rdf.core.UriRef createTextEnhancement(org.apache.clerezza.rdf.core.MGraph metadata,
                                                                        EnhancementEngine engine,
                                                                        org.apache.clerezza.rdf.core.UriRef contentItemId)
Create a new instance with the types enhancer:Enhancement and enhancer:TextAnnotation in the parsed graph along with default properties (dc:creator, dc:created and enhancer:extracted-form) and return the UriRef of the extraction so that engines can further add.

Parameters:
metadata - the graph
engine - the engine
contentItemId - the id
Returns:
the URI of the new enhancement instance

createEntityEnhancement

public static org.apache.clerezza.rdf.core.UriRef createEntityEnhancement(ContentItem ci,
                                                                          EnhancementEngine engine)
Create a new instance with the types enhancer:Enhancement and enhancer:EntityAnnotation in the metadata-graph of the content item along with default properties (dc:creator and dc:created) and return the UriRef of the extraction so that engines can further add

Parameters:
ci - the ContentItem being under analysis
engine - the Engine performing the analysis
Returns:
the URI of the new enhancement instance

createEntityEnhancement

public static org.apache.clerezza.rdf.core.UriRef createEntityEnhancement(org.apache.clerezza.rdf.core.MGraph metadata,
                                                                          EnhancementEngine engine,
                                                                          org.apache.clerezza.rdf.core.UriRef contentItemId)
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 UriRef of the extraction so that engines can further add.

Parameters:
metadata - the graph
engine - the engine
contentItemId - the id
Returns:
the URI of the new enhancement instance

createEnhancement

protected static org.apache.clerezza.rdf.core.UriRef createEnhancement(org.apache.clerezza.rdf.core.MGraph metadata,
                                                                       EnhancementEngine engine,
                                                                       org.apache.clerezza.rdf.core.UriRef contentItemId)
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 UriRef of the extraction so that engines can further add.

Parameters:
ci - the ContentItem being under analysis
engine - the Engine performing the analysis
Returns:
the URI of the new enhancement instance

createNewExtraction

@Deprecated
public static org.apache.clerezza.rdf.core.UriRef createNewExtraction(ContentItem ci,
                                                                                 EnhancementEngine engine)
Deprecated. 

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 UriRef of the extraction so that engines can further add

Parameters:
ci - the ContentItem being under analysis
engine - the Engine performing the analysis
Returns:
the URI of the new extraction instance
See Also:
createEntityEnhancement(ContentItem, EnhancementEngine), createTextEnhancement(ContentItem, EnhancementEngine)

randomUUID

public static java.util.UUID randomUUID()
Random UUID generator with re-seedable RNG for the tests.

Returns:
a new Random UUID

get

public static <T> T get(org.apache.clerezza.rdf.core.TripleCollection graph,
                        org.apache.clerezza.rdf.core.NonLiteral resource,
                        org.apache.clerezza.rdf.core.UriRef property,
                        java.lang.Class<T> type,
                        org.apache.clerezza.rdf.core.LiteralFactory literalFactory)
Getter for the first typed literal value of the property for a resource.

Type Parameters:
T - the java class the literal value needs to be converted to. Note that the parsed LiteralFactory needs to support this conversion
Parameters:
graph - the graph used to query for the property value
resource - the resource
property - the property
type - the type the literal needs to be converted to
literalFactory - the literalFactory
Returns:
the value

getValues

public static <T> java.util.Iterator<T> getValues(org.apache.clerezza.rdf.core.TripleCollection graph,
                                                  org.apache.clerezza.rdf.core.NonLiteral resource,
                                                  org.apache.clerezza.rdf.core.UriRef property,
                                                  java.lang.Class<T> type,
                                                  org.apache.clerezza.rdf.core.LiteralFactory literalFactory)
Getter for the typed literal values of the property for a resource

Type Parameters:
T - the java class the literal value needs to be converted to. Note that the parsed LiteralFactory needs to support this conversion
Parameters:
graph - the graph used to query for the property value
resource - the resource
property - the property
type - the type the literal needs to be converted to
literalFactory - the literalFactory
Returns:
the value

getString

public static java.lang.String getString(org.apache.clerezza.rdf.core.TripleCollection graph,
                                         org.apache.clerezza.rdf.core.NonLiteral resource,
                                         org.apache.clerezza.rdf.core.UriRef property)
Getter for the first String literal value the property for a resource

Parameters:
graph - the graph used to query for the property value
resource - the resource
property - the property
Returns:
the value

getStrings

public static java.util.Iterator<java.lang.String> getStrings(org.apache.clerezza.rdf.core.TripleCollection graph,
                                                              org.apache.clerezza.rdf.core.NonLiteral resource,
                                                              org.apache.clerezza.rdf.core.UriRef property)
Getter for the string literal values the property for a resource

Parameters:
graph - the graph used to query for the property value
resource - the resource
property - the property
Returns:
the value

getReference

public static org.apache.clerezza.rdf.core.UriRef getReference(org.apache.clerezza.rdf.core.TripleCollection graph,
                                                               org.apache.clerezza.rdf.core.NonLiteral resource,
                                                               org.apache.clerezza.rdf.core.UriRef property)
Getter for the first value of the data type property for a resource

Parameters:
graph - the graph used to query for the property value
resource - the resource
property - the property
Returns:
the value

getReferences

public static java.util.Iterator<org.apache.clerezza.rdf.core.UriRef> getReferences(org.apache.clerezza.rdf.core.TripleCollection graph,
                                                                                    org.apache.clerezza.rdf.core.NonLiteral resource,
                                                                                    org.apache.clerezza.rdf.core.UriRef property)
Getter for the values of the data type property for a resource.

Parameters:
graph - the graph used to query for the property value
resource - the resource
property - the property
Returns:
The iterator over all the values (

getEngineOrder

public static java.lang.Integer getEngineOrder(EnhancementEngine engine)
Gets the ServiceProperties.ENHANCEMENT_ENGINE_ORDERING value for the parsed EnhancementEngine. If the Engine does not implement the ServiceProperties interface or does not provide the ServiceProperties.ENHANCEMENT_ENGINE_ORDERING the ServiceProperties.ORDERING_DEFAULT is returned

This method is guaranteed to NOT return null.

Parameters:
engine - the engine
Returns:
the ordering


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.