org.apache.stanbol.enhancer.engines.restful.nlp.impl
Class RestfulNlpAnalysisEngine

java.lang.Object
  extended by org.apache.stanbol.enhancer.servicesapi.impl.AbstractEnhancementEngine<IOException,RuntimeException>
      extended by org.apache.stanbol.enhancer.engines.restful.nlp.impl.RestfulNlpAnalysisEngine
All Implemented Interfaces:
org.apache.stanbol.enhancer.servicesapi.EnhancementEngine, org.apache.stanbol.enhancer.servicesapi.ServiceProperties

@Service
@Properties(value={@Property(name="stanbol.enhancer.engine.name",value="changeme"),@Property(name="enhancer.engine.restful.nlp.languages",value="*",cardinality=2147483647),@Property(name="enhancer.engine.restful.nlp.analysis.service",value="http://changeme"),@Property(name="enhancer.engine.restful.nlp.analysis.service.user",value=""),@Property(name="enhancer.engine.restful.nlp.analysis.service.pwd",value=""),@Property(name="service.ranking",intValue=0)})
public class RestfulNlpAnalysisEngine
extends org.apache.stanbol.enhancer.servicesapi.impl.AbstractEnhancementEngine<IOException,RuntimeException>
implements org.apache.stanbol.enhancer.servicesapi.ServiceProperties

An enhancement engine that uses a RESTful service for NLP processing of the pain text content part of processed ContentItems.

The RESTful API of the remote service is standardised by STANBOL-892

Author:
Rupert Westenthaler

Nested Class Summary
protected  class RestfulNlpAnalysisEngine.AnalysisResponseHandler
           
 
Field Summary
static String ANALYSIS_SERVICE_PWD
          The User for the remote analyses service
static String ANALYSIS_SERVICE_URL
          The URI for the remote analyses service
static String ANALYSIS_SERVICE_USER
          The User for the remote analyses service
static String CONFIG_LANGUAGES
          Language configuration.
protected  org.apache.http.impl.client.DefaultHttpClient httpClient
           
 
Fields inherited from interface org.apache.stanbol.enhancer.servicesapi.ServiceProperties
ENHANCEMENT_ENGINE_ORDERING, ORDERING_CONTENT_EXTRACTION, ORDERING_DEFAULT, ORDERING_EXTRACTION_ENHANCEMENT, ORDERING_NLP_CHUNK, ORDERING_NLP_LANGAUGE_DETECTION, ORDERING_NLP_LEMMATIZE, ORDERING_NLP_POS, ORDERING_NLP_SENTENCE_DETECTION, ORDERING_NLP_TOKENIZING, ORDERING_POST_PROCESSING, ORDERING_PRE_PROCESSING
 
Fields inherited from interface org.apache.stanbol.enhancer.servicesapi.EnhancementEngine
CANNOT_ENHANCE, ENHANCE_ASYNC, ENHANCE_SYNCHRONOUS, PROPERTY_NAME
 
Constructor Summary
RestfulNlpAnalysisEngine()
           
 
Method Summary
protected  void activate(org.osgi.service.component.ComponentContext ce)
          Activate and read the properties.
 int canEnhance(org.apache.stanbol.enhancer.servicesapi.ContentItem ci)
          Indicate if this engine can enhance supplied ContentItem, and if it suggests enhancing it synchronously or asynchronously.
 void computeEnhancements(org.apache.stanbol.enhancer.servicesapi.ContentItem ci)
          Compute enhancements for supplied ContentItem.
protected  void deactivate(org.osgi.service.component.ComponentContext context)
           
 Map<String,Object> getServiceProperties()
           
 
Methods inherited from class org.apache.stanbol.enhancer.servicesapi.impl.AbstractEnhancementEngine
getName, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANALYSIS_SERVICE_URL

public static final String ANALYSIS_SERVICE_URL
The URI for the remote analyses service

See Also:
Constant Field Values

ANALYSIS_SERVICE_USER

public static final String ANALYSIS_SERVICE_USER
The User for the remote analyses service

See Also:
Constant Field Values

ANALYSIS_SERVICE_PWD

public static final String ANALYSIS_SERVICE_PWD
The User for the remote analyses service

See Also:
Constant Field Values

CONFIG_LANGUAGES

public static final String CONFIG_LANGUAGES
Language configuration. Takes a list of ISO language codes to be processed by this engine. This list will be joined with the list of languages supported by the RESTful NLP analysis service.

See Also:
Constant Field Values

httpClient

protected org.apache.http.impl.client.DefaultHttpClient httpClient
Constructor Detail

RestfulNlpAnalysisEngine

public RestfulNlpAnalysisEngine()
Method Detail

canEnhance

public int canEnhance(org.apache.stanbol.enhancer.servicesapi.ContentItem ci)
               throws org.apache.stanbol.enhancer.servicesapi.EngineException
Indicate if this engine can enhance supplied ContentItem, and if it suggests enhancing it synchronously or asynchronously. The EnhancementJobManager can force sync/async mode if desired, it is just a suggestion from the engine.

Returns ENHANCE_ASYNC in case there is a text/plain content part and a tagger for the language identified for the content item, CANNOT_ENHANCE otherwise.

Specified by:
canEnhance in interface org.apache.stanbol.enhancer.servicesapi.EnhancementEngine
Throws:
org.apache.stanbol.enhancer.servicesapi.EngineException - if the introspecting process of the content item fails

computeEnhancements

public void computeEnhancements(org.apache.stanbol.enhancer.servicesapi.ContentItem ci)
                         throws org.apache.stanbol.enhancer.servicesapi.EngineException
Compute enhancements for supplied ContentItem. The results of the process are expected to be stored in the metadata of the content item.

The client (usually an EnhancementJobManager) should take care of persistent storage of the enhanced ContentItem.

This method creates a new POSContentPart using org.apache.stanbol.enhancer.engines.pos.api.POSTaggerHelper#createContentPart from a text/plain part and stores it as a new part in the content item. The metadata is not changed.

Specified by:
computeEnhancements in interface org.apache.stanbol.enhancer.servicesapi.EnhancementEngine
Throws:
org.apache.stanbol.enhancer.servicesapi.EngineException - if the underlying process failed to work as expected

getServiceProperties

public Map<String,Object> getServiceProperties()
Specified by:
getServiceProperties in interface org.apache.stanbol.enhancer.servicesapi.ServiceProperties

activate

@Activate
protected void activate(org.osgi.service.component.ComponentContext ce)
                 throws org.osgi.service.cm.ConfigurationException,
                        IOException
Activate and read the properties. Configures and initialises a POSTagger for each language configured in CONFIG_LANGUAGES.

Overrides:
activate in class org.apache.stanbol.enhancer.servicesapi.impl.AbstractEnhancementEngine<IOException,RuntimeException>
Parameters:
ce - the ComponentContext
Throws:
org.osgi.service.cm.ConfigurationException
IOException

deactivate

@Deactivate
protected void deactivate(org.osgi.service.component.ComponentContext context)
Overrides:
deactivate in class org.apache.stanbol.enhancer.servicesapi.impl.AbstractEnhancementEngine<IOException,RuntimeException>


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.