Demo


Description

Usage

Input

Post a block of text as a value of the parameter text, as follows:

curl -d text="..." http://bionlp.dbcls.jp/enju_rest/
or
curl -H "content-type:application/json" -d '{"text":"..."}' http://bionlp.dbcls.jp/enju_rest/

Output

You will get the parsing results in the PubAnnotation JSON format.

Interface Synopsis (Ruby on Sinatra)

require 'sinatra'
require 'json'

before do
  if request.content_type && request.content_type.downcase == 'application/json'
    body = request.body.read
    json_params = JSON.parse body, :symbolize_names => true unless body.empty?
    params.merge!(json_params) unless json_params.nil?
  end
end

post '/' do
  begin
    text = params[:text]
    raise ArgumentError, "'text' value needs to be supplied." if text.nil?
    ...
    headers \
      'Content-Type' => 'application/json'
    body annotations.to_json

  rescue ArgumentError => e
    headers \
      'Content-Type' => 'application/json'
    status 400
    {message:e.message}.to_json

  rescue IOError => e
    headers \
      'Content-Type' => 'application/json'
    status 502
    {message:e.message}.to_json
  end
end