Author: tommaso
Date: Thu May 26 08:55:40 2011
New Revision: 1127832

URL: http://svn.apache.org/viewvc?rev=1127832&view=rev
Log:
[CLEREZZA-555] - added a service for remote concept tagging (and storing the 
graph) with HTTP GET

Added:
    
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMARemoteResourceTaggerService.java
    
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/AggregateResourceTaggerAE.xml
    
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/ClerezzaCASConsumerDescriptor.xml
    
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/UrlConceptTaggingAEDescriptor.xml
Modified:
    incubator/clerezza/trunk/parent/uima/uima.concept-tagging/   (props changed)
    incubator/clerezza/trunk/parent/uima/uima.concept-tagging/pom.xml
    
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMAResourceTagger.java

Propchange: incubator/clerezza/trunk/parent/uima/uima.concept-tagging/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Thu May 26 08:55:40 2011
@@ -1,3 +1 @@
 target
-*.iml
-

Modified: incubator/clerezza/trunk/parent/uima/uima.concept-tagging/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.concept-tagging/pom.xml?rev=1127832&r1=1127831&r2=1127832&view=diff
==============================================================================
--- incubator/clerezza/trunk/parent/uima/uima.concept-tagging/pom.xml (original)
+++ incubator/clerezza/trunk/parent/uima/uima.concept-tagging/pom.xml Thu May 
26 08:55:40 2011
@@ -23,6 +23,12 @@
       <version>0.1-incubating-SNAPSHOT</version>
     </dependency>
     <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>uima.casconsumer</artifactId>
+      <version>0.1-incubating-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
       <groupId>org.apache.uima</groupId>
       <artifactId>uimaj-ep-runtime</artifactId>
     </dependency>
@@ -30,15 +36,11 @@
       <groupId>org.apache.uima</groupId>
       <artifactId>alchemy-annotator-osgi</artifactId>
       <version>2.3.1-SNAPSHOT</version>
-      <scope>system</scope>
-      
<systemPath>${project.basedir}/../uima.utils/lib/org.apache.uima.alchemyapi_2.3.1.SNAPSHOT.jar</systemPath>
     </dependency>
     <dependency>
       <groupId>org.apache.uima</groupId>
       <artifactId>OpenCalaisAnnotator-osgi</artifactId>
       <version>2.3.1-SNAPSHOT</version>
-      <scope>system</scope>
-      
<systemPath>${project.basedir}/../uima.utils/lib/org.apache.uima.opencalais_2.3.1.SNAPSHOT.jar</systemPath>
     </dependency>
   </dependencies>
 </project>

Added: 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMARemoteResourceTaggerService.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMARemoteResourceTaggerService.java?rev=1127832&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMARemoteResourceTaggerService.java
 (added)
+++ 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMARemoteResourceTaggerService.java
 Thu May 26 08:55:40 2011
