Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 14810200C70 for ; Thu, 4 May 2017 10:11:49 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1308F160BB0; Thu, 4 May 2017 08:11:49 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 590A9160B9F for ; Thu, 4 May 2017 10:11:48 +0200 (CEST) Received: (qmail 63225 invoked by uid 500); 4 May 2017 08:11:47 -0000 Mailing-List: contact user-help@uima.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@uima.apache.org Delivered-To: mailing list user@uima.apache.org Delivered-To: moderator for user@uima.apache.org Received: (qmail 20351 invoked by uid 99); 4 May 2017 07:49:55 -0000 X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.174 X-Spam-Level: ** X-Spam-Status: No, score=2.174 tagged_above=-999 required=6.31 tests=[DKIM_ADSP_CUSTOM_MED=0.001, FROM_MISSPACED=0.001, NML_ADSP_CUSTOM_MED=1.2, SPF_SOFTFAIL=0.972] autolearn=disabled MIME-Version: 1.0 Message-ID: Subject: Using REST api with UIMA References: From: "Luca Toldo" In-Reply-To: Content-Type: text/plain; charset="iso-8859-1" x-ponymail-sender: 74e6686617f3aa47a64d7b1d024fc6f80fda271e Date: Thu, 04 May 2017 07:49:49 -0000 x-ponymail-agent: PonyMail Composer/0.2 To: X-Mailer: LuaSocket 3.0-rc1 archived-at: Thu, 04 May 2017 08:11:49 -0000 The following Java code (inspired from http://stackoverflow.com/questions/40838999/getting-output-in-json-format-in-uima ) import java.io.*; import org.apache.uima.fit.factory.JCasFactory; import org.apache.uima.jcas.JCas; import org.apache.uima.cas.CAS; import org.apache.uima.json.JsonCasSerializer; public class test { public static void main(String [] args ) throws IOException { try { String note="Lorem ipsum incididunt ut labore et dolore magna aliqua"; JCas jcas = JCasFactory.createJCas(); jcas.setDocumentText(note); JsonCasSerializer jcs = new JsonCasSerializer(); jcs.setPrettyPrint(true); StringWriter sw = new StringWriter(); CAS cas = jcas.getCas(); jcs.serialize(cas, sw); System.out.println(sw.toString()); } catch (Exception ex) { } } } delivers properly formatted JSON CAS: {"_context" : { "_types" : { "DocumentAnnotation" : {"_id" : "uima.tcas.DocumentAnnotation", "_feature_types" : {"sofa" : "_ref" } }, "Sofa" : {"_id" : "uima.cas.Sofa", "_feature_types" : {"sofaArray" : "_ref" } }, "Annotation" : {"_id" : "uima.tcas.Annotation", "_feature_types" : {"sofa" : "_ref" }, "_subtypes" : ["DocumentAnnotation" ] }, "AnnotationBase" : {"_id" : "uima.cas.AnnotationBase", "_feature_types" : {"sofa" : "_ref" }, "_subtypes" : ["Annotation" ] }, "TOP" : {"_id" : "uima.cas.TOP", "_subtypes" : ["AnnotationBase", "Sofa" ] } } }, "_views" : { "_InitialView" : { "DocumentAnnotation" : [ {"sofa" : 1, "begin" : 0, "end" : 55, "language" : "x-unspecified" } ] } }, "_referenced_fss" : { "1" : {"_type" : "Sofa", "sofaNum" : 1, "sofaID" : "_InitialView", "mimeType" : "text", "sofaString" : "Lorem ipsum incididunt ut labore et dolore magna aliqua" } } } How to deserialize that back into CAS object ?