Author: tommaso
Date: Mon Nov  7 23:10:50 2011
New Revision: 1198997

URL: http://svn.apache.org/viewvc?rev=1198997&view=rev
Log:
[CLEREZZA-650] - initial import of uima.samples code

Added:
    incubator/clerezza/trunk/parent/uima/uima.samples/   (with props)
    incubator/clerezza/trunk/parent/uima/uima.samples/pom.xml
    incubator/clerezza/trunk/parent/uima/uima.samples/src/
    incubator/clerezza/trunk/parent/uima/uima.samples/src/main/
    incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/
    incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/
    incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/
    
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/
    
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/
    
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/
    
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/RegExAnnotatorAOService.java
    
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/UIMASamplesBundleActivator.java
    incubator/clerezza/trunk/parent/uima/uima.samples/src/main/resources/
    
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/resources/META-INF/
    
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/resources/META-INF/AggregateRegExAOAE.xml
    incubator/clerezza/trunk/parent/uima/uima.samples/src/test/
    incubator/clerezza/trunk/parent/uima/uima.samples/src/test/java/
    incubator/clerezza/trunk/parent/uima/uima.samples/src/test/resources/

Propchange: incubator/clerezza/trunk/parent/uima/uima.samples/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Nov  7 23:10:50 2011
@@ -0,0 +1 @@
+*.iml

Added: incubator/clerezza/trunk/parent/uima/uima.samples/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.samples/pom.xml?rev=1198997&view=auto
==============================================================================
--- incubator/clerezza/trunk/parent/uima/uima.samples/pom.xml (added)
+++ incubator/clerezza/trunk/parent/uima/uima.samples/pom.xml Mon Nov  7 
23:10:50 2011
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.apache.clerezza</groupId>
+  <artifactId>uima.samples</artifactId>
+  <version>0.1-incubating-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <name>Clerezza - Apache UIMA integration samples</name>
+  <parent>
+    <groupId>org.apache.clerezza</groupId>
+    <artifactId>uima</artifactId>
+    <version>0.1-incubating-SNAPSHOT</version>
+  </parent>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>uima.utils</artifactId>
+      <version>0.1-incubating-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>triaxrs</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.clerezza</groupId>
+      <artifactId>uima.casconsumer</artifactId>
+      <version>0.1-incubating-SNAPSHOT</version>
+      <scope>runtime</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <version>2.0.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.uima</groupId>
+      <artifactId>RegularExpressionAnnotator</artifactId>
+      <version>2.3.1</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Import-Package>
+              
javax.ws.rs.*;javax.xml.stream.*;org.osgi.service.component.*;org.apache.uima.*;org.apache.clerezza.*;org.apache.commons.io.*
+            </Import-Package>
+            <Export-Package>org.apache.clerezza.uima.samples.*</Export-Package>
+            
<Bundle-Activator>org.apache.clerezza.uima.samples.UIMASamplesBundleActivator</Bundle-Activator>
+          </instructions>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/RegExAnnotatorAOService.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/RegExAnnotatorAOService.java?rev=1198997&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/RegExAnnotatorAOService.java
 (added)
+++ 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/RegExAnnotatorAOService.java
 Mon Nov  7 23:10:50 2011
