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
|
* 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.common.SolrInputDocument;
|
||||||
import org.apache.solr.uima.processor.SolrUIMAConfiguration.MapField;
|
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.FSIterator;
|
||||||
import org.apache.uima.cas.FeatureStructure;
|
import org.apache.uima.cas.FeatureStructure;
|
||||||
import org.apache.uima.cas.Type;
|
import org.apache.uima.cas.Type;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<typeSystemDescription>
|
<typeSystemDescription>
|
||||||
<types>
|
<types>
|
||||||
<typeDescription>
|
<typeDescription>
|
||||||
<name>org.apache.solr.uima.ts.SentimentAnnotation</name>
|
<name>org.apache.solr.uima.ts.DummySentimentAnnotation</name>
|
||||||
<description/>
|
<description/>
|
||||||
<supertypeName>uima.tcas.Annotation</supertypeName>
|
<supertypeName>uima.tcas.Annotation</supertypeName>
|
||||||
<features>
|
<features>
|
||||||
|
|
|
@ -827,7 +827,7 @@
|
||||||
</lst>
|
</lst>
|
||||||
</lst>
|
</lst>
|
||||||
<lst name="type">
|
<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">
|
<lst name="mapping">
|
||||||
<str name="feature">mood</str>
|
<str name="feature">mood</str>
|
||||||
<str name="field">sentiment</str>
|
<str name="field">sentiment</str>
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.apache.solr.uima.processor.an;
|
||||||
|
|
||||||
import java.util.Arrays;
|
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.TokenAnnotation;
|
||||||
import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
|
import org.apache.uima.analysis_component.JCasAnnotator_ImplBase;
|
||||||
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
|
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
|
||||||
|
@ -38,24 +38,24 @@ public class DummySentimentAnnotator extends JCasAnnotator_ImplBase{
|
||||||
String tokenPOS = ((TokenAnnotation) annotation).getPosTag();
|
String tokenPOS = ((TokenAnnotation) annotation).getPosTag();
|
||||||
if ("jj".equals(tokenPOS)) {
|
if ("jj".equals(tokenPOS)) {
|
||||||
if (Arrays.asList(positiveAdj).contains(annotation.getCoveredText())) {
|
if (Arrays.asList(positiveAdj).contains(annotation.getCoveredText())) {
|
||||||
SentimentAnnotation sentimentAnnotation = createSentimentAnnotation(jcas, annotation);
|
DummySentimentAnnotation dummySentimentAnnotation = createSentimentAnnotation(jcas, annotation);
|
||||||
sentimentAnnotation.setMood("positive");
|
dummySentimentAnnotation.setMood("positive");
|
||||||
sentimentAnnotation.addToIndexes();
|
dummySentimentAnnotation.addToIndexes();
|
||||||
}
|
}
|
||||||
else if (Arrays.asList(negativeAdj).contains(annotation.getCoveredText())) {
|
else if (Arrays.asList(negativeAdj).contains(annotation.getCoveredText())) {
|
||||||
SentimentAnnotation sentimentAnnotation = createSentimentAnnotation(jcas, annotation);
|
DummySentimentAnnotation dummySentimentAnnotation = createSentimentAnnotation(jcas, annotation);
|
||||||
sentimentAnnotation.setMood("negative");
|
dummySentimentAnnotation.setMood("negative");
|
||||||
sentimentAnnotation.addToIndexes();
|
dummySentimentAnnotation.addToIndexes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private SentimentAnnotation createSentimentAnnotation(JCas jcas, Annotation annotation) {
|
private DummySentimentAnnotation createSentimentAnnotation(JCas jcas, Annotation annotation) {
|
||||||
SentimentAnnotation sentimentAnnotation = new SentimentAnnotation(jcas);
|
DummySentimentAnnotation dummySentimentAnnotation = new DummySentimentAnnotation(jcas);
|
||||||
sentimentAnnotation.setBegin(annotation.getBegin());
|
dummySentimentAnnotation.setBegin(annotation.getBegin());
|
||||||
sentimentAnnotation.setEnd(annotation.getEnd());
|
dummySentimentAnnotation.setEnd(annotation.getEnd());
|
||||||
return sentimentAnnotation;
|
return dummySentimentAnnotation;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,11 +14,11 @@ import org.apache.uima.jcas.tcas.Annotation;
|
||||||
* Updated by JCasGen Fri Mar 04 13:08:40 CET 2011
|
* 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
|
* XML source: /Users/tommasoteofili/Documents/workspaces/lucene_workspace/lucene_dev/solr/contrib/uima/src/test/resources/DummySentimentAnalysisAEDescriptor.xml
|
||||||
* @generated */
|
* @generated */
|
||||||
public class SentimentAnnotation extends Annotation {
|
public class DummySentimentAnnotation extends Annotation {
|
||||||
/** @generated
|
/** @generated
|
||||||
* @ordered
|
* @ordered
|
||||||
*/
|
*/
|
||||||
public final static int typeIndexID = JCasRegistry.register(SentimentAnnotation.class);
|
public final static int typeIndexID = JCasRegistry.register(DummySentimentAnnotation.class);
|
||||||
/** @generated
|
/** @generated
|
||||||
* @ordered
|
* @ordered
|
||||||
*/
|
*/
|
||||||
|
@ -28,23 +28,23 @@ public class SentimentAnnotation extends Annotation {
|
||||||
|
|
||||||
/** Never called. Disable default constructor
|
/** Never called. Disable default constructor
|
||||||
* @generated */
|
* @generated */
|
||||||
protected SentimentAnnotation() {}
|
protected DummySentimentAnnotation() {}
|
||||||
|
|
||||||
/** Internal - constructor used by generator
|
/** Internal - constructor used by generator
|
||||||
* @generated */
|
* @generated */
|
||||||
public SentimentAnnotation(int addr, TOP_Type type) {
|
public DummySentimentAnnotation(int addr, TOP_Type type) {
|
||||||
super(addr, type);
|
super(addr, type);
|
||||||
readObject();
|
readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @generated */
|
/** @generated */
|
||||||
public SentimentAnnotation(JCas jcas) {
|
public DummySentimentAnnotation(JCas jcas) {
|
||||||
super(jcas);
|
super(jcas);
|
||||||
readObject();
|
readObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @generated */
|
/** @generated */
|
||||||
public SentimentAnnotation(JCas jcas, int begin, int end) {
|
public DummySentimentAnnotation(JCas jcas, int begin, int end) {
|
||||||
super(jcas);
|
super(jcas);
|
||||||
setBegin(begin);
|
setBegin(begin);
|
||||||
setEnd(end);
|
setEnd(end);
|
||||||
|
@ -65,16 +65,16 @@ public class SentimentAnnotation extends Annotation {
|
||||||
/** getter for mood - gets
|
/** getter for mood - gets
|
||||||
* @generated */
|
* @generated */
|
||||||
public String getMood() {
|
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");
|
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
|
/** setter for mood - sets
|
||||||
* @generated */
|
* @generated */
|
||||||
public void setMood(String v) {
|
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.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
|
* Updated by JCasGen Fri Mar 04 13:08:40 CET 2011
|
||||||
* @generated */
|
* @generated */
|
||||||
public class SentimentAnnotation_Type extends Annotation_Type {
|
public class DummySentimentAnnotation_Type extends Annotation_Type {
|
||||||
/** @generated */
|
/** @generated */
|
||||||
protected FSGenerator getFSGenerator() {return fsGenerator;}
|
protected FSGenerator getFSGenerator() {return fsGenerator;}
|
||||||
/** @generated */
|
/** @generated */
|
||||||
private final FSGenerator fsGenerator =
|
private final FSGenerator fsGenerator =
|
||||||
new FSGenerator() {
|
new FSGenerator() {
|
||||||
public FeatureStructure createFS(int addr, CASImpl cas) {
|
public FeatureStructure createFS(int addr, CASImpl cas) {
|
||||||
if (SentimentAnnotation_Type.this.useExistingInstance) {
|
if (DummySentimentAnnotation_Type.this.useExistingInstance) {
|
||||||
// Return eq fs instance if already created
|
// 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) {
|
if (null == fs) {
|
||||||
fs = new SentimentAnnotation(addr, SentimentAnnotation_Type.this);
|
fs = new DummySentimentAnnotation(addr, DummySentimentAnnotation_Type.this);
|
||||||
SentimentAnnotation_Type.this.jcas.putJfsFromCaddr(addr, fs);
|
DummySentimentAnnotation_Type.this.jcas.putJfsFromCaddr(addr, fs);
|
||||||
return fs;
|
return fs;
|
||||||
}
|
}
|
||||||
return fs;
|
return fs;
|
||||||
} else return new SentimentAnnotation(addr, SentimentAnnotation_Type.this);
|
} else return new DummySentimentAnnotation(addr, DummySentimentAnnotation_Type.this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/** @generated */
|
/** @generated */
|
||||||
public final static int typeIndexID = SentimentAnnotation.typeIndexID;
|
public final static int typeIndexID = DummySentimentAnnotation.typeIndexID;
|
||||||
/** @generated
|
/** @generated
|
||||||
@modifiable */
|
@modifiable */
|
||||||
public final static boolean featOkTst = JCasRegistry.getFeatOkTst("org.apache.solr.uima.ts.SentimentAnnotation");
|
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
|
/** initialize variables to correspond with Cas Type and Features
|
||||||
* @generated */
|
* @generated */
|
||||||
public SentimentAnnotation_Type(JCas jcas, Type casType) {
|
public DummySentimentAnnotation_Type(JCas jcas, Type casType) {
|
||||||
super(jcas, casType);
|
super(jcas, casType);
|
||||||
casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());
|
casImpl.getFSClassRegistry().addGeneratorForType((TypeImpl)this.casType, getFSGenerator());
|
||||||
|
|
Loading…
Reference in New Issue