From e96d323723e8bc5e1e04cee8458eaed362daad1b Mon Sep 17 00:00:00 2001 From: Robert Muir Date: Tue, 22 Mar 2011 01:01:26 +0000 Subject: [PATCH] SOLR-2387: stabilize UIMA tests, so they use mock objects instead of remote calls git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1084045 13f79535-47bb-0310-9956-ffa450edef68 --- solr/contrib/uima/CHANGES.txt | 11 + .../uima/processor/SolrUIMAConfiguration.java | 6 +- .../SolrUIMAConfigurationReader.java | 6 +- .../uima/processor/ae/AEProviderFactory.java | 2 +- .../ae/OverridingParamsAEProvider.java | 36 +++- .../UIMAUpdateRequestProcessorTest.java | 25 +-- .../processor/an/DummyEntityAnnotator.java | 42 ++++ .../processor/an/DummySentimentAnnotator.java | 61 ++++++ .../apache/solr/uima/ts/EntityAnnotation.java | 62 ++++++ .../solr/uima/ts/EntityAnnotation_Type.java | 55 +++++ .../solr/uima/ts/SentimentAnnotation.java | 80 ++++++++ .../uima/ts/SentimentAnnotation_Type.java | 79 +++++++ .../test/resources/AggregateSentenceAE.xml | 26 ++- .../resources/DummyEntityAEDescriptor.xml | 56 +++++ .../DummySentimentAnalysisAEDescriptor.xml | 60 ++++++ .../test/resources/OpenCalaisAnnotator.xml | 194 ------------------ .../uima/src/test/resources/TestAE.xml | 116 ++--------- .../TextCategorizationAEDescriptor.xml | 102 --------- .../test/resources/solr-uima/conf/schema.xml | 6 +- .../resources/solr-uima/conf/solrconfig.xml | 33 +-- 20 files changed, 596 insertions(+), 462 deletions(-) create mode 100644 solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/an/DummyEntityAnnotator.java create mode 100644 solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/an/DummySentimentAnnotator.java create mode 100644 solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/EntityAnnotation.java create mode 100644 solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/EntityAnnotation_Type.java create mode 100644 solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/SentimentAnnotation.java create mode 100644 solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/SentimentAnnotation_Type.java create mode 100644 solr/contrib/uima/src/test/resources/DummyEntityAEDescriptor.xml create mode 100644 solr/contrib/uima/src/test/resources/DummySentimentAnalysisAEDescriptor.xml delete mode 100644 solr/contrib/uima/src/test/resources/OpenCalaisAnnotator.xml delete mode 100644 solr/contrib/uima/src/test/resources/TextCategorizationAEDescriptor.xml diff --git a/solr/contrib/uima/CHANGES.txt b/solr/contrib/uima/CHANGES.txt index cf4bc6cfa56..8b588c97cd7 100644 --- a/solr/contrib/uima/CHANGES.txt +++ b/solr/contrib/uima/CHANGES.txt @@ -18,3 +18,14 @@ AlchemyAPIAnnotator v2.3.1-SNAPSHOT rev. 1062868 WhitespaceTokenizer v2.3.1-SNAPSHOT rev. 1076132 $Id$ + +================== 3.2.0-dev ================== + +Test Cases: + + * SOLR-2387: add mock annotators for improved testing, + (Tommaso Teofili via rmuir) + +================== 3.1.0-dev ================== + +Initial Release diff --git a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/SolrUIMAConfiguration.java b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/SolrUIMAConfiguration.java index 2ba2d7f4fc5..62c145c5dc0 100644 --- a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/SolrUIMAConfiguration.java +++ b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/SolrUIMAConfiguration.java @@ -34,11 +34,11 @@ public class SolrUIMAConfiguration { private String aePath; - private Map runtimeParameters; + private Map runtimeParameters; public SolrUIMAConfiguration(String aePath, String[] fieldsToAnalyze, boolean fieldsMerging, Map> typesFeaturesFieldsMapping, - Map runtimeParameters) { + Map runtimeParameters) { this.aePath = aePath; this.fieldsToAnalyze = fieldsToAnalyze; this.fieldsMerging = fieldsMerging; @@ -62,7 +62,7 @@ public class SolrUIMAConfiguration { return aePath; } - public Map getRuntimeParameters() { + public Map getRuntimeParameters() { return runtimeParameters; } diff --git a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/SolrUIMAConfigurationReader.java b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/SolrUIMAConfigurationReader.java index 4ffeb83fa56..3f2b01d7328 100644 --- a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/SolrUIMAConfigurationReader.java +++ b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/SolrUIMAConfigurationReader.java @@ -105,15 +105,15 @@ public class SolrUIMAConfigurationReader { return map; } - private Map readAEOverridingParameters() { - Map runtimeParameters = new HashMap(); + private Map readAEOverridingParameters() { + Map runtimeParameters = new HashMap(); Node uimaConfigNode = solrConfig.getNode(AE_RUNTIME_PARAMETERS_NODE_PATH, true); if (uimaConfigNode.hasChildNodes()) { NodeList overridingNodes = uimaConfigNode.getChildNodes(); for (int i = 0; i < overridingNodes.getLength(); i++) { Node overridingNode = overridingNodes.item(i); - if (overridingNode.getNodeType() != Node.TEXT_NODE) { + if (overridingNode.getNodeType() != Node.TEXT_NODE && overridingNode.getNodeType() != Node.COMMENT_NODE) { runtimeParameters.put(overridingNode.getNodeName(), overridingNode.getTextContent()); } } diff --git a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/ae/AEProviderFactory.java b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/ae/AEProviderFactory.java index 2104e753353..bc5ad81367e 100644 --- a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/ae/AEProviderFactory.java +++ b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/ae/AEProviderFactory.java @@ -43,7 +43,7 @@ public class AEProviderFactory { } public synchronized AEProvider getAEProvider(String core, String aePath, - Map runtimeParameters) { + Map runtimeParameters) { String key = new StringBuilder(core).append(aePath).toString(); if (providerCache.get(key) == null) { providerCache.put(key, new OverridingParamsAEProvider(aePath, runtimeParameters)); diff --git a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/ae/OverridingParamsAEProvider.java b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/ae/OverridingParamsAEProvider.java index d4d74910379..586c0cd9aab 100644 --- a/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/ae/OverridingParamsAEProvider.java +++ b/solr/contrib/uima/src/main/java/org/apache/solr/uima/processor/ae/OverridingParamsAEProvider.java @@ -43,9 +43,9 @@ public class OverridingParamsAEProvider implements AEProvider { private AnalysisEngine cachedAE; - private Map runtimeParameters; + private Map runtimeParameters; - public OverridingParamsAEProvider(String aeFilePath, Map runtimeParameters) { + public OverridingParamsAEProvider(String aeFilePath, Map runtimeParameters) { this.aeFilePath = aeFilePath; this.runtimeParameters = runtimeParameters; } @@ -63,9 +63,11 @@ public class OverridingParamsAEProvider implements AEProvider { /* iterate over each AE (to set runtime parameters) */ for (String attributeName : runtimeParameters.keySet()) { + Object val = getRuntimeValue(desc, attributeName); desc.getAnalysisEngineMetaData().getConfigurationParameterSettings().setParameterValue( - attributeName, runtimeParameters.get(attributeName)); - log.info(new StringBuilder("setting ").append(attributeName).append(" : ").append( + attributeName, val); + if (log.isDebugEnabled()) + log.debug(new StringBuilder("setting ").append(attributeName).append(" : ").append( runtimeParameters.get(attributeName)).toString()); } // create AE here @@ -86,4 +88,30 @@ public class OverridingParamsAEProvider implements AEProvider { return cachedAE; } + /* create the value to inject in the runtime parameter depending on its declared type */ + private Object getRuntimeValue(AnalysisEngineDescription desc, String attributeName) + throws ClassNotFoundException { + String type = desc.getAnalysisEngineMetaData().getConfigurationParameterDeclarations(). + getConfigurationParameter(null, attributeName).getType(); + // TODO : do it via reflection ? i.e. Class paramType = Class.forName(type)... + Object val = null; + Object runtimeValue = runtimeParameters.get(attributeName); + if (runtimeValue!=null) { + if ("String".equals(type)) { + val = String.valueOf(runtimeValue); + } + else if ("Integer".equals(type)) { + val = Integer.valueOf(runtimeValue.toString()); + } + else if ("Boolean".equals(type)) { + val = Boolean.valueOf(runtimeValue.toString()); + } + else if ("Float".equals(type)) { + val = Float.valueOf(runtimeValue.toString()); + } + } + + return val; + } + } \ No newline at end of file diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java index f6e032d3b78..dcf2f0d7b01 100644 --- a/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java +++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/UIMAUpdateRequestProcessorTest.java @@ -70,8 +70,6 @@ public class UIMAUpdateRequestProcessorTest extends SolrTestCaseJ4 { @Test public void testProcessing() throws Exception { - // this test requires an internet connection (e.g. opencalais api) - checkInternetConnection(); addDoc(adoc( "id", @@ -83,26 +81,29 @@ public class UIMAUpdateRequestProcessorTest extends SolrTestCaseJ4 { + " attached if you need it, but it is also committed to trunk and 3_x branch." + " Last Lucene European Conference has been held in Prague.")); assertU(commit()); - assertQ(req("suggested_category:*"), "//*[@numFound='1']"); + assertQ(req("sentence:*"), "//*[@numFound='1']"); + assertQ(req("sentiment:*"), "//*[@numFound='0']"); + assertQ(req("entity:Prague"), "//*[@numFound='1']"); } @Test public void testTwoUpdates() throws Exception { - // this test requires an internet connection (e.g. opencalais api) - checkInternetConnection(); addDoc(adoc("id", "1", "text", "The Apache Software Foundation is happy to announce " + "BarCampApache Sydney, Australia, the first ASF-backed event in the Southern " + "Hemisphere!")); assertU(commit()); - assertQ(req("suggested_category:*"), "//*[@numFound='1']"); + assertQ(req("sentence:*"), "//*[@numFound='1']"); addDoc(adoc("id", "2", "text", "Taking place 11th December 2010 at the University " + "of Sydney's Darlington Centre, the BarCampApache \"unconference\" will be" + " attendee-driven, facilitated by members of the Apache community and will " + "focus on the Apache...")); assertU(commit()); - assertQ(req("suggested_category:*"), "//*[@numFound='2']"); + assertQ(req("sentence:*"), "//*[@numFound='2']"); + + assertQ(req("sentiment:positive"), "//*[@numFound='1']"); + assertQ(req("entity:Apache"), "//*[@numFound='2']"); } private void addDoc(String doc) throws Exception { @@ -120,14 +121,4 @@ public class UIMAUpdateRequestProcessorTest extends SolrTestCaseJ4 { handler.handleRequestBody(req, new SolrQueryResponse()); } - private void checkInternetConnection() { - try { - URLConnection conn = new URL("http://www.apache.org/").openConnection(); - conn.setConnectTimeout(5000); - conn.setReadTimeout(5000); - conn.connect(); - } catch (Exception ex) { - assumeNoException("This test requires an internet connection", ex); - } - } } diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/an/DummyEntityAnnotator.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/an/DummyEntityAnnotator.java new file mode 100644 index 00000000000..6c3941ac49e --- /dev/null +++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/an/DummyEntityAnnotator.java @@ -0,0 +1,42 @@ +package org.apache.solr.uima.processor.an; + +import org.apache.solr.uima.ts.EntityAnnotation; +import org.apache.uima.TokenAnnotation; +import org.apache.uima.analysis_component.JCasAnnotator_ImplBase; +import org.apache.uima.analysis_engine.AnalysisEngineProcessException; +import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.tcas.Annotation; + +/** + * 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. + */ + +public class DummyEntityAnnotator extends JCasAnnotator_ImplBase{ + + @Override + public void process(JCas jcas) throws AnalysisEngineProcessException { + for (Annotation annotation : jcas.getAnnotationIndex(TokenAnnotation.type)) { + String tokenPOS = ((TokenAnnotation) annotation).getPosTag(); + if ("np".equals(tokenPOS) || "nps".equals(tokenPOS)) { + EntityAnnotation entityAnnotation = new EntityAnnotation(jcas); + entityAnnotation.setBegin(annotation.getBegin()); + entityAnnotation.setEnd(annotation.getEnd()); + entityAnnotation.addToIndexes(); + } + } + } + +} diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/an/DummySentimentAnnotator.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/an/DummySentimentAnnotator.java new file mode 100644 index 00000000000..b91d986c838 --- /dev/null +++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/processor/an/DummySentimentAnnotator.java @@ -0,0 +1,61 @@ +package org.apache.solr.uima.processor.an; + +import java.util.Arrays; + +import org.apache.solr.uima.ts.SentimentAnnotation; +import org.apache.uima.TokenAnnotation; +import org.apache.uima.analysis_component.JCasAnnotator_ImplBase; +import org.apache.uima.analysis_engine.AnalysisEngineProcessException; +import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.tcas.Annotation; + +/** + * 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. + */ + +public class DummySentimentAnnotator extends JCasAnnotator_ImplBase{ + + private static final String[] positiveAdj = {"happy","cool","nice"}; + + private static final String[] negativeAdj = {"bad","sad","ugly"}; + + @Override + public void process(JCas jcas) throws AnalysisEngineProcessException { + for (Annotation annotation : jcas.getAnnotationIndex(TokenAnnotation.type)) { + String tokenPOS = ((TokenAnnotation) annotation).getPosTag(); + if ("jj".equals(tokenPOS)) { + if (Arrays.asList(positiveAdj).contains(annotation.getCoveredText())) { + SentimentAnnotation sentimentAnnotation = createSentimentAnnotation(jcas, annotation); + sentimentAnnotation.setMood("positive"); + sentimentAnnotation.addToIndexes(); + } + else if (Arrays.asList(negativeAdj).contains(annotation.getCoveredText())) { + SentimentAnnotation sentimentAnnotation = createSentimentAnnotation(jcas, annotation); + sentimentAnnotation.setMood("negative"); + sentimentAnnotation.addToIndexes(); + } + } + } + } + + private SentimentAnnotation createSentimentAnnotation(JCas jcas, Annotation annotation) { + SentimentAnnotation sentimentAnnotation = new SentimentAnnotation(jcas); + sentimentAnnotation.setBegin(annotation.getBegin()); + sentimentAnnotation.setEnd(annotation.getEnd()); + return sentimentAnnotation; + } + +} diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/EntityAnnotation.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/EntityAnnotation.java new file mode 100644 index 00000000000..f48e5bc0912 --- /dev/null +++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/EntityAnnotation.java @@ -0,0 +1,62 @@ + + +/* First created by JCasGen Fri Mar 04 12:48:08 CET 2011 */ +package org.apache.solr.uima.ts; + +import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.JCasRegistry; +import org.apache.uima.jcas.cas.TOP_Type; + +import org.apache.uima.jcas.tcas.Annotation; + + +/** + * Updated by JCasGen Fri Mar 04 12:50:14 CET 2011 + * XML source: /Users/tommasoteofili/Documents/workspaces/lucene_workspace/lucene_dev/solr/contrib/uima/src/test/resources/DummyEntityAEDescriptor.xml + * @generated */ +public class EntityAnnotation extends Annotation { + /** @generated + * @ordered + */ + public final static int typeIndexID = JCasRegistry.register(EntityAnnotation.class); + /** @generated + * @ordered + */ + public final static int type = typeIndexID; + /** @generated */ + public int getTypeIndexID() {return typeIndexID;} + + /** Never called. Disable default constructor + * @generated */ + protected EntityAnnotation() {} + + /** Internal - constructor used by generator + * @generated */ + public EntityAnnotation(int addr, TOP_Type type) { + super(addr, type); + readObject(); + } + + /** @generated */ + public EntityAnnotation(JCas jcas) { + super(jcas); + readObject(); + } + + /** @generated */ + public EntityAnnotation(JCas jcas, int begin, int end) { + super(jcas); + setBegin(begin); + setEnd(end); + readObject(); + } + + /** + * Write your own initialization here + * + @generated modifiable */ + private void readObject() {} + +} + + \ No newline at end of file diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/EntityAnnotation_Type.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/EntityAnnotation_Type.java new file mode 100644 index 00000000000..f7bb572f7aa --- /dev/null +++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/EntityAnnotation_Type.java @@ -0,0 +1,55 @@ + +/* First created by JCasGen Fri Mar 04 12:48:08 CET 2011 */ +package org.apache.solr.uima.ts; + +import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.JCasRegistry; +import org.apache.uima.cas.impl.CASImpl; +import org.apache.uima.cas.impl.FSGenerator; +import org.apache.uima.cas.FeatureStructure; +import org.apache.uima.cas.impl.TypeImpl; +import org.apache.uima.cas.Type; +import org.apache.uima.jcas.tcas.Annotation_Type; + +/** + * Updated by JCasGen Fri Mar 04 12:50:14 CET 2011 + * @generated */ +public class EntityAnnotation_Type extends Annotation_Type { + /** @generated */ + protected FSGenerator getFSGenerator() {return fsGenerator;} + /** @generated */ + private final FSGenerator fsGenerator = + new FSGenerator() { + public FeatureStructure createFS(int addr, CASImpl cas) { + if (EntityAnnotation_Type.this.useExistingInstance) { + // Return eq fs instance if already created + FeatureStructure fs = EntityAnnotation_Type.this.jcas.getJfsFromCaddr(addr); + if (null == fs) { + fs = new EntityAnnotation(addr, EntityAnnotation_Type.this); + EntityAnnotation_Type.this.jcas.putJfsFromCaddr(addr, fs); + return fs; + } + return fs; + } else return new EntityAnnotation(addr, EntityAnnotation_Type.this); + } + }; + /** @generated */ + public final static int typeIndexID = EntityAnnotation.typeIndexID; + /** @generated + @modifiable */ + public final static boolean featOkTst = JCasRegistry.getFeatOkTst("org.apache.solr.uima.ts.EntityAnnotation"); + + + + /** initialize variables to correspond with Cas Type and Features + * @generated */ + public EntityAnnotation_Type(JCas jcas, Type casType) { + super(jcas, casType); + casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator()); + + } +} + + + + \ No newline at end of file diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/SentimentAnnotation.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/SentimentAnnotation.java new file mode 100644 index 00000000000..f3a5ad91ef6 --- /dev/null +++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/SentimentAnnotation.java @@ -0,0 +1,80 @@ + + +/* First created by JCasGen Fri Mar 04 13:08:40 CET 2011 */ +package org.apache.solr.uima.ts; + +import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.JCasRegistry; +import org.apache.uima.jcas.cas.TOP_Type; + +import org.apache.uima.jcas.tcas.Annotation; + + +/** + * Updated by JCasGen Fri Mar 04 13:08:40 CET 2011 + * XML source: /Users/tommasoteofili/Documents/workspaces/lucene_workspace/lucene_dev/solr/contrib/uima/src/test/resources/DummySentimentAnalysisAEDescriptor.xml + * @generated */ +public class SentimentAnnotation extends Annotation { + /** @generated + * @ordered + */ + public final static int typeIndexID = JCasRegistry.register(SentimentAnnotation.class); + /** @generated + * @ordered + */ + public final static int type = typeIndexID; + /** @generated */ + public int getTypeIndexID() {return typeIndexID;} + + /** Never called. Disable default constructor + * @generated */ + protected SentimentAnnotation() {} + + /** Internal - constructor used by generator + * @generated */ + public SentimentAnnotation(int addr, TOP_Type type) { + super(addr, type); + readObject(); + } + + /** @generated */ + public SentimentAnnotation(JCas jcas) { + super(jcas); + readObject(); + } + + /** @generated */ + public SentimentAnnotation(JCas jcas, int begin, int end) { + super(jcas); + setBegin(begin); + setEnd(end); + readObject(); + } + + /** + * Write your own initialization here + * + @generated modifiable */ + private void readObject() {} + + + + //*--------------* + //* Feature: mood + + /** getter for mood - gets + * @generated */ + public String getMood() { + if (SentimentAnnotation_Type.featOkTst && ((SentimentAnnotation_Type)jcasType).casFeat_mood == null) + jcasType.jcas.throwFeatMissing("mood", "org.apache.solr.uima.ts.SentimentAnnotation"); + return jcasType.ll_cas.ll_getStringValue(addr, ((SentimentAnnotation_Type)jcasType).casFeatCode_mood);} + + /** setter for mood - sets + * @generated */ + public void setMood(String v) { + if (SentimentAnnotation_Type.featOkTst && ((SentimentAnnotation_Type)jcasType).casFeat_mood == null) + jcasType.jcas.throwFeatMissing("mood", "org.apache.solr.uima.ts.SentimentAnnotation"); + jcasType.ll_cas.ll_setStringValue(addr, ((SentimentAnnotation_Type)jcasType).casFeatCode_mood, v);} + } + + \ No newline at end of file diff --git a/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/SentimentAnnotation_Type.java b/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/SentimentAnnotation_Type.java new file mode 100644 index 00000000000..88945c484c4 --- /dev/null +++ b/solr/contrib/uima/src/test/java/org/apache/solr/uima/ts/SentimentAnnotation_Type.java @@ -0,0 +1,79 @@ + +/* First created by JCasGen Fri Mar 04 13:08:40 CET 2011 */ +package org.apache.solr.uima.ts; + +import org.apache.uima.jcas.JCas; +import org.apache.uima.jcas.JCasRegistry; +import org.apache.uima.cas.impl.CASImpl; +import org.apache.uima.cas.impl.FSGenerator; +import org.apache.uima.cas.FeatureStructure; +import org.apache.uima.cas.impl.TypeImpl; +import org.apache.uima.cas.Type; +import org.apache.uima.cas.impl.FeatureImpl; +import org.apache.uima.cas.Feature; +import org.apache.uima.jcas.tcas.Annotation_Type; + +/** + * Updated by JCasGen Fri Mar 04 13:08:40 CET 2011 + * @generated */ +public class SentimentAnnotation_Type extends Annotation_Type { + /** @generated */ + protected FSGenerator getFSGenerator() {return fsGenerator;} + /** @generated */ + private final FSGenerator fsGenerator = + new FSGenerator() { + public FeatureStructure createFS(int addr, CASImpl cas) { + if (SentimentAnnotation_Type.this.useExistingInstance) { + // Return eq fs instance if already created + FeatureStructure fs = SentimentAnnotation_Type.this.jcas.getJfsFromCaddr(addr); + if (null == fs) { + fs = new SentimentAnnotation(addr, SentimentAnnotation_Type.this); + SentimentAnnotation_Type.this.jcas.putJfsFromCaddr(addr, fs); + return fs; + } + return fs; + } else return new SentimentAnnotation(addr, SentimentAnnotation_Type.this); + } + }; + /** @generated */ + public final static int typeIndexID = SentimentAnnotation.typeIndexID; + /** @generated + @modifiable */ + public final static boolean featOkTst = JCasRegistry.getFeatOkTst("org.apache.solr.uima.ts.SentimentAnnotation"); + + /** @generated */ + final Feature casFeat_mood; + /** @generated */ + final int casFeatCode_mood; + /** @generated */ + public String getMood(int addr) { + if (featOkTst && casFeat_mood == null) + jcas.throwFeatMissing("mood", "org.apache.solr.uima.ts.SentimentAnnotation"); + return ll_cas.ll_getStringValue(addr, casFeatCode_mood); + } + /** @generated */ + public void setMood(int addr, String v) { + if (featOkTst && casFeat_mood == null) + jcas.throwFeatMissing("mood", "org.apache.solr.uima.ts.SentimentAnnotation"); + ll_cas.ll_setStringValue(addr, casFeatCode_mood, v);} + + + + + + /** initialize variables to correspond with Cas Type and Features + * @generated */ + public SentimentAnnotation_Type(JCas jcas, Type casType) { + super(jcas, casType); + casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator()); + + + casFeat_mood = jcas.getRequiredFeatureDE(casType, "mood", "uima.cas.String", featOkTst); + casFeatCode_mood = (null == casFeat_mood) ? JCas.INVALID_FEATURE_CODE : ((FeatureImpl)casFeat_mood).getCode(); + + } +} + + + + \ No newline at end of file diff --git a/solr/contrib/uima/src/test/resources/AggregateSentenceAE.xml b/solr/contrib/uima/src/test/resources/AggregateSentenceAE.xml index d548da84170..73d697e220d 100644 --- a/solr/contrib/uima/src/test/resources/AggregateSentenceAE.xml +++ b/solr/contrib/uima/src/test/resources/AggregateSentenceAE.xml @@ -14,25 +14,34 @@ 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. - --> - +--> org.apache.uima.java false - - - + + + AggregateSentenceAE 1.0 - + + + ngramsize + Integer + false + false + + HmmTagger/NGRAM_SIZE + + + @@ -44,7 +53,10 @@ - + + org.apache.uima.SentenceAnnotation + org.apache.uima.TokenAnnotation + diff --git a/solr/contrib/uima/src/test/resources/DummyEntityAEDescriptor.xml b/solr/contrib/uima/src/test/resources/DummyEntityAEDescriptor.xml new file mode 100644 index 00000000000..61f1d8c8046 --- /dev/null +++ b/solr/contrib/uima/src/test/resources/DummyEntityAEDescriptor.xml @@ -0,0 +1,56 @@ + + + + org.apache.uima.java + true + org.apache.solr.uima.processor.an.DummyEntityAnnotator + + DummyEntityAEDescriptor + + 1.0 + ASF + + + + + + org.apache.solr.uima.ts.EntityAnnotation + + uima.tcas.Annotation + + + + + + + + + + org.apache.solr.uima.ts.EntityAnnotation + + + + + + true + true + false + + + + diff --git a/solr/contrib/uima/src/test/resources/DummySentimentAnalysisAEDescriptor.xml b/solr/contrib/uima/src/test/resources/DummySentimentAnalysisAEDescriptor.xml new file mode 100644 index 00000000000..315266dac35 --- /dev/null +++ b/solr/contrib/uima/src/test/resources/DummySentimentAnalysisAEDescriptor.xml @@ -0,0 +1,60 @@ + + + + org.apache.uima.java + true + org.apache.solr.uima.processor.an.DummySentimentAnnotator + + DummySentimentAnalysisAEDescriptor + + 1.0 + ASF + + + + + + org.apache.solr.uima.ts.SentimentAnnotation + + uima.tcas.Annotation + + + mood + + uima.cas.String + + + + + + + + + + + + + + + true + true + false + + + + diff --git a/solr/contrib/uima/src/test/resources/OpenCalaisAnnotator.xml b/solr/contrib/uima/src/test/resources/OpenCalaisAnnotator.xml deleted file mode 100644 index e7b0c07dcd4..00000000000 --- a/solr/contrib/uima/src/test/resources/OpenCalaisAnnotator.xml +++ /dev/null @@ -1,194 +0,0 @@ - - - org.apache.uima.java - true - org.apache.uima.annotator.calais.OpenCalaisAnnotator - - OpenCalaisAnnotator - - - - allowDistribution - - Boolean - false - true - - - allowSearch - - Boolean - false - true - - - submitter - - String - false - true - - - licenseID - - String - false - true - - - - - allowDistribution - - false - - - - allowSearch - - false - - - - submitter - - - - - - licenseID - - OC_LICENSE_ID - - - - - - - org.apache.uima.calais.Person - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Anniversary - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.City - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Company - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Continent - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Country - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Currency - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.EmailAddress - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Facility - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.FaxNumber - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Holiday - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.IndustryTerm - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.NaturalDisaster - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.NaturalFeature - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Organization - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.PhoneNumber - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.ProviceOrState - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Region - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.Technology - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.URL - - org.apache.uima.calais.BaseType - - - org.apache.uima.calais.BaseType - - uima.tcas.Annotation - - - calaisType - OpenCalais type - uima.cas.String - - - - - - - - - - - - - - true - true - false - - - diff --git a/solr/contrib/uima/src/test/resources/TestAE.xml b/solr/contrib/uima/src/test/resources/TestAE.xml index 87c9eda678b..70fb9b612eb 100644 --- a/solr/contrib/uima/src/test/resources/TestAE.xml +++ b/solr/contrib/uima/src/test/resources/TestAE.xml @@ -20,126 +20,38 @@ org.apache.uima.java false - - - - - - - - - - - - - - - - - + + + + + - ExtServicesAE + TestAE 1.0 - + - oc_licenseID - String + ngramsize + Integer false - true + false - OpenCalaisAnnotator/licenseID - - - - keyword_apikey - String - false - true - - TextKeywordExtractionAEDescriptor/apikey - - - - concept_apikey - String - false - true - - TextConceptTaggingAEDescriptor/apikey - - - - lang_apikey - String - false - true - - TextLanguageDetectionAEDescriptor/apikey - - - - cat_apikey - String - false - true - - TextCategorizationAEDescriptor/apikey - - - - entities_apikey - String - false - true - - TextRankedEntityExtractionAEDescriptor/apikey + AggregateSentenceAE/ngramsize - - - oc_licenseID - - licenseid - - - - keyword_apikey - - apikey - - - - concept_apikey - - apikey - - - - lang_apikey - - apikey - - - - cat_apikey - - apikey - - - + AggregateSentenceAE - OpenCalaisAnnotator - TextCategorizationAEDescriptor + DummyEntityAEDescriptor + DummySentimentAnalysisAEDescriptor diff --git a/solr/contrib/uima/src/test/resources/TextCategorizationAEDescriptor.xml b/solr/contrib/uima/src/test/resources/TextCategorizationAEDescriptor.xml deleted file mode 100644 index 16aff2b7775..00000000000 --- a/solr/contrib/uima/src/test/resources/TextCategorizationAEDescriptor.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - org.apache.uima.java - true - org.apache.uima.alchemy.annotator.TextCategorizationAnnotator - - TextCategorizationAEDescriptor - - 1.0 - - - - apikey - String - false - true - - - outputMode - String - false - true - - - baseUrl - String - false - false - - - - - outputMode - - xml - - - - apikey - - AA_API_KEY - - - - - - - org.apache.uima.alchemy.ts.categorization.Category - - uima.cas.TOP - - - score - - uima.cas.String - - - text - - uima.cas.String - - - - - - - - - - - - - - - - true - true - false - - - - diff --git a/solr/contrib/uima/src/test/resources/solr-uima/conf/schema.xml b/solr/contrib/uima/src/test/resources/solr-uima/conf/schema.xml index ff447a97f2b..6df09b51320 100644 --- a/solr/contrib/uima/src/test/resources/solr-uima/conf/schema.xml +++ b/solr/contrib/uima/src/test/resources/solr-uima/conf/schema.xml @@ -562,11 +562,9 @@ --> - - - - + +