Opinosis Text Summarization Web API

The Opinosis REST API is available to all academic researchers. You can use a command line tool like cURL to access the API or you can also easily access the API from any programming language using HTTP request and response libraries.

The nice thing with using the REST API version versus the Java jar file is that you can integrate the API into your code base, making evaluation and the ability to build on the API output much easier. Please follow these steps to start using the API:

Steps for Consuming API

  • Create a Mashape account (Mashape manages API keys and access) and subscribe to the basic plan of this API. The usage is free up to a certain limit.
  • You can use the examples below to start using the Opinosis Web API
  • You can use this page to learn how to set the opinosis parameters.

Example JSON Input & Output:

The Opinosis Web API accepts a JSON input and returns a JSON output.

Here is the sample request: JSON request.
This is the sample response for this request: JSON response 

{
    "results": [
        {
            "summary": "easy/jj to/to use/vb ,/, and/cc accurate/jj",
            "score": "3.69"
        },
        {
            "summary": "it/prp is/vbz always/rb accurate/jj",
            "score": "2.54"
        }
    ]
}

Example JSON Request using cURL

curl -X POST --include "https://rxnlp-opinosis.p.mashape.com/generateOpinosisSummaries" \
  -H "X-Mashape-Key: api_key" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  --data-binary "{'maxGap':'3','maxSentences':'5','minRedundancy':'2','doCollapse':'true','scoringFunction':'3','text':[{'sentence':'the/DT bathroom/NN was/VBD clean/JJ and/CC the/DT bed/NN was/VBD comfy/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD clean/JJ and/CC the/DT bed/NN was/VBD comfy/JJ ./.'},{'sentence':'the/DT bed/NN was/VBD comfy/JJ and/CC bathroom/NN was/VBD clean/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD too/RB dirty/JJ ./.'}]}" 

Example JSON Request using Python

# These code snippets use an open-source library. http://unirest.io/python
response = unirest.post("https://rxnlp-opinosis.p.mashape.com/generateOpinosisSummaries",
  headers={
    "X-Mashape-Key": "API-Key",
    "Content-Type": "application/json",
    "Accept": "application/json"
  },
  params=("{'maxGap':'3','maxSentences':'5','minRedundancy':'2','doCollapse':'true','scoringFunction':'3','text':[{'sentence':'the/DT bathroom/NN was/VBD clean/JJ and/CC the/DT bed/NN was/VBD comfy/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD clean/JJ and/CC the/DT bed/NN was/VBD comfy/JJ ./.'},{'sentence':'the/DT bed/NN was/VBD comfy/JJ and/CC bathroom/NN was/VBD clean/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD too/RB dirty/JJ ./.'}]}")
)

Example JSON Request using PHP

// These code snippets use an open-source library. http://unirest.io/php
$response = Unirest\Request::post("https://rxnlp-opinosis.p.mashape.com/generateOpinosisSummaries",
  array(
    "X-Mashape-Key" => "API-Key",
    "Content-Type" => "application/json",
    "Accept" => "application/json"
  )
  "{'maxGap':'3','maxSentences':'5','minRedundancy':'2','doCollapse':'true','scoringFunction':'3','text':[{'sentence':'the/DT bathroom/NN was/VBD clean/JJ and/CC the/DT bed/NN was/VBD comfy/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD clean/JJ and/CC the/DT bed/NN was/VBD comfy/JJ ./.'},{'sentence':'the/DT bed/NN was/VBD comfy/JJ and/CC bathroom/NN was/VBD clean/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD dirty/JJ ./.'},{'sentence':'the/DT bathroom/NN was/VBD too/RB dirty/JJ ./.'}]}"
);