Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ryuih opened this issue May 30, 2019 · 2 comments

Comments

@ryuih
Copy link

ryuih commented May 30, 2019

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.

@hiroshinoji
Copy link
Contributor

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.

@ryuih
Copy link
Author

ryuih commented May 30, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants