jigg icon indicating copy to clipboard operation
jigg copied to clipboard

Question about the output format when we use annotate function on JAVA development environment

Open ryuih opened this issue 5 years ago • 2 comments

Hi, We faced an issue when we use annotate function on java development environment. The symtom is as following.

  • we used 0.8.0 version of JAR file you shared on this repository.
  • we set properties as below before we call annotate function.
       import jigg.pipeline.Pipelie;
       import java.util.properties;
       ...
       Properties prop = new Properties();
       prop.setProperty("annotators", "ssplit,mecab,cabocha");
       prop.setProperty("outpurFormat", "json");
  • and we call annotate as follwoing.
       ...
       pipeline = new Pipeline(prop)
       annotation = pipeline.annotate(msg)
  • The output format of returned value annotation is always XML not JSON. However we set the property as JSON.
  • For in case, we checked the property value of outputFormat we set as following. But, it returned JSON always as we set.
       ...
       System.out.println(pipeline.outputFormat();
       ...

Based on the result, it seems that there are some inconsistency between set value of outputFormat on pipeline when we use your JAR file on JAVA development environment. Could you kindly look on this? Please let us know if JAVA is not supported yet.

Finally, for your references, I add python code we have used. Under the python environment, The output format from annotate function didn't show any issues.

  • The example of python code for using annotate
       from pyjigg import Pipeline
       from subprocess import Popen
       ...
       # Making a child process for the pipeline server
       self.proc = Popen(["java", "-Xmx4g", "-cp", '/opt/pipeline/jigg-0.8.0/jigg-0.8.0.jar',  'jigg.pipeline.PipelineServer'])
       ...
       # Initializing Pipeline
       self.pipeline = Pipeline('http://127.0.0.1:8080')
       # call the annotate function
       self.annotation = self.pipeline.annotate(msg, properties={'annotators': 'ssplit,mecab,cabocha', 'outputFormat': 'json'})

Thank you.

ryuih avatar May 30 '19 04:05 ryuih

Thanks for using Jigg. The problem is that the outpurFormat option only makes sense for command-line usage. This option changes the format of the output file only and not change the format of an internal annotated object, which is always Scala XML Node object.

Currently, we do not support to convert an XML Node to a JSON object. Sorry for the inconvenience. Or if you want to get the output in Jigg's JSON output format, this can be done by calling jigg.util.JSONUtil.toJSONFromNode(node: Node): String to the output of annotate(). However, this method only supports converting to a string directly from an XML. We may support conversion to a JSON object if there is a request.

hiroshinoji avatar May 30 '19 04:05 hiroshinoji

Thank you for your prompt response. Let us discuss internally and we would like to take the next action if needed.

Thank you so much.

ryuih avatar May 30 '19 05:05 ryuih