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 E3AE2200C70 for ; Thu, 4 May 2017 16:37:41 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id E25F0160BB0; Thu, 4 May 2017 14:37:41 +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 303BC160B9F for ; Thu, 4 May 2017 16:37:41 +0200 (CEST) Received: (qmail 66257 invoked by uid 500); 4 May 2017 14:37:40 -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 Received: (qmail 66242 invoked by uid 99); 4 May 2017 14:37:40 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 04 May 2017 14:37:40 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id A53BA188A22 for ; Thu, 4 May 2017 14:37:39 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.002 X-Spam-Level: X-Spam-Status: No, score=-0.002 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id y0aWZsRQf6OL for ; Thu, 4 May 2017 14:37:37 +0000 (UTC) Received: from gateway32.websitewelcome.com (gateway32.websitewelcome.com [192.185.145.171]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 5FD555F1BA for ; Thu, 4 May 2017 14:37:37 +0000 (UTC) Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 72F1A1113EB for ; Thu, 4 May 2017 09:37:27 -0500 (CDT) Received: from gator3253.hostgator.com ([198.57.247.217]) by cmsmtp with SMTP id 6HsedMn12LwLw6Hsed1YK6; Thu, 04 May 2017 09:37:20 -0500 Received: from yktgi01e0-s5.watson.ibm.com ([129.34.20.19]:59323 helo=[9.2.54.87]) by gator3253.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.87) (envelope-from ) id 1d6Hsk-000RvZ-Jk for user@uima.apache.org; Thu, 04 May 2017 09:37:26 -0500 Subject: Re: Using REST api with UIMA To: user@uima.apache.org References: From: Marshall Schor Message-ID: <05c1546e-8093-0cb9-66a6-3bb6b2c32d11@schor.com> Date: Thu, 4 May 2017 10:37:36 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator3253.hostgator.com X-AntiAbuse: Original Domain - uima.apache.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - schor.com X-BWhitelist: no X-Source-IP: 129.34.20.19 X-Exim-ID: 1d6Hsk-000RvZ-Jk X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: yktgi01e0-s5.watson.ibm.com ([9.2.54.87]) [129.34.20.19]:59323 X-Source-Auth: msa+schor.com X-Email-Count: 4 X-Source-Cap: bWlzY2hvcjttaXNjaG9yO2dhdG9yMzI1My5ob3N0Z2F0b3IuY29t archived-at: Thu, 04 May 2017 14:37:42 -0000 The core UIMA support has not (yet) implemented a deserializer back into CAS form, for this. The main idea behind CAS -> JSON conversion was to provide the CAS info to JSON Consumers. We have multiple other serializations (CAS -> XMI, etc.) that are designed for "transport" and include deserializers. Of course, it is quite possible to create an addition to UIMA which can deserialize the JSON format(s) - that just hasn't yet been done. Contributions welcome! -Marshall On 5/4/2017 3:49 AM, Luca Toldo wrote: > 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 ? >