You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by rw...@apache.org on 2012/05/31 14:16:37 UTC
svn commit: r1344669 - in
/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src:
main/java/org/apache/stanbol/enhancer/engines/celi/
main/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/
main/java/org/apache/stanbol/en...
Author: rwesten
Date: Thu May 31 12:16:36 2012
New Revision: 1344669
URL: http://svn.apache.org/viewvc?rev=1344669&view=rev
Log:
STANBOL-583: Commit an intermediate version mainly because I have added an unit test for the NER engine that fails because the CELI server response contains illegal formatted results.
Added:
incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliConstants.java (with props)
Modified:
incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngine.java
incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngine.java
incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngine.java
incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngine.java
incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/OSGI-INF/metatype/metatype.properties
incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngineTest.java
incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/testutils/MockComponentContext.java
Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliConstants.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliConstants.java?rev=1344669&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliConstants.java (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliConstants.java Thu May 31 12:16:36 2012
@@ -0,0 +1,27 @@
+package org.apache.stanbol.enhancer.engines.celi;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.service.component.ComponentContext;
+
+public interface CeliConstants {
+
+ /**
+ * Property used to provide the license key for the CELI service to all the
+ * CELI engines.<p>
+ * License keys are read from:<ol>
+ * <li> {@link ComponentContext#getProperties()} - engine configuration:
+ * This can be used to configure a specific keys for single Engine
+ * <li> {@link BundleContext#getProperty(String)} - system configuration:
+ * This can be used to configure the key within the "sling.properties" file
+ * or as a system property when starting the Stanbol instance.
+ * </ol>
+ * <b>Note</b><ul>
+ * <li> License keys configures like that will be used by all CELI engines
+ * that do not provide there own key.
+ * <li> If the License key is configured via a System property it can be
+ * also accessed by other components.
+ * </ul>
+ */
+ String CELI_LICENSE = "celi.license";
+
+}
Propchange: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/CeliConstants.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngine.java?rev=1344669&r1=1344668&r2=1344669&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngine.java (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngine.java Thu May 31 12:16:36 2012
@@ -36,6 +36,7 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.commons.stanboltools.offline.OnlineMode;
+import org.apache.stanbol.enhancer.engines.celi.CeliConstants;
import org.apache.stanbol.enhancer.servicesapi.Blob;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
import org.apache.stanbol.enhancer.servicesapi.EngineException;
@@ -56,7 +57,10 @@ import org.slf4j.LoggerFactory;
@Component(immediate = true, metatype = true)
@Service
-@Properties(value = { @Property(name = EnhancementEngine.PROPERTY_NAME, value = "celiClassification") })
+@Properties(value = {
+ @Property(name = EnhancementEngine.PROPERTY_NAME, value = "celiClassification"),
+ @Property(name = CeliConstants.CELI_LICENSE)
+})
public class CeliClassificationEnhancementEngine extends AbstractEnhancementEngine<IOException, RuntimeException> implements EnhancementEngine, ServiceProperties {
/**
@@ -115,11 +119,9 @@ public class CeliClassificationEnhanceme
*/
private static final Set<String> SUPPORTED_MIMTYPES = Collections.singleton(TEXT_PLAIN_MIMETYPE);
- @Property
- public static final String LICENSE_KEY = "org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine.license";
@Property(value = "http://linguagrid.org/LSGrid/ws/dbpedia-classification")
- public static final String SERVICE_URL = "org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine.url";
+ public static final String SERVICE_URL = "org.apache.stanbol.enhancer.engines.celi.classification.url";
private String licenseKey;
private URL serviceURL;
@@ -132,7 +134,10 @@ public class CeliClassificationEnhanceme
super.activate(ctx);
@SuppressWarnings("unchecked")
Dictionary<String, Object> properties = ctx.getProperties();
- this.licenseKey = (String) properties.get(LICENSE_KEY);
+ this.licenseKey = (String) properties.get(CeliConstants.CELI_LICENSE);
+ if(licenseKey == null || licenseKey.isEmpty()){
+ this.licenseKey = ctx.getBundleContext().getProperty(CeliConstants.CELI_LICENSE);
+ }
if (licenseKey == null || licenseKey.isEmpty()) {
log.warn("no CELI license key configured for this Engine, a guest account will be used (max 100 requests per day). Go on http://linguagrid.org for getting a proper license key.");
}
Modified: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngine.java?rev=1344669&r1=1344668&r2=1344669&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngine.java (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngine.java Thu May 31 12:16:36 2012
@@ -30,6 +30,7 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.commons.stanboltools.offline.OnlineMode;
+import org.apache.stanbol.enhancer.engines.celi.CeliConstants;
import org.apache.stanbol.enhancer.servicesapi.Blob;
import org.apache.stanbol.enhancer.servicesapi.Chain;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
@@ -48,7 +49,10 @@ import org.slf4j.LoggerFactory;
@Component(immediate = true, metatype = true)
@Service
-@Properties(value = { @Property(name = EnhancementEngine.PROPERTY_NAME, value = "celiLangid") })
+@Properties(value = {
+ @Property(name = EnhancementEngine.PROPERTY_NAME, value = "celiLangid"),
+ @Property(name = CeliConstants.CELI_LICENSE)
+})
public class CeliLanguageIdentifierEnhancementEngine extends AbstractEnhancementEngine<IOException, RuntimeException> implements EnhancementEngine, ServiceProperties {
/**
* This ensures that no connections to external services are made if Stanbol is started in offline mode
@@ -84,8 +88,6 @@ public class CeliLanguageIdentifierEnhan
*/
private final LiteralFactory literalFactory = LiteralFactory.getInstance();
- @Property
- public static final String LICENSE_KEY = "org.apache.stanbol.enhancer.engines.celi.langid.license";
@Property(value = "http://linguagrid.org/LSGrid/ws/language-identifier")
public static final String SERVICE_URL = "org.apache.stanbol.enhancer.engines.celi.langid.url";
@@ -100,7 +102,10 @@ public class CeliLanguageIdentifierEnhan
public void activate(ComponentContext ctx) throws IOException, ConfigurationException {
super.activate(ctx);
Dictionary<String, Object> properties = ctx.getProperties();
- this.licenseKey = (String) properties.get(LICENSE_KEY);
+ this.licenseKey = (String) properties.get(CeliConstants.CELI_LICENSE);
+ if (licenseKey == null || licenseKey.isEmpty()) {
+ this.licenseKey = ctx.getBundleContext().getProperty(CeliConstants.CELI_LICENSE);
+ }
if (licenseKey == null || licenseKey.isEmpty()) {
log.warn("no CELI license key configured for this Engine, a guest account will be used (max 100 requests per day). Go on http://linguagrid.org for getting a proper license key.");
}
Modified: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngine.java?rev=1344669&r1=1344668&r2=1344669&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngine.java (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngine.java Thu May 31 12:16:36 2012
@@ -33,6 +33,7 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.commons.stanboltools.offline.OnlineMode;
+import org.apache.stanbol.enhancer.engines.celi.CeliConstants;
import org.apache.stanbol.enhancer.servicesapi.Blob;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
import org.apache.stanbol.enhancer.servicesapi.EngineException;
@@ -49,7 +50,10 @@ import org.slf4j.LoggerFactory;
@Component(immediate = true, metatype = true)
@Service
-@Properties(value = { @Property(name = EnhancementEngine.PROPERTY_NAME, value = "celiLemmatizer") })
+@Properties(value = {
+ @Property(name = EnhancementEngine.PROPERTY_NAME, value = "celiLemmatizer"),
+ @Property(name = CeliConstants.CELI_LICENSE)
+})
public class CeliLemmatizerEnhancementEngine extends AbstractEnhancementEngine<IOException, RuntimeException> implements EnhancementEngine, ServiceProperties {
/**
@@ -96,9 +100,6 @@ public class CeliLemmatizerEnhancementEn
*/
private static final Set<String> SUPPORTED_MIMTYPES = Collections.singleton(TEXT_PLAIN_MIMETYPE);
- @Property
- public static final String LICENSE_KEY = "org.apache.stanbol.enhancer.engines.celi.lemmatizer.license";
-
@Property(value = "http://linguagrid.org/LSGrid/ws/morpho-analyser")
public static final String SERVICE_URL = "org.apache.stanbol.enhancer.engines.celi.lemmatizer.url";
@@ -116,7 +117,10 @@ public class CeliLemmatizerEnhancementEn
protected void activate(ComponentContext ctx) throws IOException, ConfigurationException {
super.activate(ctx);
Dictionary<String, Object> properties = ctx.getProperties();
- this.licenseKey = (String) properties.get(LICENSE_KEY);
+ this.licenseKey = (String) properties.get(CeliConstants.CELI_LICENSE);
+ if (licenseKey == null || licenseKey.isEmpty()) {
+ this.licenseKey = ctx.getBundleContext().getProperty(CeliConstants.CELI_LICENSE);
+ }
if (licenseKey == null || licenseKey.isEmpty()) {
log.warn("no CELI license key configured for this Engine, a guest account will be used (max 100 requests per day). Go on http://linguagrid.org for getting a proper license key.");
}
Modified: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngine.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngine.java?rev=1344669&r1=1344668&r2=1344669&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngine.java (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngine.java Thu May 31 12:16:36 2012
@@ -39,6 +39,7 @@ import org.apache.felix.scr.annotations.
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.stanbol.commons.stanboltools.offline.OnlineMode;
+import org.apache.stanbol.enhancer.engines.celi.CeliConstants;
import org.apache.stanbol.enhancer.servicesapi.Blob;
import org.apache.stanbol.enhancer.servicesapi.ContentItem;
import org.apache.stanbol.enhancer.servicesapi.EngineException;
@@ -56,7 +57,10 @@ import org.slf4j.LoggerFactory;
@Component(immediate = true, metatype = true)
@Service
-@Properties(value = { @Property(name = EnhancementEngine.PROPERTY_NAME, value = "celiNer") })
+@Properties(value = {
+ @Property(name = EnhancementEngine.PROPERTY_NAME, value = "celiNer"),
+ @Property(name = CeliConstants.CELI_LICENSE)
+})
public class CeliNamedEntityExtractionEnhancementEngine extends AbstractEnhancementEngine<IOException, RuntimeException> implements EnhancementEngine, ServiceProperties {
/**
@@ -107,9 +111,6 @@ public class CeliNamedEntityExtractionEn
*/
private static final Set<String> SUPPORTED_MIMTYPES = Collections.singleton(TEXT_PLAIN_MIMETYPE);
- @Property
- public static final String LICENSE_KEY = "org.apache.stanbol.enhancer.engines.celi.ner.license";
-
@Property(value = "http://linguagrid.org/LSGrid/ws/com.celi-france.linguagrid.namedentityrecognition.v0u0.demo")
public static final String SERVICE_URL = "org.apache.stanbol.enhancer.engines.celi.ner.url";
@@ -130,7 +131,10 @@ public class CeliNamedEntityExtractionEn
Dictionary<String, Object> properties = ctx.getProperties();
log.info("Activate CELI NER engine:");
log.info(" > name: {}",getName());
- this.licenseKey = (String) properties.get(LICENSE_KEY);
+ this.licenseKey = (String) properties.get(CeliConstants.CELI_LICENSE);
+ if (licenseKey == null || licenseKey.isEmpty()) {
+ this.licenseKey = ctx.getBundleContext().getProperty(CeliConstants.CELI_LICENSE);
+ }
if (licenseKey == null || licenseKey.isEmpty()) {
log.warn("no CELI license key configured for this Engine, a guest account will be used (max 100 requests per day). Go on http://linguagrid.org for getting a proper license key.");
}
@@ -144,24 +148,32 @@ public class CeliNamedEntityExtractionEn
log.info(" > CELI service: {}",serviceURL);
//init the supported languages (now configurable)
- Object languagObject = properties.get(SUPPORTED_LANGUAGES);
+ Object languageObject = properties.get(SUPPORTED_LANGUAGES);
HashSet<String> languages;
- if(languagObject instanceof String){
+ if(languageObject instanceof String){
//support splitting multiple languages with ';'
- languages = new HashSet<String>(Arrays.asList(languagObject.toString().split(";")));
+ languages = new HashSet<String>(Arrays.asList(languageObject.toString().split(";")));
if(languages.remove("")){
- log.warn("Languages configuration '{}' contained empty language -> removed",languagObject);
+ log.warn("Languages configuration '{}' contained empty language -> removed",languageObject);
}//empty not allowed
- } else if(languagObject instanceof Iterable<?>){
+ } else if(languageObject instanceof Iterable<?>){ //does not work for arrays :(
languages = new HashSet<String>();
- for(Object o : (Iterable<Object>)languagObject){
+ for(Object o : (Iterable<Object>)languageObject){
if(o != null && !o.toString().isEmpty()){
languages.add(o.toString());
} else {
log.warn("Language configuration '{}' contained illegal value '{}' -> removed",
- languagObject.getClass().isArray()?
- Arrays.toString((Object[])languagObject): //nicer logging for arrays
- languagObject,o);
+ languageObject,o);
+ }
+ }
+ } else if(languageObject.getClass().isArray()){
+ languages = new HashSet<String>();
+ for(Object langObj : (Object[])languageObject){
+ if(langObj != null){
+ languages.add(langObj.toString());
+ } else {
+ log.warn("Language configuration '{}' contained illegal value '{}' -> removed",
+ Arrays.toString((Object[])languageObject),langObj);
}
}
} else {
@@ -170,9 +182,9 @@ public class CeliNamedEntityExtractionEn
if(languages == null || languages.isEmpty()){
throw new ConfigurationException(SUPPORTED_LANGUAGES, String.format(
"Missing or invalid configuration of the supported languages (config :'%s'",
- languagObject != null && languagObject.getClass().isArray() ?
- Arrays.toString((Object[])languagObject): //nicer logging for arrays
- languagObject));
+ languageObject != null && languageObject.getClass().isArray() ?
+ Arrays.toString((Object[])languageObject): //nicer logging for arrays
+ languageObject));
}
this.supportedLangs = Collections.unmodifiableSet(languages);
log.info(" > supported languages: {}",supportedLangs);
@@ -194,7 +206,7 @@ public class CeliNamedEntityExtractionEn
log.info("Unable to extract language annotation for ContentItem -> will not enhance",
ci.getUri());
return CANNOT_ENHANCE;
- } else if(isLangSupported(language)){
+ } else if(!isLangSupported(language)){
log.debug("Language '{}' of contentItem {} is not supported (supported: {}) -> will not enhance",
new Object[]{language,ci.getUri(),supportedLangs});
return CANNOT_ENHANCE;
Modified: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/OSGI-INF/metatype/metatype.properties
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/OSGI-INF/metatype/metatype.properties?rev=1344669&r1=1344668&r2=1344669&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/OSGI-INF/metatype/metatype.properties (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/OSGI-INF/metatype/metatype.properties Thu May 31 12:16:36 2012
@@ -23,14 +23,18 @@
#Properties and Options used to configure CELI enhancement
#===============================================================================
+#Key for the License key - used by all engines (see also CeliConstants interface)
+
+celi.license.name=License Key
+celi.license.description=The key needed to access the CELI Named Entity Recognizer \
+Web Service. This can be also set as OSGI framework or system property. An engine \
+specific configuration will override a framework/system wide configuration.
+
#NER
org.apache.stanbol.enhancer.engines.celi.ner.impl.CeliNamedEntityExtractionEnhancementEngine.name=Apache Stanbol Enhancer Engine: CELI Named Entity Recognizer
org.apache.stanbol.enhancer.engines.celi.ner.impl.CeliNamedEntityExtractionEnhancementEngine.description=An Enhancement Engine that sends ContentItems to CELI Named Entity Recognizer Web Service and converts the results to the Stanbol Enhancement Structure
-org.apache.stanbol.enhancer.engines.celi.ner.license.name=License Key
-org.apache.stanbol.enhancer.engines.celi.ner.license.description=The key needed to access the CELI Named Entity Recognizer Web Service
-
org.apache.stanbol.enhancer.engines.celi.ner.url.name=Service URL
org.apache.stanbol.enhancer.engines.celi.ner.url.description=The URL of the CELI Named Entity Recognizer Web Service
@@ -41,31 +45,21 @@ org.apache.stanbol.enhancer.engines.celi
org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine.name=Apache Stanbol Enhancer Engine: CELI Document Classification
org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine.description=An Enhancement Engine that sends ContentItems to CELI Document Classification Web Service and converts the results to the Stanbol Enhancement Structure
-org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine.license.name=License Key
-org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine.license.description=The key needed to access the CELI Document Classification Web Service
-
-org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine.url.name=Service URL
-org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine.url.description=The URL of the CELI Document Classification Web Service
+org.apache.stanbol.enhancer.engines.celi.classification.url.name=Service URL
+org.apache.stanbol.enhancer.engines.celi.classification.url.description=The URL of the CELI Document Classification Web Service
#LID
org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngine.name=Apache Stanbol Enhancer Engine: CELI Language Identifier
org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngine.description=An Enhancement Engine that sends ContentItems to Language Identifier Web Service and converts the results to the Stanbol Enhancement Structure
-org.apache.stanbol.enhancer.engines.celi.langid.license.name=License Key
-org.apache.stanbol.enhancer.engines.celi.langid.license.description=The key needed to access the CELI Language Identifier Web Service
-
org.apache.stanbol.enhancer.engines.celi.langid.url.name=Service URL
org.apache.stanbol.enhancer.engines.celi.langid.url.description=The URL of the CELI Language Identifier Web Service
-
#LEMM
org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.name=Apache Stanbol Enhancer Engine: CELI Lemmatizer
org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.description=An Enhancement Engine that sends ContentItems to OpenCalais and converts the results to the Stanbol Enhancement Structure
-org.apache.stanbol.enhancer.engines.celi.lemmatizer.license.name=License Key
-org.apache.stanbol.enhancer.engines.celi.lemmatizer.license.description=The key needed to access the CELI Lemmatizer Web Service
-
org.apache.stanbol.enhancer.engines.celi.lemmatizer.url.name=Service URL
org.apache.stanbol.enhancer.engines.celi.lemmatizer.url.description=The URL of the CELI Lemmatizer Web Service
Modified: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngineTest.java?rev=1344669&r1=1344668&r2=1344669&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngineTest.java (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngineTest.java Thu May 31 12:16:36 2012
@@ -47,6 +47,14 @@ public class CeliNamedEntityExtractionEn
private static final String TEXT_fr = "Brigitte Bardot, née le 28 septembre " +
"1934 à Paris, est une actrice de cinéma et chanteuse française.";
+ private static final String TEXT_fr2 = "Le premier ministre français a annoncé " +
+ "mardi 29 mai, dans un entretien à LâExpress, que la baisse des rémunérations " +
+ "des grands patrons des entreprises publiques sâappliquerait aussi aux « " +
+ "contrats en cours ». « Je crois au patriotisme des dirigeants, qui peuvent " +
+ "comprendre que la crise suppose lâexemplarité des élites politiques et " +
+ "économiques », a-t-il argumenté. La rémunération du président de la " +
+ "République, du premier ministre et des ministres a du reste déjà été abaissée.";
+
@BeforeClass
public static void setUpServices() throws IOException, ConfigurationException {
Dictionary<String, Object> properties = new Hashtable<String, Object>();
@@ -96,6 +104,7 @@ public class CeliNamedEntityExtractionEn
public void tesetEngine() throws Exception {
this.testInput(CeliNamedEntityExtractionEnhancementEngineTest.TEXT_it, "it");
this.testInput(CeliNamedEntityExtractionEnhancementEngineTest.TEXT_fr, "fr");
+ this.testInput(CeliNamedEntityExtractionEnhancementEngineTest.TEXT_fr2, "fr");
}
// private int checkAllEntityAnnotations(MGraph g) {
Modified: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/testutils/MockComponentContext.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/testutils/MockComponentContext.java?rev=1344669&r1=1344668&r2=1344669&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/testutils/MockComponentContext.java (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/testutils/MockComponentContext.java Thu May 31 12:16:36 2012
@@ -16,18 +16,28 @@
*/
package org.apache.stanbol.enhancer.engines.celi.testutils;
+import java.io.File;
+import java.io.InputStream;
import java.util.Dictionary;
import java.util.Hashtable;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.BundleListener;
+import org.osgi.framework.Filter;
+import org.osgi.framework.FrameworkListener;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceListener;
import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.ComponentInstance;
public class MockComponentContext implements ComponentContext {
protected final Dictionary<String, Object> properties;
+ protected final BundleContext bundleContext = new MockBundleContext();
public MockComponentContext() {
properties = new Hashtable<String, Object>();
@@ -38,17 +48,19 @@ public class MockComponentContext implem
}
public void disableComponent(String name) {
+ throw new UnsupportedOperationException("Mock implementation");
}
public void enableComponent(String name) {
+ throw new UnsupportedOperationException("Mock implementation");
}
public BundleContext getBundleContext() {
- return null;
+ return bundleContext;
}
public ComponentInstance getComponentInstance() {
- return null;
+ throw new UnsupportedOperationException("Mock implementation");
}
public Dictionary<String, Object> getProperties() {
@@ -56,23 +68,138 @@ public class MockComponentContext implem
}
public ServiceReference getServiceReference() {
- return null;
+ throw new UnsupportedOperationException("Mock implementation");
}
public Bundle getUsingBundle() {
- return null;
+ throw new UnsupportedOperationException("Mock implementation");
}
public Object locateService(String name) {
- return null;
+ throw new UnsupportedOperationException("Mock implementation");
}
public Object locateService(String name, ServiceReference reference) {
- return null;
+ throw new UnsupportedOperationException("Mock implementation");
}
public Object[] locateServices(String name) {
- return null;
+ throw new UnsupportedOperationException("Mock implementation");
}
+ private static final class MockBundleContext implements BundleContext {
+ /**
+ * Used by the Engine to read System properties
+ */
+ @Override
+ public String getProperty(String key) {
+ return System.getProperty(key);
+ }
+
+ @Override
+ public Bundle getBundle() {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public Bundle installBundle(String location) throws BundleException {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public Bundle installBundle(String location, InputStream input) throws BundleException {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public Bundle getBundle(long id) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public Bundle[] getBundles() {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public void addServiceListener(ServiceListener listener, String filter) throws InvalidSyntaxException {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public void addServiceListener(ServiceListener listener) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public void removeServiceListener(ServiceListener listener) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public void addBundleListener(BundleListener listener) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public void removeBundleListener(BundleListener listener) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public void addFrameworkListener(FrameworkListener listener) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public void removeFrameworkListener(FrameworkListener listener) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public ServiceRegistration registerService(String[] clazzes, Object service, Dictionary properties) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public ServiceRegistration registerService(String clazz, Object service, Dictionary properties) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public ServiceReference[] getServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public ServiceReference[] getAllServiceReferences(String clazz, String filter) throws InvalidSyntaxException {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public ServiceReference getServiceReference(String clazz) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public Object getService(ServiceReference reference) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public boolean ungetService(ServiceReference reference) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public File getDataFile(String filename) {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ @Override
+ public Filter createFilter(String filter) throws InvalidSyntaxException {
+ throw new UnsupportedOperationException("Mock implementation");
+ }
+
+ }
}