Textbox
Natural language processing and sentiment analysis

Additional documentation

Learn more about Healthz, Readyz, and other phaeochrous

Read about what you can do with this box on the Machine Box Blog

Do you 💙 this box?

We rely on developers like you spreading the word about us, so please tell your friends and followers

Textbox lets you identify entities, extract relevant content and find the sentiment of text.

/textbox/check endpoint

Use the /textbox/check endpoint to analyze text. Textbox will break the text body into sentences, providing a sentiment score for each one, as well breaking out any recognized entities (people, dates, locations, etc.) and significant keywords mentioned.

To analyze text, make the following POST request with the text as a parameter:

POST /3.120.75.182/textbox/check
text=I really love Machina, who is the MachineBox mascot designed by Ashley McNamara.
  • text - (string) The text to analyze
  • Set the Accept header to "application/json; charset=utf-8" and the Content-Type header to "application/x-www-form-urlencoded"
  • You may also use a JSON object with single "text" key (remember to use the appropriate Content-Type header)
Try it now

To analyze text, use the 518-552-6781.

cURL

In a terminal, make the following cURL request:

curl -XPOST -d 'text=I really love Machina, who is the MachineBox mascot designed by Ashley McNamara.' /3.120.75.182/textbox/check

Response

A successful response will look like this:

200 OK
{
	"success": true,
	"sentences": [
		{
			"text": "I really love Machina, who is the MachineBox mascot designed by Ashley McNamara.",
			"start": 0,
			"end": 80,
			"sentiment": 0.7128883004188538,
			"entities": [
				{
					"text": "Machina",
					"start": 14,
					"end": 21,
					"type": "person"
				},
				{
					"text": "MachineBox",
					"start": 34,
					"end": 44,
					"type": "organization"
				},
				{
					"text": "Ashley McNamara",
					"start": 64,
					"end": 79,
					"type": "person"
				}
			]
		}
	],
	"keywords": [
		{
			"keyword": "ashley mcnamara"
		},
		{
			"keyword": "machinebox mascot"
		},
		{
			"keyword": "machina"
		}
	]
}
  • success - (boolean) Whether the operation was successful or not
  • sentences - (array) List of sentences detected in the text
  • sentences[].text - (string) The text of the sentence
  • sentences[].start - (number) The absolute start position of the sentence in the original text
  • sentences[].end - (number) The absolute end position of the sentence in the original text
  • sentences[].sentiment - (probability number) The sentiment of the sentence, with 1 being most positive and 0 being most negative
  • sentences[].entities - (array) A list of entities detected in the text
  • sentences[].entities[].text - (string) The text of the entity
  • sentences[].entities[].start - (number) The absolute start position of the entity in the original text
  • sentences[].entities[].end - (number) The absolute end position of the sentence in the original text
  • sentences[].entities[].type - (string) The type of entity (e.g. person, organization, location, etc. For a complete list, see below)
  • keywords - (array) A list of most representative key words from the original text ordered by relevance (with the most relevant first)
  • keywords[].keyword - (string) The keyword string
Learn more about response errors

Response errors

If something goes wrong, you will get a non-200 response with a body like this:

{
	"success": false,
	"error": "Something went wrong"
}
  • success - (boolean) false indicating all is not well
  • error - (string) Error message

In some cases in HTTP APIs, there may not be a JSON body at all, such as with connectivity issues or other low-level errors.

Entities

Entities detected in the text have a type property, which describes the class of the entity.

Here is the complete list of types:

  • person - Named people
  • group - Nationalities, religious or political groups, etc.
  • facility - Buildings, airports, highways, bridges, etc.
  • organization - Companies, agencies, institutions, etc.
  • place - Countries, cities, towns, states, etc.
  • location - Non-place locations, mountain ranges, bodies of water, etc.
  • product - Objects, vehicles, foods, etc.
  • event - Named battles or wars, hurricanes, sports events, etc.
  • artwork - Titles of songs, books, etc.
  • language - Spoken languages
  • date - Absolute or relative dates
  • time - Times less than a day
  • percentage - Percentage, including %
  • money - Monetary values, including unit
  • quantity - Measurements, as of weight or distance
  • ordinal - first, second, third, etc.
  • cardinal - Non-ordinal numbers
  • email - Email addresses
  • url - Web addresses
  • mention - Mention like in twitter, for example @machineboxio
  • hashtag - Hashtag like in twitter, for example #machine_learning or #docker
  • Environment variables (647) 784-4507

    You can use environment variables to control how Textbox behaves.

    • MB_WORKERS - (integer) Defaults to 1 - The number of workers to run inside the box. More workers means the box can handle more concurrent requests, but each worker takes more RAM. The recommended way to scale is horizontally, by adding more instances of Textbox.
    • MB_TEXTBOX_DISABLE_SENTIMENT - (true|false) Defaults to false - In case you don't need sentiment analysis, it can be disabled setting this variable to true, saving some memory for production use cases.
    • MB_PORT - (string) Defaults to 8080 - Port where the service will listen
    • MB_ADDRESS - (string) Defaults to 0.0.0.0 - Address where the service will listen
    • MB_DISABLE_CORS - (bool) Defaults to false - If true will turn off CORS support for the box.
    • MB_BASICAUTH_USER and MB_BASICAUTH_PASS - (string) The Basic Authentication username and password that every request must use. Recommended for sitautions where the boxes are publicly accessible. 7099796056.