mirror of https://github.com/apache/lucene.git
[SOLR-3902] - moved SentimentAnnotation to DummySentimentAnnotation (to avoid cofusion), moved out FieldMappingException from a dedicated exception package
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1391322 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9639baaa32
commit
c65bdde36f
|
@ -1,4 +1,4 @@
|
|||
package org.apache.solr.uima.processor.exception;
|
||||
package org.apache.solr.uima.processor;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
@ -21,7 +21,6 @@ import java.util.Map;
|
|||
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField;
|
||||
import org.apache.solr.uima.processor.exception.FieldMappingException;
|
||||
import org.apache.uima.cas.FSIterator;
|
||||
import org.apache.uima.cas.FeatureStructure;
|
||||
import org.apache.uima.cas.Type;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
<typeSystemDescription>
|
||||
<types>
|
||||
<typeDescription>
|
||||
<name>org.apache.solr.uima.ts.SentimentAnnotation</name>
|
||||
<name>org.apache.solr.uima.ts.DummySentimentAnnotation</name>
|
||||
<description/>
|
||||
<supertypeName>uima.tcas.Annotation</supertypeName>
|
||||
<features>
|
||||
|
|
|
@ -827,7 +827,7 @@
|
|||
</lst>
|
||||
</lst>
|
||||
<lst name="type">
|
||||
<str name="name">org.apache.solr.uima.ts.SentimentAnnotation</str>
|
||||
<str name="name">org.apache.solr.uima.ts.DummySentimentAnnotation</str>
|
||||
<lst name="mapping">
|
||||
<str name="feature">mood</str>
|
||||
<str name="field">sentiment</str>
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.apache.solr.uima.processor.an;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.solr.uima.ts.SentimentAnnotation;
|
||||
import org.apache.solr.uima.ts.DummySentimentAnnotation;
|
||||
import org.apache.uima.TokenAnnotation;
|
||||
import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
|
||||
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
|
||||
|
@ -38,24 +38,24 @@ public class DummySentimentAnnotator extends JCasAnnotator_ImplBase{
|
|||
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();
|
||||
DummySentimentAnnotation dummySentimentAnnotation = createSentimentAnnotation(jcas, annotation);
|
||||
dummySentimentAnnotation.setMood("positive");
|
||||
dummySentimentAnnotation.addToIndexes();
|
||||
}
|
||||
else if (Arrays.asList(negativeAdj).contains(annotation.getCoveredText())) {
|
||||
SentimentAnnotation sentimentAnnotation = createSentimentAnnotation(jcas, annotation);
|
||||
sentimentAnnotation.setMood("negative");
|
||||
sentimentAnnotation.addToIndexes();
|
||||
DummySentimentAnnotation dummySentimentAnnotation = createSentimentAnnotation(jcas, annotation);
|
||||
dummySentimentAnnotation.setMood("negative");
|
||||
dummySentimentAnnotation.addToIndexes();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private SentimentAnnotation createSentimentAnnotation(JCas jcas, Annotation annotation) {
|
||||
SentimentAnnotation sentimentAnnotation = new SentimentAnnotation(jcas);
|
||||
sentimentAnnotation.setBegin(annotation.getBegin());
|
||||
sentimentAnnotation.setEnd(annotation.getEnd());
|
||||
return sentimentAnnotation;
|
||||
private DummySentimentAnnotation createSentimentAnnotation(JCas jcas, Annotation annotation) {
|
||||
DummySentimentAnnotation dummySentimentAnnotation = new DummySentimentAnnotation(jcas);
|
||||
dummySentimentAnnotation.setBegin(annotation.getBegin());
|
||||
dummySentimentAnnotation.setEnd(annotation.getEnd());
|
||||
return dummySentimentAnnotation;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ 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 {
|
||||
public class DummySentimentAnnotation extends Annotation {
|
||||
/** @generated
|
||||
* @ordered
|
||||
*/
|
||||
public final static int typeIndexID = JCasRegistry.register(SentimentAnnotation.class);
|
||||
public final static int typeIndexID = JCasRegistry.register(DummySentimentAnnotation.class);
|
||||
/** @generated
|
||||
* @ordered
|
||||
*/
|
||||
|
@ -28,23 +28,23 @@ public class SentimentAnnotation extends Annotation {
|
|||
|
||||
/** Never called. Disable default constructor
|
||||
* @generated */
|
||||
protected SentimentAnnotation() {}
|
||||
protected DummySentimentAnnotation() {}
|
||||
|
||||
/** Internal - constructor used by generator
|
||||
* @generated */
|
||||
public SentimentAnnotation(int addr, TOP_Type type) {
|
||||
public DummySentimentAnnotation(int addr, TOP_Type type) {
|
||||
super(addr, type);
|
||||
readObject();
|
||||
}
|
||||
|
||||
/** @generated */
|
||||
public SentimentAnnotation(JCas jcas) {
|
||||
public DummySentimentAnnotation(JCas jcas) {
|
||||
super(jcas);
|
||||
readObject();
|
||||
}
|
||||
|
||||
/** @generated */
|
||||
public SentimentAnnotation(JCas jcas, int begin, int end) {
|
||||
public DummySentimentAnnotation(JCas jcas, int begin, int end) {
|
||||
super(jcas);
|
||||
setBegin(begin);
|
||||
setEnd(end);
|
||||
|
@ -65,16 +65,16 @@ public class SentimentAnnotation extends Annotation {
|
|||
/** getter for mood - gets
|
||||
* @generated */
|
||||
public String getMood() {
|
||||
if (SentimentAnnotation_Type.featOkTst && ((SentimentAnnotation_Type)jcasType).casFeat_mood == null)
|
||||
if (DummySentimentAnnotation_Type.featOkTst && ((DummySentimentAnnotation_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);}
|
||||
return jcasType.ll_cas.ll_getStringValue(addr, ((DummySentimentAnnotation_Type)jcasType).casFeatCode_mood);}
|
||||
|
||||
/** setter for mood - sets
|
||||
* @generated */
|
||||
public void setMood(String v) {
|
||||
if (SentimentAnnotation_Type.featOkTst && ((SentimentAnnotation_Type)jcasType).casFeat_mood == null)
|
||||
if (DummySentimentAnnotation_Type.featOkTst && ((DummySentimentAnnotation_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);}
|
||||
jcasType.ll_cas.ll_setStringValue(addr, ((DummySentimentAnnotation_Type)jcasType).casFeatCode_mood, v);}
|
||||
}
|
||||
|
||||
|
|
@ -15,27 +15,27 @@ 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 {
|
||||
public class DummySentimentAnnotation_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) {
|
||||
if (DummySentimentAnnotation_Type.this.useExistingInstance) {
|
||||
// Return eq fs instance if already created
|
||||
FeatureStructure fs = SentimentAnnotation_Type.this.jcas.getJfsFromCaddr(addr);
|
||||
FeatureStructure fs = DummySentimentAnnotation_Type.this.jcas.getJfsFromCaddr(addr);
|
||||
if (null == fs) {
|
||||
fs = new SentimentAnnotation(addr, SentimentAnnotation_Type.this);
|
||||
SentimentAnnotation_Type.this.jcas.putJfsFromCaddr(addr, fs);
|
||||
fs = new DummySentimentAnnotation(addr, DummySentimentAnnotation_Type.this);
|
||||
DummySentimentAnnotation_Type.this.jcas.putJfsFromCaddr(addr, fs);
|
||||
return fs;
|
||||
}
|
||||
return fs;
|
||||
} else return new SentimentAnnotation(addr, SentimentAnnotation_Type.this);
|
||||
} else return new DummySentimentAnnotation(addr, DummySentimentAnnotation_Type.this);
|
||||
}
|
||||
};
|
||||
/** @generated */
|
||||
public final static int typeIndexID = SentimentAnnotation.typeIndexID;
|
||||
public final static int typeIndexID = DummySentimentAnnotation.typeIndexID;
|
||||
/** @generated
|
||||
@modifiable */
|
||||
public final static boolean featOkTst = JCasRegistry.getFeatOkTst("org.apache.solr.uima.ts.SentimentAnnotation");
|
||||
|
@ -62,7 +62,7 @@ public class SentimentAnnotation_Type extends Annotation_Type {
|
|||
|
||||
/** initialize variables to correspond with Cas Type and Features
|
||||
* @generated */
|
||||
public SentimentAnnotation_Type(JCas jcas, Type casType) {
|
||||
public DummySentimentAnnotation_Type(JCas jcas, Type casType) {
|
||||
super(jcas, casType);
|
||||
casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());
|
||||
|
Loading…
Reference in New Issue