Sai, here's an example from what I'm using.  I'm using multiple threads to
process documents concurrently, if you're not interested in that you can
ignore the CASPool stuff and just instantiate a CAS directly.  You *do*
want to re-use CAS instances though, they're very expensive to create.

// the name of the analysis engine xml file
String pipelineFileName =
./desc/ctakes-clinical-pipeline/desc/analysis_engine/AggregatePlaintextUMLSProcessor.xml;

// the number of simultaneous pipelines to support
int threadCount = 3;

// load the pipeline specifier
XMLInputSource input = new XMLInputSource(new File(pipelineFileName));
ResourceSpecifier pipelineSpecifier =
UIMAFramework.getXMLParser().parseResourceSpecifier(input);

// create the analysis engine for the pipeline and allocate some CAS
AnalysisEngine analysisEngine =
UIMAFramework.produceAnalysisEngine(pipelineSpecifier, threadCount, 0);
CasPool casPool = new CasPool(threadCount, analysisEngine);



// for each document...
CAS cas = casPool.getCas();
try
{
    // process the document
    cas.reset();
    cas.setDocumentLanguage("en");
    cas.setDocumentText(textToAnalyze);

    // then consume the assertions of whatever type you're interested in
    Type eventType =
cas.getTypeSystem().getType("org.apache.ctakes.typesystem.type.textsem.EventMention");

    FSIterator<FeatureStructure> iter =
cas.getIndexRepository().getAllIndexedFS(eventType);
    while (iter.hasNext())
    {
        FeatureStructure fs = iter.next();

        // extract information from the assertion
    }
}
finally
{
    casPool.releaseCas(cas);
}

On Tue, Jun 16, 2015 at 2:37 AM, Sai Anuroop <[email protected]>
wrote:

> Hi All,
>
> I want to run cTAKES CPE by choosing a Collection Reader,AE and CAS
> Consumer from java directly so that i can reduce the time taken for
> processing text documents.Please can anyone explain how to do this by
> giving an example java code or point out to any resources.
>
> Regards,
>
> Vetsa Sai Anuroop
>
>
>


-- 
.........................................................
*Lance Eason*
Iodine Software
Vice President of Engineering
[email protected]
512.785.5195 office | 801.203.8987 fax
.........................................................

Reply via email to