Hi,
I have attached a txt version. Sorry for wrong format. Do have a look.
Thanks,
Ravi
On Mon, Jul 29, 2013 at 6:21 PM, Tim Miller <
[email protected]> wrote:
> Ravi,
> My email reader doesn't seem to know what format the attachment is. If
> it's short enough you may be able to just paste your source into the body
> of the email, otherwise could you resend the file with an appropriate file
> extension?
> Thanks
> Tim
>
>
> On 07/28/2013 08:58 AM, ravi garg wrote:
>
> Hi,
> I skipped the tests for now and was able to build it successfully. But I
> am facing another problem here. I get a NoSuchElementFound Exception when I
> run the pipeline. I have attached the code for reference. Please do have a
> look. The AnalysisEngine get initialised fine but for some reasons I am not
> getting any Annotation. The exact error is,
>
> Caused by: java.util.NoSuchElementException at
> org.apache.uima.cas.impl.FSIndexRepositoryImpl$PointerIterator.ll_get(FSIndexRepositoryImpl.java:542)
> at
> org.apache.uima.cas.impl.FSIndexRepositoryImpl$PointerIterator.get(FSIndexRepositoryImpl.java:537)
> at
> org.apache.uima.cas.impl.FSIteratorWrapper.get(FSIteratorWrapper.java:48)
> at
> org.apache.uima.cas.impl.FSIteratorImplBase.next(FSIteratorImplBase.java:67)
> at
> org.apache.uima.cas.impl.FSIteratorImplBase.next(FSIteratorImplBase.java:33)
> at
> org.phenotips.ctakes.CTAKESScriptService.extract(CTAKESScriptService.java:400)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:616) at
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.doInvoke(UberspectImpl.java:395)
> at
> org.apache.velocity.util.introspection.UberspectImpl$VelMethodImpl.invoke(UberspectImpl.java:384)
> at
> org.apache.velocity.runtime.parser.node.ASTMethod.execute(ASTMethod.java:173)
> ... 116 more
>
>
>
>
>
>
> On Sat, Jul 27, 2013 at 5:13 PM, ravi garg <[email protected]> wrote:
>
>> Hi,
>>
>> I downloaded the 3.1 version (
>> https://svn.apache.org/repos/asf/ctakes/branches/ctakes-3.1.0/).
>> But while running mvn clean install I get a build error. The error is
>>
>> Results :
>>
>> Tests in error:
>>
>> testTokenizerAnnotatorPTB(org.apache.ctakes.core.ae.TokenizerAnnotatorPTBTests):
>> Initialization of annotator class
>> "org.apache.ctakes.core.ae.SentenceDetector" failed. (Descriptor:
>> file:/home/ravi/cTAKES3.1/ctakes-core/desc/analysis_engine/SentenceDetectorAnnotator.xml
>> )
>>
>> Tests run: 3, Failures: 0, Errors: 1, Skipped: 0
>>
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Reactor Summary:
>> [INFO]
>> [INFO] Apache cTAKES ..................................... SUCCESS
>> [4.215s]
>> [INFO] Apache cTAKES common type system .................. SUCCESS
>> [7.806s]
>> [INFO] Apache cTAKES utils ............................... SUCCESS
>> [2.361s]
>> [INFO] Apache cTAKES Resources core ...................... SUCCESS
>> [0.979s]
>> [INFO] Apache cTAKES core ................................ FAILURE
>> [6.078s]
>> [INFO] Apache cTAKES Resources pos-tagger ................ SKIPPED
>> [INFO] Apache cTAKES part-of-speech tagger ............... SKIPPED
>> [INFO] Apache cTAKES Resources ctakes-chunker-res ........ SKIPPED
>> [INFO] Apache cTAKES chunker ............................. SKIPPED
>> [INFO] Apache cTAKES document preprocessor ............... SKIPPED
>> [INFO] Apache cTAKES Resources dictionary-lookup ......... SKIPPED
>> [INFO] Apache cTAKES dictionary lookup ................... SKIPPED
>> [INFO] Apache cTAKES context dependent tokenizer ......... SKIPPED
>> [INFO] Apache cTAKES Resources lvg ....................... SKIPPED
>> [INFO] Apache cTAKES LVG lexical tools ................... SKIPPED
>> [INFO] Apache cTAKES Resources ne-contexts ............... SKIPPED
>> [INFO] Apache cTAKES named entity contexts ............... SKIPPED
>> [INFO] Apache cTAKES Resources constituency-parser ....... SKIPPED
>> [INFO] Apache cTAKES Constituency Parser ................. SKIPPED
>> [INFO] Apache cTAKES Resources coreference ............... SKIPPED
>> [INFO] Apache cTAKES Resources relation-extractor ........ SKIPPED
>> [INFO] Apache cTAKES Resources dependency-parser ......... SKIPPED
>> [INFO] Apache cTAKES Dependency Parser ................... SKIPPED
>> [INFO] Apache cTAKES Relation Extractor .................. SKIPPED
>> [INFO] Apache cTAKES CoReference Resolver ................ SKIPPED
>> [INFO] Apache cTAKES Resources drug-ner .................. SKIPPED
>> [INFO] Apache cTAKES Drug NER ............................ SKIPPED
>> [INFO] Apache cTAKES Resources side-effect ............... SKIPPED
>> [INFO] Apache cTAKES Side Effects ........................ SKIPPED
>> [INFO] Apache cTAKES Resources smoking-status ............ SKIPPED
>> [INFO] Apache cTAKES Smoking Status ...................... SKIPPED
>> [INFO] Apache cTAKES Resources pad-term-spotter-res ...... SKIPPED
>> [INFO] Apache cTAKES Pad Term Spotter .................... SKIPPED
>> [INFO] Apache cTAKES Resources assertion ................. SKIPPED
>> [INFO] Apache cTAKES Resources assertion-zoner ........... SKIPPED
>> [INFO] Apache cTAKES Assertion's zoner ................... SKIPPED
>> [INFO] Apache cTAKES Assertion ........................... SKIPPED
>> [INFO] Apache cTAKES Resources temporal .................. SKIPPED
>> [INFO] Apache cTAKES Temporal Information Extraction ..... SKIPPED
>> [INFO] Apache cTAKES ctakes-clinical-pipeline ............ SKIPPED
>> [INFO] Apache cTAKES Distribution ........................ SKIPPED
>> [INFO] Apache cTAKES Regression-test ..................... SKIPPED
>> [INFO] Apache cTAKES template filler ..................... SKIPPED
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] BUILD FAILURE
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] Total time: 23.783s
>> [INFO] Finished at: Sat Jul 27 17:07:40 IST 2013
>> [INFO] Final Memory: 30M/198M
>> [INFO]
>> ------------------------------------------------------------------------
>> [ERROR] Failed to execute goal
>> org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on
>> project ctakes-core: There are test failures.
>>
>>
>> Any ideas what I am doing wrong or what am I missing something. I
>> checked and confirmed to have updated version of 3.1
>>
>>
>> On Fri, Jul 26, 2013 at 9:52 PM, ravi garg <[email protected]> wrote:
>>
>>> Hi,
>>>
>>> I will checkout the latest version. Thanks for the prompt reply :)
>>>
>>>
>>> On Fri, Jul 26, 2013 at 6:56 PM, Chen, Pei <
>>> [email protected]> wrote:
>>>
>>>> Ravi,
>>>> trunk an the upcoming release (3.1) - have been upgraded to Lucene 4.x.
>>>> There should be an RC very soon... I would strongly recommend using that as
>>>> there were some code changes as well new updating the resources/indexes.
>>>>
>>>> Sent from my iPhone
>>>>
>>>> On Jul 26, 2013, at 8:08 AM, "ravi garg" <[email protected]> wrote:
>>>>
>>>> > Hi,
>>>> >
>>>> > I am working on a project which uses upgraded Lucene version (4.0). I
>>>> have to integrate cTAKES with it but unfortunately cTAKES still uses older
>>>> version of Lucene (3.0 I believe). So is there a workaround you could
>>>> please suggest. Also is the newer version of Apache cTAKES scheduled to
>>>> arrive soon with the updated Lucene version. Could you please provide any
>>>> info on that.
>>>> >
>>>> > Thanks,
>>>> > Ravi Garg
>>>> >
>>>> > --
>>>> > Ravi Garg
>>>> > 3rd Year
>>>> > MSc (hons) Biological Sciences
>>>> > B.E (hons) Computer Science and Engineering
>>>> > BITS Pilani KK Birla Goa Campus
>>>>
>>>
>>>
>>>
>>> --
>>> Ravi Garg
>>> 3rd Year
>>> MSc (hons) Biological Sciences
>>> B.E (hons) Computer Science and Engineering
>>> BITS Pilani KK Birla Goa Campus
>>>
>>
>>
>>
>> --
>> Ravi Garg
>> 3rd Year
>> MSc (hons) Biological Sciences
>> B.E (hons) Computer Science and Engineering
>> BITS Pilani KK Birla Goa Campus
>>
>
>
>
> --
> Ravi Garg
> 3rd Year
> MSc (hons) Biological Sciences
> B.E (hons) Computer Science and Engineering
> BITS Pilani KK Birla Goa Campus
>
>
>
--
Ravi Garg
3rd Year
MSc (hons) Biological Sciences
B.E (hons) Computer Science and Engineering
BITS Pilani KK Birla Goa Campus
import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.inject.Named;
import javax.inject.Singleton;
import org.apache.ctakes.chunker.ae.Chunker;
import org.apache.ctakes.chunker.ae.adjuster.ChunkAdjuster;
import org.apache.ctakes.contexttokenizer.ae.ContextDependentTokenizerAnnotator;
import org.apache.ctakes.core.ae.CopyAnnotator;
import org.apache.ctakes.core.ae.OverlapAnnotator;
import org.apache.ctakes.core.ae.SentenceDetector;
import org.apache.ctakes.core.ae.SimpleSegmentAnnotator;
import org.apache.ctakes.core.ae.TokenizerAnnotatorPTB;
import org.apache.ctakes.core.resource.FileResource;
import org.apache.ctakes.core.resource.FileResourceImpl;
import org.apache.ctakes.core.resource.LuceneIndexReaderResourceImpl;
import org.apache.ctakes.dictionary.lookup.ae.DictionaryLookupAnnotator;
import org.apache.ctakes.postagger.POSTagger;
import org.apache.ctakes.typesystem.type.textsem.EventMention;
import org.apache.uima.analysis_engine.AnalysisEngine;
import org.apache.uima.analysis_engine.AnalysisEngineDescription;
import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
import org.apache.uima.cas.FSIndex;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.Annotation;
import org.apache.uima.resource.ExternalResourceDependency;
import org.apache.uima.resource.ExternalResourceDescription;
import org.apache.uima.resource.ResourceInitializationException;
import org.apache.uima.resource.impl.ExternalResourceDependency_impl;
import org.apache.uima.resource.metadata.ConfigurationParameter;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.resource.metadata.impl.TypeSystemDescription_impl;
import org.uimafit.factory.AnalysisEngineFactory;
import org.uimafit.factory.ConfigurationParameterFactory;
import org.uimafit.factory.ExternalResourceFactory;
import org.uimafit.factory.TypeSystemDescriptionFactory;
import org.uimafit.util.JCasUtil;
import org.xwiki.component.annotation.Component;
import org.xwiki.component.phase.Initializable;
import org.xwiki.component.phase.InitializationException;
import org.xwiki.script.service.ScriptService;
@Component
@Named("ctakes")
@Singleton
public class CTAKESScriptService implements ScriptService, Initializable
{
private AnalysisEngine analysisEng;
private Class<FileResource> fileResClass =
org.apache.ctakes.core.resource.FileResource.class;
private Class<FileResourceImpl> fileResClassImpl =
org.apache.ctakes.core.resource.FileResourceImpl.class;
@Override
public final void initialize() throws InitializationException {
String tsdst = "org.apache.ctakes.typesystem.types.TypeSystem";
TypeSystemDescription tsd =
TypeSystemDescriptionFactory.createTypeSystemDescription(tsdst);
try {
//Segmentation
Class<SimpleSegmentAnnotator> ssA = SimpleSegmentAnnotator.class;
AnalysisEngineDescription simpleSegmentDesc =
AnalysisEngineFactory.createPrimitiveDescription(ssA);
//Tokenizer
Class<TokenizerAnnotatorPTB> taC = TokenizerAnnotatorPTB.class;
AnalysisEngineDescription tokenizerDesc =
AnalysisEngineFactory.createPrimitiveDescription(taC, tsd);
//Sentence Detection
String senturl = "webapps/phenotips/resources/cTAKES/"
+ "SentenceDetection/sd-med-model.zip";
AnalysisEngineDescription sentDetectDesc =
AnalysisEngineFactory.createPrimitiveDescription(
SentenceDetector.class,
SentenceDetector.SD_MODEL_FILE_PARAM, senturl);
//context dependent tokenizer
Class<ContextDependentTokenizerAnnotator> cdta =
ContextDependentTokenizerAnnotator.class;
AnalysisEngineDescription contextDependentTokenizerDesc =
AnalysisEngineFactory.createPrimitiveDescription(cdta);
//POS Tagger
String posresfile = "webapps/phenotips/resources/cTAKES/"
+ "POSTagger/mayo-pos.zip";
AnalysisEngineDescription posTagdesc =
AnalysisEngineFactory.createPrimitiveDescription(
POSTagger.class, tsd,
POSTagger.POS_MODEL_FILE_PARAM, posresfile);
//Chunker
String chunkfileres = "webapps/phenotips/resources/cTAKES/"
+ "Chunker/chunk-model-claims-1-5.zip";
String chunkurl = new File(chunkfileres).toURI().toURL().toString();
String chunkp = "org.apache.ctakes.chunker.ae.DefaultChunkCreator";
ExternalResourceDescription chunkererd =
ExternalResourceFactory.createExternalResourceDescription(
"ChunkerModelFile", fileResClassImpl, chunkurl);
AnalysisEngineDescription chunkerDesc =
AnalysisEngineFactory.createPrimitiveDescription(
Chunker.class, tsd,
Chunker.CHUNKER_MODEL_FILE_PARAM, chunkfileres,
Chunker.CHUNKER_CREATOR_CLASS_PARAM, chunkp,
"ChunkerModel", chunkererd);
ExternalResourceFactory.createDependency(
chunkerDesc, "ChunkerModel", fileResClass);
//Chunk Adjuster NN
String nn = "NN";
String[] chunkPattern = new String[2];
chunkPattern[0] = nn;
chunkPattern[1] = nn;
AnalysisEngineDescription chunkAdjusterDesc =
AnalysisEngineFactory.createPrimitiveDescription(
ChunkAdjuster.class, null,
ChunkAdjuster.PARAM_CHUNK_PATTERN, chunkPattern,
ChunkAdjuster.PARAM_EXTEND_TO_INCLUDE_TOKEN, 1);
//chunk adjuster PN
String[] chunkPatternPN = new String[3];
chunkPatternPN[0] = nn;
chunkPatternPN[1] = "PN";
chunkPatternPN[2] = nn;
AnalysisEngineDescription chunkAdjusterPNDesc =
AnalysisEngineFactory.createPrimitiveDescription(
ChunkAdjuster.class, null,
ChunkAdjuster.PARAM_EXTEND_TO_INCLUDE_TOKEN, 2,
ChunkAdjuster.PARAM_CHUNK_PATTERN, chunkPatternPN);
//Lookup Annotators
//Overlap Annotators
AnalysisEngineDescription overlapdesc = getOverlapAnnotatorDesc();
//Copy Annotator - Lookup
AnalysisEngineDescription copyADesc = getCopyAnnotatorDesc();
//Dictionary Lookup
AnalysisEngineDescription dictlookupDesc = getDictlookupDesc();
//Final Analysis Engine Description
List<AnalysisEngineDescription> aedList =
new ArrayList<AnalysisEngineDescription>();
List<String> components = new ArrayList<String>();
aedList.add(simpleSegmentDesc);
components.add("SimpleSegmentAnnotator");
aedList.add(sentDetectDesc);
components.add("SentenceDetector");
aedList.add(tokenizerDesc);
components.add("TokenizerAnnotator");
aedList.add(contextDependentTokenizerDesc);
components.add("ContextDependentTokenizer");
aedList.add(posTagdesc);
components.add("POSTagger");
aedList.add(chunkerDesc);
components.add("Chunker");
aedList.add(chunkAdjusterDesc);
components.add("AdjustNounPhraseToIncludeFollowingNP");
aedList.add(chunkAdjusterPNDesc);
components.add("AdjustNounPhraseToIncludeFollowingPPNP");
aedList.add(overlapdesc);
components.add("OverlapAnnotator-Lookup");
aedList.add(copyADesc);
components.add("CopyAnnotator-Lookup");
aedList.add(dictlookupDesc);
components.add("Dictionary Lookup");
// Create the Analysis Engine
analysisEng = AnalysisEngineFactory.createAggregate(
aedList, components, null, null, null);
System.out.println("Analysis Engine Initialised");
} catch (Exception e) {
e.printStackTrace();
System.out.println(e.getMessage());
}
}
private AnalysisEngineDescription getDictlookupDesc()
throws ResourceInitializationException, MalformedURLException {
//Dictionary Lookup
ConfigurationParameter[] dictconfParam = new ConfigurationParameter[1];
ConfigurationParameter maxListSize =
ConfigurationParameterFactory.createPrimitiveParameter(
"maxListSize", Integer.class, "desc", false);
dictconfParam[0] = maxListSize;
Object[] dictconfVals = new Object[1];
dictconfVals[0] = 27;
String fileurl = new File("webapps/phenotips/resources/cTAKES/"
+ "DictionaryLookup/LookupDesc_csv_sample.xml")
.toURI().toURL().toString();
String dicturl = new File("webapps/phenotips/resources/cTAKES/"
+ "DictionaryLookup/dictionary1.csv")
.toURI().toURL().toString();
String drugurl = "webapps/phenotips/resources/cTAKES/"
+ "DictionaryLookup/drug_index";
String orangeurl = "webapps/phenotips/resources/cTAKES/"
+ "DictionaryLookup/OrangeBook";
Class<LuceneIndexReaderResourceImpl> luceneResClassImpl =
org.apache.ctakes.core.resource.LuceneIndexReaderResourceImpl.class;
String luceneResClassStr =
"org.apache.ctakes.core.resource.LuceneIndexReaderResource";
String fileResClassStr =
"org.apache.ctakes.core.resource.FileResource";
ExternalResourceDescription dictERD1 =
ExternalResourceFactory.createExternalResourceDescription(
"LookupDescriptorFile", fileResClassImpl, fileurl);
ExternalResourceDescription dictionaryERD2 =
ExternalResourceFactory.createExternalResourceDescription(
"DictionaryFileResource", fileResClassImpl, dicturl);
ExternalResourceDescription dictERD3 =
ExternalResourceFactory.createExternalResourceDescription(
"RxnormIndex", luceneResClassImpl, "",
"UseMemoryIndex", true, "IndexDirectory", drugurl);
ExternalResourceDescription dictERD4 =
ExternalResourceFactory.createExternalResourceDescription(
"OrangeBookIndex", luceneResClassImpl, "" ,
"UseMemoryIndex", true, "IndexDirectory", orangeurl);
Map<String, ExternalResourceDescription> dictMap =
new HashMap<String, ExternalResourceDescription>();
dictMap.put("LookupDescriptor", dictERD1);
dictMap.put("DictionaryFile", dictionaryERD2);
dictMap.put("RxnormIndexReader", dictERD3);
dictMap.put("OrangeBookIndexReader", dictERD4);
AnalysisEngineDescription dictAED =
AnalysisEngineFactory.createPrimitiveDescription(
DictionaryLookupAnnotator.class, null, null, null, null,
dictconfParam, dictconfVals, dictMap);
ExternalResourceDependency[] dictD = new ExternalResourceDependency[4];
ExternalResourceDependency dicterd1 =
new ExternalResourceDependency_impl();
dicterd1.setKey("LookupDescriptor"); dicterd1.setOptional(false);
dicterd1.setInterfaceName(fileResClassStr);
ExternalResourceDependency dicterd2 =
new ExternalResourceDependency_impl();
dicterd2.setKey("DictionaryFile"); dicterd2.setOptional(false);
dicterd2.setInterfaceName(fileResClassStr);
ExternalResourceDependency dicterd3 =
new ExternalResourceDependency_impl();
dicterd3.setKey("RxnormIndexReader"); dicterd3.setOptional(false);
dicterd3.setInterfaceName(luceneResClassStr);
ExternalResourceDependency dicterd4 =
new ExternalResourceDependency_impl();
dicterd4.setKey("OrangeBookIndexReader"); dicterd4.setOptional(false);
dicterd4.setInterfaceName(luceneResClassStr);
dictD[0] = dicterd1; dictD[1] = dicterd2;
dictD[2] = dicterd3; dictD[3] = dicterd4;
dictAED.setExternalResourceDependencies(dictD);
return dictAED;
}
private AnalysisEngineDescription getCopyAnnotatorDesc()
throws ResourceInitializationException {
//Copy Annotator - Lookup
TypeSystemDescription copyATsd = new TypeSystemDescription_impl();
copyATsd.addType("org.apache.ctakes.typesystem.type.CopySrcAnnotation",
null, "uima.tcas.Annotation");
copyATsd.addType("org.apache.ctakes.typesystem.type.CopyDestAnnotation",
null, "uima.tcas.Annotation");
ConfigurationParameter[] copyAconfParam = new ConfigurationParameter[3];
ConfigurationParameter srcObjClass =
ConfigurationParameterFactory.createPrimitiveParameter(
"srcObjClass", String.class, "desc", true);
ConfigurationParameter destObjClass =
ConfigurationParameterFactory.createPrimitiveParameter(
"destObjClass", String.class, "desc", true);
ConfigurationParameter dataBindMap =
ConfigurationParameterFactory.createPrimitiveParameter(
"dataBindMap", String.class, "desc", true);
dataBindMap.setMultiValued(true);
copyAconfParam[0] = srcObjClass;
copyAconfParam[1] = destObjClass;
copyAconfParam[2] = dataBindMap;
Object[] copyAconfVals = new Object[3];
copyAconfVals[0] = "org.apache.ctakes.typesystem.type.syntax.NP";
copyAconfVals[1] =
"org.apache.ctakes.typesystem.type.textspan.LookupWindowAnnotation";
String[] dataBindArray = new String[2];
dataBindArray[0] = "getBegin|setBegin";
dataBindArray[1] = "getEnd|setEnd";
copyAconfVals[2] = dataBindArray;
Class<CopyAnnotator> copyAclass = CopyAnnotator.class;
AnalysisEngineDescription copyAnnotatorDesc =
AnalysisEngineFactory.createPrimitiveDescription(
copyAclass, copyATsd, null, null, null,
copyAconfParam, copyAconfVals);
return copyAnnotatorDesc;
}
private AnalysisEngineDescription getOverlapAnnotatorDesc()
throws ResourceInitializationException {
ConfigurationParameter[] configurationParameters =
new ConfigurationParameter[5];
ConfigurationParameter actionType =
ConfigurationParameterFactory.createPrimitiveParameter(
"ActionType", String.class, "desc", true);
ConfigurationParameter aObjectClass =
ConfigurationParameterFactory.createPrimitiveParameter(
"A_ObjectClass", String.class, "desc", true);
ConfigurationParameter bObjectClass =
ConfigurationParameterFactory.createPrimitiveParameter(
"B_ObjectClass", String.class, "desc", true);
ConfigurationParameter overlaptype =
ConfigurationParameterFactory.createPrimitiveParameter(
"OverlapType", String.class, "desc", true);
ConfigurationParameter deleteaction =
ConfigurationParameterFactory.createPrimitiveParameter(
"DeleteAction", String.class, "desc", true);
deleteaction.setMultiValued(true);
configurationParameters[0] = aObjectClass;
configurationParameters[1] = bObjectClass;
configurationParameters[2] = overlaptype;
configurationParameters[3] = actionType;
configurationParameters[4] = deleteaction;
Object[] configVals = new Object[5];
configVals[0] =
"org.apache.ctakes.typesystem.type.textspan.LookupWindowAnnotation";
configVals[1] =
"org.apache.ctakes.typesystem.type.textspan.LookupWindowAnnotation";
configVals[2] = "A_ENV_B";
configVals[3] = "DELETE";
String[] deleteActionArray = new String[1];
deleteActionArray[0] = "selector=B";
configVals[4] = deleteActionArray;
Class<OverlapAnnotator> overlapAnnot = OverlapAnnotator.class;
AnalysisEngineDescription overlapdesc =
AnalysisEngineFactory.createPrimitiveDescription(overlapAnnot,
null, null, null, null,
configurationParameters, configVals);
return overlapdesc;
}
public final Map<String, ExtractedTerm> extract(String input)
throws ResourceInitializationException, AnalysisEngineProcessException {
Map<String, ExtractedTerm> finalTerms =
new HashMap<String, ExtractedTerm>();
JCas jCas = analysisEng.newJCas();
jCas.setDocumentText(input.toLowerCase());
analysisEng.process(jCas);
for(EventMention event : JCasUtil.select(jCas, EventMention.class)){
System.out.println(event.getCoveredText());
}
FSIndex<?> eventIndex =
jCas.getAnnotationIndex(org.apache.ctakes.typesystem.type.textsem.EventMention.type);
Iterator<?> eventIter = eventIndex.iterator();
EventMention firstevent = (EventMention) eventIter.next();
ExtractedTerm firstTerm = new ExtractedTerm();
firstTerm.setExtractedText(firstevent.getCoveredText());
firstTerm.setBeginIndex(firstevent.getBegin());
firstTerm.setEndIndex(firstevent.getEnd());
finalTerms.put(firstevent.getCoveredText(), firstTerm);