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/14 23:07:21 UTC

svn commit: r1338425 [2/2] - in /incubator/stanbol/branches/celi-enhancement-engines: bundlelist/src/main/bundles/ engines/ engines/celi/ engines/celi/src/ engines/celi/src/main/ engines/celi/src/main/java/ engines/celi/src/main/java/org/ engines/celi/...

Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/NERserviceClientHTTP.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/NERserviceClientHTTP.java?rev=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/NERserviceClientHTTP.java (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/NERserviceClientHTTP.java Mon May 14 21:07:19 2012
@@ -0,0 +1,120 @@
+package org.apache.stanbol.enhancer.engines.celi.ner.impl;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.List;
+import java.util.Vector;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.clerezza.rdf.core.impl.util.Base64;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang.StringEscapeUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+
+public class NERserviceClientHTTP {
+
+	private URL serviceEP;
+	private String licenseKey;
+	
+	private final Logger log = LoggerFactory.getLogger(getClass());
+		
+	public NERserviceClientHTTP(URL serviceUrl, String licenseKey){
+		this.serviceEP=serviceUrl;
+		this.licenseKey=licenseKey;
+	}
+	
+	public InputStream doPostRequest(URL url, String body) throws IOException {
+		
+		HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
+		urlConn.setRequestMethod("POST");
+		urlConn.setDoInput(true);
+		if (null != body) {
+			urlConn.setDoOutput(true);
+		} else {
+			urlConn.setDoOutput(false);
+		}
+		urlConn.setUseCaches(false);
+		String	contentType = "text/xml; charset=utf-8";
+		urlConn.setRequestProperty("Content-Type", contentType);
+		if(this.licenseKey!=null){
+			String encoded = Base64.encode(this.licenseKey.getBytes("UTF-8"));
+			urlConn.setRequestProperty("Authorization", "Basic "+encoded);
+		}
+		
+		// send POST output
+		if (null != body) {
+			OutputStreamWriter printout = new OutputStreamWriter(urlConn.getOutputStream(), "UTF-8");
+			printout.write(body);
+			printout.flush();
+			printout.close();
+		}
+		
+		//close connection
+		urlConn.disconnect();
+		
+		// get response data
+		return urlConn.getInputStream();
+	}
+
+
+	public List<NamedEntity> extractEntities(String text) {
+
+		List<NamedEntity> extractedNE = new Vector<NamedEntity>();
+
+		try {
+			String txt = StringEscapeUtils.escapeXml(text);
+			String xmldata = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:v0u0=\"http://linguagrid.org/ns/namedentityrecognition/v0u0\"><soapenv:Header/><soapenv:Body><v0u0:processTextRequest><v0u0:text>"
+					+ txt + "</v0u0:text></v0u0:processTextRequest></soapenv:Body></soapenv:Envelope>";
+			
+			InputStream resultStream = doPostRequest(serviceEP, xmldata);
+
+			// Create SoapMessage
+			MessageFactory msgFactory = MessageFactory.newInstance();
+			SOAPMessage message = msgFactory.createMessage();
+			SOAPPart soapPart = message.getSOAPPart();
+
+			// Load the SOAP text into a stream source
+			StreamSource source = new StreamSource(resultStream);
+
+			// Set contents of message
+			soapPart.setContent(source);
+
+			SOAPBody soapBody = message.getSOAPBody();
+			NodeList nlist = soapBody.getElementsByTagName("result");
+			for (int i = 0; i < nlist.getLength(); i++) {
+				try {
+					Element result = (Element) nlist.item(i);
+
+					NamedEntity ne = new NamedEntity();
+					ne.setType(result.getElementsByTagNameNS("*","type").item(0).getTextContent());
+					ne.setSource(result.getElementsByTagNameNS("*","source").item(0).getTextContent());
+					ne.setFormKind(result.getElementsByTagNameNS("*","formKind").item(0).getTextContent());
+					ne.setFrom(Long.parseLong(result.getElementsByTagNameNS("*","from").item(0).getTextContent()));
+					ne.setTo(Long.parseLong(result.getElementsByTagNameNS("*","to").item(0).getTextContent()));
+
+					extractedNE.add(ne);
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+
+		return extractedNE;
+	}
+}

Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/NamedEntity.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/NamedEntity.java?rev=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/NamedEntity.java (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/NamedEntity.java Mon May 14 21:07:19 2012
@@ -0,0 +1,216 @@
+
+package org.apache.stanbol.enhancer.engines.celi.ner.impl;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlSchemaType;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for NamedEntity complex type.
+ * 
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ * 
+ * <pre>
+ * &lt;complexType name="NamedEntity">
+ *   &lt;complexContent>
+ *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       &lt;sequence>
+ *         &lt;element name="id" type="{http://www.w3.org/2001/XMLSchema}long"/>
+ *         &lt;element name="type" type="{http://www.w3.org/2001/XMLSchema}anyURI" minOccurs="0"/>
+ *         &lt;element name="source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         &lt;element name="formKind" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         &lt;element name="morphosyntacticFeatures" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
+ *         &lt;element name="from" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
+ *         &lt;element name="to" type="{http://www.w3.org/2001/XMLSchema}long" minOccurs="0"/>
+ *       &lt;/sequence>
+ *     &lt;/restriction>
+ *   &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ * 
+ * 
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "NamedEntity", namespace = "http://linguagrid.org/ns/namedentityrecognition/v0u0", propOrder = {
+    "id",
+    "type",
+    "source",
+    "formKind",
+    "morphosyntacticFeatures",
+    "from",
+    "to"
+})
+public class NamedEntity {
+
+    protected long id;
+    @XmlSchemaType(name = "anyURI")
+    protected String type;
+    protected String source;
+    protected String formKind;
+    protected String morphosyntacticFeatures;
+    protected Long from;
+    protected Long to;
+
+    /**
+     * Gets the value of the id property.
+     * 
+     */
+    public long getId() {
+        return id;
+    }
+
+    /**
+     * Sets the value of the id property.
+     * 
+     */
+    public void setId(long value) {
+        this.id = value;
+    }
+
+    /**
+     * Gets the value of the type property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getType() {
+        return type;
+    }
+
+    /**
+     * Sets the value of the type property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setType(String value) {
+        this.type = value;
+    }
+
+    /**
+     * Gets the value of the source property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getSource() {
+        return source;
+    }
+
+    /**
+     * Sets the value of the source property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setSource(String value) {
+        this.source = value;
+    }
+
+    /**
+     * Gets the value of the formKind property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getFormKind() {
+        return formKind;
+    }
+
+    /**
+     * Sets the value of the formKind property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setFormKind(String value) {
+        this.formKind = value;
+    }
+
+    /**
+     * Gets the value of the morphosyntacticFeatures property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link String }
+     *     
+     */
+    public String getMorphosyntacticFeatures() {
+        return morphosyntacticFeatures;
+    }
+
+    /**
+     * Sets the value of the morphosyntacticFeatures property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link String }
+     *     
+     */
+    public void setMorphosyntacticFeatures(String value) {
+        this.morphosyntacticFeatures = value;
+    }
+
+    /**
+     * Gets the value of the from property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link Long }
+     *     
+     */
+    public Long getFrom() {
+        return from;
+    }
+
+    /**
+     * Sets the value of the from property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link Long }
+     *     
+     */
+    public void setFrom(Long value) {
+        this.from = value;
+    }
+
+    /**
+     * Gets the value of the to property.
+     * 
+     * @return
+     *     possible object is
+     *     {@link Long }
+     *     
+     */
+    public Long getTo() {
+        return to;
+    }
+
+    /**
+     * Sets the value of the to property.
+     * 
+     * @param value
+     *     allowed object is
+     *     {@link Long }
+     *     
+     */
+    public void setTo(Long value) {
+        this.to = value;
+    }
+
+}

Added: 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=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/OSGI-INF/metatype/metatype.properties (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/OSGI-INF/metatype/metatype.properties Mon May 14 21:07:19 2012
@@ -0,0 +1,144 @@
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+# This file contains localization strings for configuration labels and
+# descriptions as used in the metatype.xml descriptor generated by the
+# the maven SCR plugin
+
+#===============================================================================
+#Properties and Options used to configure CELI enhancement 
+#===============================================================================
+
+#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
+
+org.apache.stanbol.enhancer.engines.celi.ner.languages.name=Supported languages
+org.apache.stanbol.enhancer.engines.celi.ner.languages.description=The language(s) supported by the configured Named Entity Recognizer Web Service
+
+#CLASSIFICATION
+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
+
+
+#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.impl.CeliLanguageIdentifierEnhancementEngine.license.name=License Key
+org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngine.license.description=The key needed to access the CELI Language Identifier Web Service
+
+org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngine.url.name=Service URL
+org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngine.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.impl.CeliLemmatizerEnhancementEngine.license.name=License Key
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.license.description=The key needed to access the CELI Lemmatizer Web Service
+
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.url.name=Service URL
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.url.description=The URL of the CELI Lemmatizer Web Service
+
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.morphoAnalysis.name=Full Morphological Analysis
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.morphoAnalysis.description=Boolean value that sets the Engine to full morphological analysis working mode (true) or to textual contents lemmatization (false)
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+
+# This file contains localization strings for configuration labels and
+# descriptions as used in the metatype.xml descriptor generated by the
+# the maven SCR plugin
+
+#===============================================================================
+#Properties and Options used to configure CELI enhancement 
+#===============================================================================
+
+#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.impl.CeliNamedEntityExtractionEnhancementEngine.license.name=License Key
+org.apache.stanbol.enhancer.engines.celi.ner.impl.CeliNamedEntityExtractionEnhancementEngine.license.description=The key needed to access the CELI Named Entity Recognizer Web Service
+
+org.apache.stanbol.enhancer.engines.celi.ner.impl.CeliNamedEntityExtractionEnhancementEngine.url.name=Service URL
+org.apache.stanbol.enhancer.engines.celi.ner.impl.CeliNamedEntityExtractionEnhancementEngine.url.description=The URL of the CELI Named Entity Recognizer Web Service
+
+
+#CLASSIFICATION
+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
+
+
+#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.impl.CeliLanguageIdentifierEnhancementEngine.license.name=License Key
+org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngine.license.description=The key needed to access the CELI Language Identifier Web Service
+
+org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngine.url.name=Service URL
+org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngine.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.impl.CeliLemmatizerEnhancementEngine.license.name=License Key
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.license.description=The key needed to access the CELI Lemmatizer Web Service
+
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.url.name=Service URL
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.url.description=The URL of the CELI Lemmatizer Web Service
+
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.morphoAnalysis.name=Full Morphological Analysis
+org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine.morphoAnalysis.description=Boolean value that sets the Engine to full morphological analysis working mode (true) or to textual contents lemmatization (false)
\ No newline at end of file

Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/log4j.properties?rev=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/log4j.properties (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/main/resources/log4j.properties Mon May 14 21:07:19 2012
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+log4j.rootLogger=WARN, CONSOLE
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%C{1}] %m%n
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+log4j.rootLogger=WARN, CONSOLE
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%C{1}] %m%n
+

Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngineTest.java?rev=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngineTest.java (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/classification/impl/CeliClassificationEnhancementEngineTest.java Mon May 14 21:07:19 2012
@@ -0,0 +1,105 @@
+package org.apache.stanbol.enhancer.engines.celi.classification.impl;
+
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDF_TYPE;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_ENTITYANNOTATION;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_TEXTANNOTATION;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.stanbol.enhancer.contentitem.inmemory.InMemoryContentItemFactory;
+import org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngineTest;
+import org.apache.stanbol.enhancer.engines.celi.test_utils.MockComponentContext;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
+import org.apache.stanbol.enhancer.servicesapi.EngineException;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
+import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
+import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.service.cm.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class CeliClassificationEnhancementEngineTest {
+	
+	static CeliClassificationEnhancementEngine classificationEngine = new CeliClassificationEnhancementEngine();
+
+	private static final ContentItemFactory ciFactory = InMemoryContentItemFactory.getInstance();
+	
+	private static final Logger log = LoggerFactory.getLogger(CeliClassificationEnhancementEngine.class);
+	
+	private static final String TEXT = "Brigitte Bardot, née  le 28 septembre " +
+			"1934 à Paris, est une actrice de cinéma et chanteuse française.";
+
+	@BeforeClass
+	public static void setUpServices() throws IOException, ConfigurationException {
+		Dictionary<String, Object> properties = new Hashtable<String, Object>();
+		properties.put(EnhancementEngine.PROPERTY_NAME, "celiClassification");
+	    properties.put(CeliClassificationEnhancementEngine.SERVICE_URL, "http://linguagrid.org/LSGrid/ws/dbpedia-classification");
+	 	
+		MockComponentContext context = new MockComponentContext(properties);
+		classificationEngine.activate(context);
+	}
+
+	@AfterClass
+	public static void shutdownServices() {
+		classificationEngine.deactivate(null);
+	}
+
+	public static ContentItem wrapAsContentItem(final String text) throws IOException {
+		return ciFactory.createContentItem(new StringSource(text));
+	}
+
+	@Test
+	public void tesetEngine() throws Exception {
+		ContentItem ci = wrapAsContentItem(TEXT);
+		try {
+			CeliLanguageIdentifierEnhancementEngineTest.addEnanchements(ci);
+			
+			classificationEngine.computeEnhancements(ci);
+			int textAnnoNum = checkAllTextAnnotations(ci.getMetadata(), TEXT);
+	        log.info(textAnnoNum + " TextAnnotations found ...");
+	        int entityAnnoNum = checkAllEntityAnnotations(ci.getMetadata());
+	        log.info(entityAnnoNum + " EntityAnnotations found ...");
+		} catch (EngineException e) {
+			if (e.getCause() != null && e.getCause() instanceof UnknownHostException) {
+				log.warn("Celi Service not reachable -> offline? -> deactivate test");
+				return;
+			}
+			throw e;
+		}
+	}
+
+	private int checkAllEntityAnnotations(MGraph g) {
+		Iterator<Triple> entityAnnotationIterator = g.filter(null, RDF_TYPE, ENHANCER_ENTITYANNOTATION);
+		int entityAnnotationCount = 0;
+		while (entityAnnotationIterator.hasNext()) {
+			UriRef entityAnnotation = (UriRef) entityAnnotationIterator.next().getSubject();
+			entityAnnotationCount++;
+		}
+		return entityAnnotationCount;
+	}
+	
+	private int checkAllTextAnnotations(MGraph g, String content) {
+		Iterator<Triple> textAnnotationIterator = g.filter(null, RDF_TYPE, ENHANCER_TEXTANNOTATION);
+		// test if a textAnnotation is present
+		assertTrue(textAnnotationIterator.hasNext());
+		int textAnnotationCount = 0;
+		while (textAnnotationIterator.hasNext()) {
+			UriRef textAnnotation = (UriRef) textAnnotationIterator.next().getSubject();
+			textAnnotationCount++;
+		}
+		return textAnnotationCount;
+	}
+}

Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngineTest.java?rev=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngineTest.java (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/langid/impl/CeliLanguageIdentifierEnhancementEngineTest.java Mon May 14 21:07:19 2012
@@ -0,0 +1,115 @@
+package org.apache.stanbol.enhancer.engines.celi.langid.impl;
+
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDF_TYPE;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_ENTITYANNOTATION;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_TEXTANNOTATION;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.stanbol.enhancer.contentitem.inmemory.InMemoryContentItemFactory;
+import org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine;
+import org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl.CeliLemmatizerEnhancementEngine;
+import org.apache.stanbol.enhancer.engines.celi.ner.impl.CeliNamedEntityExtractionEnhancementEngine;
+import org.apache.stanbol.enhancer.engines.celi.test_utils.MockComponentContext;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
+import org.apache.stanbol.enhancer.servicesapi.EngineException;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
+import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
+import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.service.cm.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public class CeliLanguageIdentifierEnhancementEngineTest {
+	
+	static CeliLanguageIdentifierEnhancementEngine langIdentifier = new CeliLanguageIdentifierEnhancementEngine();
+
+    private static final ContentItemFactory ciFactory = InMemoryContentItemFactory.getInstance();
+
+    private static final Logger log = LoggerFactory.getLogger(CeliLanguageIdentifierEnhancementEngine.class);
+	
+	private static final String TEXT = "Brigitte Bardot, née  le 28 septembre 1934 à Paris, est une actrice de cinéma et chanteuse française.";
+
+	@BeforeClass
+	public static void setUpServices() throws IOException, ConfigurationException {
+		Dictionary<String, Object> properties = new Hashtable<String, Object>();
+		properties.put(EnhancementEngine.PROPERTY_NAME, "celiLangIdentifier");
+	    properties.put(CeliLanguageIdentifierEnhancementEngine.SERVICE_URL, "http://linguagrid.org/LSGrid/ws/language-identifier");
+	    
+		MockComponentContext context = new MockComponentContext(properties);
+		langIdentifier.activate(context);
+	}
+
+	@AfterClass
+	public static void shutdownServices() {
+		langIdentifier.deactivate(null);
+	}
+
+	public static ContentItem wrapAsContentItem(final String text) throws IOException {
+		return ciFactory.createContentItem(new StringSource(text));
+	}
+
+	@Test
+	public void tesetEngine() throws Exception {
+		ContentItem ci = wrapAsContentItem(TEXT);
+		try {
+			langIdentifier.computeEnhancements(ci);
+			int textAnnoNum = checkAllTextAnnotations(ci.getMetadata(), TEXT);
+	        log.info(textAnnoNum + " TextAnnotations found ...");
+	        int entityAnnoNum = checkAllEntityAnnotations(ci.getMetadata());
+	        log.info(entityAnnoNum + " EntityAnnotations found ...");
+		} catch (EngineException e) {
+			if (e.getCause() != null && e.getCause() instanceof UnknownHostException) {
+				log.warn("Celi Service not reachable -> offline? -> deactivate test");
+				return;
+			}
+			throw e;
+		}
+	}
+
+	private int checkAllEntityAnnotations(MGraph g) {
+		Iterator<Triple> entityAnnotationIterator = g.filter(null, RDF_TYPE, ENHANCER_ENTITYANNOTATION);
+		int entityAnnotationCount = 0;
+		while (entityAnnotationIterator.hasNext()) {
+			UriRef entityAnnotation = (UriRef) entityAnnotationIterator.next().getSubject();
+			entityAnnotationCount++;
+		}
+		return entityAnnotationCount;
+	}
+
+	private int checkAllTextAnnotations(MGraph g, String content) {
+		Iterator<Triple> textAnnotationIterator = g.filter(null, RDF_TYPE, ENHANCER_TEXTANNOTATION);
+		// test if a textAnnotation is present
+		assertTrue(textAnnotationIterator.hasNext());
+		int textAnnotationCount = 0;
+		while (textAnnotationIterator.hasNext()) {
+			UriRef textAnnotation = (UriRef) textAnnotationIterator.next().getSubject();
+			textAnnotationCount++;
+		}
+		return textAnnotationCount;
+	}
+
+	public static void addEnanchements(ContentItem ci) throws IOException, ConfigurationException, EngineException {
+		//Add guessed language
+		Dictionary<String, Object> properties = new Hashtable<String, Object>();
+		properties.put(EnhancementEngine.PROPERTY_NAME, "celiLangIdentifier");
+	    properties.put(CeliLanguageIdentifierEnhancementEngine.SERVICE_URL, "http://linguagrid.org/LSGrid/ws/language-identifier");
+	    MockComponentContext context = new MockComponentContext(properties);
+		CeliLanguageIdentifierEnhancementEngine langIdentifier=new CeliLanguageIdentifierEnhancementEngine();
+		langIdentifier.activate(context);
+		langIdentifier.computeEnhancements(ci);
+	}
+}

Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java?rev=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/lemmatizer/impl/CeliLemmatizerEnhancementEngineTest.java Mon May 14 21:07:19 2012
@@ -0,0 +1,104 @@
+package org.apache.stanbol.enhancer.engines.celi.lemmatizer.impl;
+
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.RDF_TYPE;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_ENTITYANNOTATION;
+import static org.apache.stanbol.enhancer.servicesapi.rdf.TechnicalClasses.ENHANCER_TEXTANNOTATION;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.clerezza.rdf.core.MGraph;
+import org.apache.clerezza.rdf.core.Triple;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.stanbol.enhancer.contentitem.inmemory.InMemoryContentItemFactory;
+import org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngineTest;
+import org.apache.stanbol.enhancer.engines.celi.test_utils.MockComponentContext;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
+import org.apache.stanbol.enhancer.servicesapi.EngineException;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
+import org.apache.stanbol.enhancer.servicesapi.helper.EnhancementEngineHelper;
+import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.service.cm.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CeliLemmatizerEnhancementEngineTest {
+	
+	static CeliLemmatizerEnhancementEngine morphoAnalysisEngine = new CeliLemmatizerEnhancementEngine();
+
+    private static final ContentItemFactory ciFactory = InMemoryContentItemFactory.getInstance();
+
+    private static final Logger log = LoggerFactory.getLogger(CeliLemmatizerEnhancementEngine.class);
+	private static final String TEXT = "Torino è la principale città del Piemonte.";
+
+	@BeforeClass
+	public static void setUpServices() throws IOException, ConfigurationException {
+		
+		Dictionary<String, Object> properties = new Hashtable<String, Object>();
+		properties.put(EnhancementEngine.PROPERTY_NAME, "celiLemmatizer");
+	    properties.put(CeliLemmatizerEnhancementEngine.SERVICE_URL, "http://linguagrid.org/LSGrid/ws/morpho-analyser");
+	    properties.put(CeliLemmatizerEnhancementEngine.MORPHOLOGICAL_ANALYSIS, Boolean.FALSE);
+		MockComponentContext context = new MockComponentContext(properties);
+		morphoAnalysisEngine.activate(context);
+	}
+
+	@AfterClass
+	public static void shutdownServices() {
+		morphoAnalysisEngine.deactivate(null);
+	}
+
+    public static ContentItem wrapAsContentItem(final String text) throws IOException {
+        return ciFactory.createContentItem(new StringSource(text));
+    }
+
+	@Test
+	public void tesetEngine() throws Exception {
+		ContentItem ci = wrapAsContentItem(TEXT);
+		
+		try {
+			CeliLanguageIdentifierEnhancementEngineTest.addEnanchements(ci);
+			
+			morphoAnalysisEngine.computeEnhancements(ci);
+			int textAnnoNum = checkAllTextAnnotations(ci.getMetadata(), TEXT);
+	        log.info(textAnnoNum + " TextAnnotations found ...");
+	        int entityAnnoNum = checkAllEntityAnnotations(ci.getMetadata());
+	        log.info(entityAnnoNum + " EntityAnnotations found ...");
+		} catch (EngineException e) {
+			if (e.getCause() != null && e.getCause() instanceof UnknownHostException) {
+				log.warn("Celi Service not reachable -> offline? -> deactivate test");
+				return;
+			}
+			throw e;
+		}
+	}
+
+	private int checkAllEntityAnnotations(MGraph g) {
+		Iterator<Triple> entityAnnotationIterator = g.filter(null, RDF_TYPE, ENHANCER_ENTITYANNOTATION);
+		int entityAnnotationCount = 0;
+		while (entityAnnotationIterator.hasNext()) {
+			UriRef entityAnnotation = (UriRef) entityAnnotationIterator.next().getSubject();
+			entityAnnotationCount++;
+		}
+		return entityAnnotationCount;
+	}
+
+	private int checkAllTextAnnotations(MGraph g, String content) {
+		Iterator<Triple> textAnnotationIterator = g.filter(null, RDF_TYPE, ENHANCER_TEXTANNOTATION);
+		// test if a textAnnotation is present
+		assertTrue(textAnnotationIterator.hasNext());
+		int textAnnotationCount = 0;
+		while (textAnnotationIterator.hasNext()) {
+			UriRef textAnnotation = (UriRef) textAnnotationIterator.next().getSubject();
+			textAnnotationCount++;
+		}
+		return textAnnotationCount;
+	}
+}

Added: 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=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngineTest.java (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/ner/impl/CeliNamedEntityExtractionEnhancementEngineTest.java Mon May 14 21:07:19 2012
@@ -0,0 +1,115 @@
+package org.apache.stanbol.enhancer.engines.celi.ner.impl;
+
+import static org.apache.stanbol.enhancer.servicesapi.rdf.Properties.DC_LANGUAGE;
+import static org.apache.stanbol.enhancer.test.helper.EnhancementStructureHelper.validateAllTextAnnotations;
+
+import java.io.IOException;
+import java.net.UnknownHostException;
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+
+import org.apache.clerezza.rdf.core.LiteralFactory;
+import org.apache.clerezza.rdf.core.Resource;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.impl.PlainLiteralImpl;
+import org.apache.clerezza.rdf.core.impl.TripleImpl;
+import org.apache.stanbol.enhancer.contentitem.inmemory.InMemoryContentItemFactory;
+import org.apache.stanbol.enhancer.engines.celi.classification.impl.CeliClassificationEnhancementEngine;
+import org.apache.stanbol.enhancer.engines.celi.langid.impl.CeliLanguageIdentifierEnhancementEngineTest;
+import org.apache.stanbol.enhancer.engines.celi.ner.impl.CeliNamedEntityExtractionEnhancementEngine;
+import org.apache.stanbol.enhancer.engines.celi.test_utils.MockComponentContext;
+import org.apache.stanbol.enhancer.servicesapi.ContentItem;
+import org.apache.stanbol.enhancer.servicesapi.ContentItemFactory;
+import org.apache.stanbol.enhancer.servicesapi.EngineException;
+import org.apache.stanbol.enhancer.servicesapi.EnhancementEngine;
+import org.apache.stanbol.enhancer.servicesapi.impl.StringSource;
+import org.apache.stanbol.enhancer.servicesapi.rdf.Properties;
+import org.apache.stanbol.enhancer.test.helper.EnhancementStructureHelper;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.service.cm.ConfigurationException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CeliNamedEntityExtractionEnhancementEngineTest {
+
+	static CeliNamedEntityExtractionEnhancementEngine nerEngine = new CeliNamedEntityExtractionEnhancementEngine();
+
+	private static final Logger log = LoggerFactory.getLogger(CeliClassificationEnhancementEngine.class);
+	
+    private static final ContentItemFactory ciFactory = InMemoryContentItemFactory.getInstance();
+
+    private static final String TEXT = "Brigitte Bardot, née  le 28 septembre 1934 à Paris, est une actrice de cinéma et chanteuse française.";
+
+	@BeforeClass
+	public static void setUpServices() throws IOException, ConfigurationException {
+		Dictionary<String, Object> properties = new Hashtable<String, Object>();
+		properties.put(EnhancementEngine.PROPERTY_NAME, "celiNer");
+	    properties.put(CeliNamedEntityExtractionEnhancementEngine.SERVICE_URL, "http://linguagrid.org/LSGrid/ws/com.celi-france.linguagrid.namedentityrecognition.v0u0.demo");
+	    properties.put(CeliNamedEntityExtractionEnhancementEngine.SUPPORTED_LANGUAGES, "fr");
+	    MockComponentContext context = new MockComponentContext(properties);
+		nerEngine.activate(context);
+	}
+
+	@AfterClass
+	public static void shutdownServices() {
+		nerEngine.deactivate(null);
+	}
+
+    public static ContentItem wrapAsContentItem(final String text) throws IOException {
+        return ciFactory.createContentItem(new StringSource(text));
+    }
+
+	@Test
+	public void tesetEngine() throws Exception {
+		ContentItem ci = wrapAsContentItem(TEXT);
+		try {
+		    //add a simple triple to statically define the language of the test
+		    //content
+		    ci.getMetadata().add(new TripleImpl(ci.getUri(), DC_LANGUAGE, new PlainLiteralImpl("fr")));
+		    //unit test should not depend on each other (if possible)
+			//CeliLanguageIdentifierEnhancementEngineTest.addEnanchements(ci);
+			
+			nerEngine.computeEnhancements(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(
+			    nerEngine.getClass().getName()));
+			int textAnnoNum = validateAllTextAnnotations(ci.getMetadata(), TEXT, expectedValues);
+	        log.info(textAnnoNum + " TextAnnotations found ...");
+	        int entityAnnoNum = EnhancementStructureHelper.validateAllEntityAnnotations(ci.getMetadata(),expectedValues);
+	        log.info(entityAnnoNum + " EntityAnnotations found ...");
+		} catch (EngineException e) {
+			if (e.getCause() != null && e.getCause() instanceof UnknownHostException) {
+				log.warn("Celi Service not reachable -> offliCeliNamedEntityExtractionEnhancementEnginene? -> deactivate test");
+				return;
+			}
+			throw e;
+		}
+	}
+
+//	private int checkAllEntityAnnotations(MGraph g) {
+//		Iterator<Triple> entityAnnotationIterator = g.filter(null, RDF_TYPE, ENHANCER_ENTITYANNOTATION);
+//		int entityAnnotationCount = 0;
+//		while (entityAnnotationIterator.hasNext()) {
+//			UriRef entityAnnotation = (UriRef) entityAnnotationIterator.next().getSubject();
+//			entityAnnotationCount++;
+//		}
+//		return entityAnnotationCount;
+//	}
+//
+//	private int checkAllTextAnnotations(MGraph g, String content) {
+//		Iterator<Triple> textAnnotationIterator = g.filter(null, RDF_TYPE, ENHANCER_TEXTANNOTATION);
+//		// test if a textAnnotation is present
+//		assertTrue(textAnnotationIterator.hasNext());
+//		int textAnnotationCount = 0;
+//		while (textAnnotationIterator.hasNext()) {
+//			UriRef textAnnotation = (UriRef) textAnnotationIterator.next().getSubject();
+//			textAnnotationCount++;
+//		}
+//		return textAnnotationCount;
+//	}
+
+}

Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/test_utils/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/test_utils/MockComponentContext.java?rev=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/test_utils/MockComponentContext.java (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/java/org/apache/stanbol/enhancer/engines/celi/test_utils/MockComponentContext.java Mon May 14 21:07:19 2012
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.stanbol.enhancer.engines.celi.test_utils;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.component.ComponentContext;
+import org.osgi.service.component.ComponentInstance;
+
+public class MockComponentContext implements ComponentContext {
+
+    protected final Dictionary<String, Object> properties;
+
+    public MockComponentContext() {
+        properties = new Hashtable<String, Object>();
+    }
+
+    public MockComponentContext(Dictionary<String, Object> properties) {
+        this.properties = properties;
+    }
+
+    public void disableComponent(String name) {
+    }
+
+    public void enableComponent(String name) {
+    }
+
+    public BundleContext getBundleContext() {
+        return null;
+    }
+
+    public ComponentInstance getComponentInstance() {
+        return null;
+    }
+
+    public Dictionary<String, Object> getProperties() {
+        return properties;
+    }
+
+    public ServiceReference getServiceReference() {
+        return null;
+    }
+
+    public Bundle getUsingBundle() {
+        return null;
+    }
+
+    public Object locateService(String name) {
+        return null;
+    }
+
+    public Object locateService(String name, ServiceReference reference) {
+        return null;
+    }
+
+    public Object[] locateServices(String name) {
+        return null;
+    }
+
+}

Added: incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/resources/log4j.properties?rev=1338425&view=auto
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/resources/log4j.properties (added)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/celi/src/test/resources/log4j.properties Mon May 14 21:07:19 2012
@@ -0,0 +1,40 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+log4j.rootLogger=DEBUG, CONSOLE
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%C{1}] %m%n
+
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+log4j.rootLogger=DEBUG, CONSOLE
+log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
+log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
+log4j.appender.CONSOLE.layout.ConversionPattern=%d{HH:mm:ss,SSS} %-5p [%C{1}] %m%n
+

Modified: incubator/stanbol/branches/celi-enhancement-engines/engines/pom.xml
URL: http://svn.apache.org/viewvc/incubator/stanbol/branches/celi-enhancement-engines/engines/pom.xml?rev=1338425&r1=1338424&r2=1338425&view=diff
==============================================================================
--- incubator/stanbol/branches/celi-enhancement-engines/engines/pom.xml (original)
+++ incubator/stanbol/branches/celi-enhancement-engines/engines/pom.xml Mon May 14 21:07:19 2012
@@ -54,5 +54,6 @@
 
     <module>opencalais</module>
     <module>zemanta</module>
+    <module>celi</module>
   </modules>
 </project>