@@ -0,0 +1,60 @@
+package org.apache.clerezza.uima.concept;
+
+import org.apache.clerezza.rdf.core.Graph;
+import org.apache.clerezza.rdf.core.UriRef;
+import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.uima.utils.UIMAExecutor;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * REST service for concept tagging which accepts 'uri' parameter to tag 
concepts and create the graph for that resource
+ */
+
+@Component
+@Service(Object.class)
+@Property(name = "javax.ws.rs", boolValue = true)
+@Path("/resourcetagger")
+public class UIMARemoteResourceTaggerService {
+
+  private static final String PATH = "/AggregateResourceTaggerAE.xml";
+
+  @GET
+  @Path("tag")
+  @Produces("application/rdf+xml")
+  public Graph tagUri(@QueryParam("uri") String uri, @QueryParam("key") String 
key) {
+
+    if (uri == null || uri.length() == 0)
+      throw new WebApplicationException(Response.status(
+              Response.Status.BAD_REQUEST).entity(new StringBuilder("No URI 
specified").toString()).build());
+
+    try {
+      System.err.println(new File(PATH).toURI().toURL());
+    } catch (MalformedURLException e) {
+      e.printStackTrace();
+    }
+    UIMAExecutor executor = new UIMAExecutor(PATH).withResults();
+    Map<String, Object> parameters = new HashMap<String, Object>();
+    parameters.put("outputgraph",uri);
+    parameters.put("alchemykey", key);
+    try {
+      executor.analyzeDocument("/AggregateResourceTaggerAE.xml", uri, 
parameters);
+    } catch (AnalysisEngineProcessException e) {
+      e.printStackTrace();
+      throw new WebApplicationException(Response.status(
+              Response.Status.INTERNAL_SERVER_ERROR).entity(new 
StringBuilder("Failed UIMA execution on URI ").
+              append(uri).append(" due to 
\n").append(e.getLocalizedMessage()).toString()).build());
+    }
+    return TcManager.getInstance().getMGraph(new UriRef(uri)).getGraph();
+  }
+
+}

Modified: 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMAResourceTagger.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMAResourceTagger.java?rev=1127832&r1=1127831&r2=1127832&view=diff
==============================================================================
--- 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMAResourceTagger.java
 (original)
+++ 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/java/org/apache/clerezza/uima/concept/UIMAResourceTagger.java
 Thu May 26 08:55:40 2011
@@ -58,7 +58,6 @@ public class UIMAResourceTagger extends 
 
   @Override
   protected void activate(ComponentContext context) throws URISyntaxException {
-    super.activate(context);
     uimaServicesFacade = new ExternalServicesFacade();
   }
 

Added: 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/AggregateResourceTaggerAE.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/AggregateResourceTaggerAE.xml?rev=1127832&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/AggregateResourceTaggerAE.xml
 (added)
+++ 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/AggregateResourceTaggerAE.xml
 Thu May 26 08:55:40 2011
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier";>
+  <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+  <primitive>false</primitive>
+  <delegateAnalysisEngineSpecifiers>
+    <delegateAnalysisEngine key="TextConceptTaggingAEDescriptor">
+      <import location="TextConceptTaggingAEDescriptor.xml"/>
+    </delegateAnalysisEngine>
+    <delegateAnalysisEngine key="ClerezzaCASConsumerDescriptor">
+      <import location="ClerezzaCASConsumerDescriptor.xml"/>
+    </delegateAnalysisEngine>
+  </delegateAnalysisEngineSpecifiers>
+  <analysisEngineMetaData>
+    <name>ExtServicesAE</name>
+    <description/>
+    <version>1.0</version>
+    <vendor/>
+     <configurationParameters>
+      <configurationParameter>
+        <name>outputgraph</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+        <overrides>
+          <parameter>ClerezzaCASConsumerDescriptor/graphName</parameter>
+        </overrides>
+      </configurationParameter>
+      <configurationParameter>
+        <name>alchemykey</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+        <overrides>
+          <parameter>TextConceptTaggingAEDescriptor/apikey</parameter>
+        </overrides>
+      </configurationParameter>
+    </configurationParameters>
+    <configurationParameterSettings/>
+    <flowConstraints>
+      <fixedFlow>
+        <node>TextConceptTaggingAEDescriptor</node>
+        <node>ClerezzaCASConsumerDescriptor</node>
+      </fixedFlow>
+    </flowConstraints>
+    <fsIndexCollection/>
+    <capabilities>
+      <capability>
+        <inputs/>
+        <outputs/>
+        <languagesSupported/>
+      </capability>
+    </capabilities>
+    <operationalProperties>
+      <modifiesCas>true</modifiesCas>
+      <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+      <outputsNewCASes>false</outputsNewCASes>
+    </operationalProperties>
+  </analysisEngineMetaData>
+  <resourceManagerConfiguration/>
+</analysisEngineDescription>

Added: 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/ClerezzaCASConsumerDescriptor.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/ClerezzaCASConsumerDescriptor.xml?rev=1127832&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/ClerezzaCASConsumerDescriptor.xml
 (added)
+++ 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/ClerezzaCASConsumerDescriptor.xml
 Thu May 26 08:55:40 2011
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier";>
+  <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+  <primitive>true</primitive>
+  
<annotatorImplementationName>org.apache.clerezza.uima.casconsumer.ClerezzaCASConsumer</annotatorImplementationName>
+  <analysisEngineMetaData>
+    <name>ClerezzaCASConsumerDescriptor</name>
+    <description>CAS Consumer to produce Clerezza graphs</description>
+    <version>1.0</version>
+    <vendor/>
+    <configurationParameters>
+      <configurationParameter>
+        <name>graphName</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>casModelFile</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+    </configurationParameters>
+    <configurationParameterSettings>
+      <nameValuePair>
+        <name>graphName</name>
+        <value>
+          <string></string>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>casModelFile</name>
+        <value>
+          <string></string>
+        </value>
+      </nameValuePair>
+    </configurationParameterSettings>
+    <typeSystemDescription>
+      <types>
+      </types>
+    </typeSystemDescription>
+    <typePriorities/>
+    <fsIndexCollection/>
+    <capabilities>
+      <capability>
+        <inputs/>
+        <outputs/>
+        <languagesSupported/>
+      </capability>
+    </capabilities>
+    <operationalProperties>
+      <modifiesCas>true</modifiesCas>
+      <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+      <outputsNewCASes>false</outputsNewCASes>
+    </operationalProperties>
+  </analysisEngineMetaData>
+  <resourceManagerConfiguration/>
+</analysisEngineDescription>

Added: 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/UrlConceptTaggingAEDescriptor.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/UrlConceptTaggingAEDescriptor.xml?rev=1127832&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/UrlConceptTaggingAEDescriptor.xml
 (added)
+++ 
incubator/clerezza/trunk/parent/uima/uima.concept-tagging/src/main/resources/UrlConceptTaggingAEDescriptor.xml
 Thu May 26 08:55:40 2011
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   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.    
+-->
+<analysisEngineDescription xmlns="http://uima.apache.org/resourceSpecifier";>
+  <frameworkImplementation>org.apache.uima.java</frameworkImplementation>
+  <primitive>true</primitive>
+  
<annotatorImplementationName>org.apache.uima.alchemy.annotator.URLConceptTaggingAnnotator</annotatorImplementationName>
+  <analysisEngineMetaData>
+    <name>UrlConceptTaggingAEDescriptor</name>
+    <description/>
+    <version>1.0</version>
+    <vendor/>
+    <configurationParameters>
+      <configurationParameter>
+        <name>apikey</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>outputMode</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>linkedData</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>false</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>showSourceText</name>
+        <type>Integer</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>maxRetrieve</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>false</mandatory>
+      </configurationParameter>
+      <configurationParameter>
+        <name>url</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>false</mandatory>
+      </configurationParameter>
+    </configurationParameters>
+    <configurationParameterSettings>
+      <nameValuePair>
+        <name>apikey</name>
+        <value>
+          <string/>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>outputMode</name>
+        <value>
+          <string>xml</string>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>linkedData</name>
+        <value>
+          <string>1</string>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>showSourceText</name>
+        <value>
+          <integer>0</integer>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>maxRetrieve</name>
+        <value>
+          <string>8</string>
+        </value>
+      </nameValuePair>
+    </configurationParameterSettings>
+    <typeSystemDescription>
+      <types>
+        <typeDescription>
+          <name>org.apache.uima.alchemy.ts.concept.ConceptFS</name>
+          <description>a concept tag</description>
+          <supertypeName>uima.cas.TOP</supertypeName>
+          <features>
+            <featureDescription>
+              <name>text</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>relevance</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>website</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>geo</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>dbpedia</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>yago</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>opencyc</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>freebase</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>ciaFactbook</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>census</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>geonames</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>musicBrainz</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>crunchbase</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+            <featureDescription>
+              <name>semanticCrunchbase</name>
+              <description/>
+              <rangeTypeName>uima.cas.String</rangeTypeName>
+            </featureDescription>
+          </features>
+        </typeDescription>
+      </types>
+    </typeSystemDescription>
+    <typePriorities/>
+    <fsIndexCollection/>
+    <capabilities>
+      <capability>
+        <inputs/>
+        <outputs/>
+        <languagesSupported/>
+      </capability>
+    </capabilities>
+    <operationalProperties>
+      <modifiesCas>true</modifiesCas>
+      <multipleDeploymentAllowed>true</multipleDeploymentAllowed>
+      <outputsNewCASes>false</outputsNewCASes>
+    </operationalProperties>
+  </analysisEngineMetaData>
+  <resourceManagerConfiguration/>
+</analysisEngineDescription>


Reply via email to