@@ -0,0 +1,77 @@
+/*
+ * 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.clerezza.uima.samples;
+
+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.clerezza.uima.utils.UIMAExecutorFactory;
+import org.apache.commons.io.IOUtils;
+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.util.XMLInputSource;
+
+import javax.ws.rs.*;
+import javax.ws.rs.core.Response;
+import java.net.URI;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Sample REST service which uses {@link 
org.apache.uima.annotator.regex.impl.RegExAnnotator} to extract named entities
+ * from the text of a given URI
+ */
+@Component
+@Service(Object.class)
+@Property(name = "javax.ws.rs", boolValue = true)
+@Path("/uima")
+public class RegExAnnotatorAOService {
+
+  private static final String PATH = "/META-INF/AggregateRegExAOAE.xml";
+  private static final String OUTPUTGRAPH = "outputgraph";
+
+  @POST
+  @Path("regex")
+  @Produces("application/rdf+xml")
+  public Graph tagUri(@QueryParam("uri") String uriString) {
+    if (uriString == null || uriString.length() == 0)
+      throw new WebApplicationException(Response.status(
+              Response.Status.BAD_REQUEST).entity(new StringBuilder("No URI 
specified").toString()).build());
+
+    UIMAExecutor executor = 
UIMAExecutorFactory.getInstance().createUIMAExecutor();
+    Map<String, Object> parameters = new HashMap<String, Object>();
+    parameters.put(OUTPUTGRAPH, uriString);
+    try {
+      URL url = URI.create(uriString).toURL();
+      String text = IOUtils.toString(url.openStream());
+      executor.analyzeDocument(text, new 
XMLInputSource(getClass().getResource(PATH)), parameters);
+    } catch (Exception e) {
+      throw new WebApplicationException(Response.status(
+              Response.Status.INTERNAL_SERVER_ERROR).entity(new 
StringBuilder("Failed UIMA execution on URI ").
+              append(uriString).append(" due to 
\n").append(e.getLocalizedMessage()).toString()).build());
+    }
+    return TcManager.getInstance().getMGraph(new UriRef(uriString)).getGraph();
+  }
+
+
+}
+

Added: 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/UIMASamplesBundleActivator.java
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/UIMASamplesBundleActivator.java?rev=1198997&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/UIMASamplesBundleActivator.java
 (added)
+++ 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/java/org/apache/clerezza/uima/samples/UIMASamplesBundleActivator.java
 Mon Nov  7 23:10:50 2011
@@ -0,0 +1,33 @@
+/*
+ * 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.clerezza.uima.samples;
+
+import org.apache.clerezza.uima.utils.UIMABundleActivator;
+import 
org.apache.clerezza.uima.utils.cl.AnalysisComponentsClassLoaderRepository;
+import org.apache.uima.annotator.regex.impl.RegExAnnotator;
+
+/**
+ * {@link org.osgi.framework.BundleActivator} for uima.samples module
+ */
+public class UIMASamplesBundleActivator extends UIMABundleActivator {
+  @Override
+  protected void classRegistered() {
+    
AnalysisComponentsClassLoaderRepository.registerComponent(RegExAnnotator.class);
+  }
+}

Added: 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/resources/META-INF/AggregateRegExAOAE.xml
URL: 
http://svn.apache.org/viewvc/incubator/clerezza/trunk/parent/uima/uima.samples/src/main/resources/META-INF/AggregateRegExAOAE.xml?rev=1198997&view=auto
==============================================================================
--- 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/resources/META-INF/AggregateRegExAOAE.xml
 (added)
+++ 
incubator/clerezza/trunk/parent/uima/uima.samples/src/main/resources/META-INF/AggregateRegExAOAE.xml
 Mon Nov  7 23:10:50 2011
@@ -0,0 +1,104 @@
+<?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>false</primitive>
+  <delegateAnalysisEngineSpecifiers>
+    <delegateAnalysisEngine key="RegExAnnotator">
+      <import name="RegExAnnotator"/>
+    </delegateAnalysisEngine>
+    <delegateAnalysisEngine key="ClerezzaCASConsumerDescriptor">
+      <import name="ClerezzaCASConsumerDescriptor"/>
+    </delegateAnalysisEngine>
+  </delegateAnalysisEngineSpecifiers>
+  <analysisEngineMetaData>
+    <name>AggregateRegExAOAE.xml</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>strategy</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+        <overrides>
+          <parameter>ClerezzaCASConsumerDescriptor/mappingStrategy</parameter>
+        </overrides>
+      </configurationParameter>
+      <configurationParameter>
+        <name>alchemykey</name>
+        <type>String</type>
+        <multiValued>false</multiValued>
+        <mandatory>true</mandatory>
+        <overrides>
+          <parameter>UrlConceptTaggingAEDescriptor/apikey</parameter>
+        </overrides>
+      </configurationParameter>
+    </configurationParameters>
+    <configurationParameterSettings>
+      <nameValuePair>
+        <name>outputgraph</name>
+        <value>
+          <string></string>
+        </value>
+      </nameValuePair>
+      <nameValuePair>
+        <name>strategy</name>
+        <value>
+          <string>ao</string>
+        </value>
+      </nameValuePair>
+    </configurationParameterSettings>
+    >
+    <flowConstraints>
+      <fixedFlow>
+        <node>UrlConceptTaggingAEDescriptor</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>


Reply via email to