jsonnlpuimactakesuimafit

Setup ctakes project with JSON output


I am trying to setup a ctakes application which gives a JSON output. I have taken the ctakes module from https://codeload.github.com/apache/ctakes/zip/ctakes-4.0.0

I am trying to convert jcas object to json as below

                CAS cas = jcas.getCas();

                JsonCasSerializer jcs = new JsonCasSerializer();
                jcs.setPrettyPrint(true);

                StringWriter sw = new StringWriter();
                jcs.serialize(cas, sw);

                System.out.println(sw.toString());

But it seems in the downloaded project setup, there is no dependency for JsonCasSerializer. I have googled and found that we need to add uimaj-json jar in my project. I have added the same as external dependency (uimaj-json-3.1.1)- I have tried different versions as well. But I am getting multiple issues after adding the same jar into the project.

My understanding is that while adding the uimaj-json jar, my POM already contains the below dependency and the newly included uimaj-json jar has a lot of dependencies which is not in compatible with my current application uimj-core version.

    <dependency>
        <groupId>org.apache.uima</groupId>
        <artifactId>uimaj-core</artifactId>
        <version>2.4.0</version>
    </dependency>

    <dependency>
        <groupId>org.apache.uima</groupId>
        <artifactId>uimafit-core</artifactId>
        <version>2.1.0</version>
    </dependency>

Kindly help.

Do we have any sample ctakes project which contains jcas to json conversion?


Solution

  • Issue resolved!

    It was a version mismatch between uimaj-core and uimaj-json. I was mixing the versions of uimaj-core and uimaj-json. You should use both of same version. I have used 2.8.1 for both.

    Please refer: https://www.mail-archive.com/dev@ctakes.apache.org/msg03498.html