-
Notifications
You must be signed in to change notification settings - Fork 28
API usage
Giannis Daras edited this page Aug 13, 2018
·
4 revisions
NLPBuddy supports an API which you call and take advantage of the following features:
- Language identification (performed using langid library).
- Text tokenization.
- Sentence splitting.
- Lemmatization.
- Part of Speech tags identification.
- Named Entity Recognition (Location, Person, Organization).
- Text summarization (uses Gensim's implementation of the TextRank algorithm).
- Keywords extraction.
- For the Greek language:
- Text classification among the following categories: Sports, Science, World News, Greek News, Environment, Politics, Art, Health, Science. The Greek classifier is built with FastText and is trained in 20.000 articles labeled in these categories. Accuracy reaches 90%,
- Text subjectivity analysis.
- Emotion analysis. It detects the main text emotion among the following emotions: Anger, Disgust, Fear, Happiness, Sadness, Surprise.
- Lexical Attributes.
- Noun chunks.
Our goal is to provide all these functionalities with a single API call so anybody can use NLPBuddy for any purpose that fits his needs.
This section provides an example call to the API and a sample response.
Example:
user@user~$ curl -H "Content-Type: application/json" -XPOST --data '{"text": "Indonesia earthquake: 14 dead on tourist island of Lombok.A powerful earthquake has struck a popular tourist destination in Indonesia, killing at least 14 people."}' https://nlpbuddy.io/api/analyze
Or in python
import requests
url = 'https://nlp.wordgames.gr/api/analyze'
text = """
Indonesia earthquake: 14 dead on tourist island of Lombok.
A powerful earthquake has struck a popular tourist destination in Indonesia, killing at least 14 people."
"""
res = requests.post(url, json={'text': text})
res.json()
Example response:
{"language": "English", "named_entities": {"person": [], "organization": ["Lombok"], "location": ["Indonesia"]}, "part_of_speech": {"verbs": ["has", "struck", "killing"], "adjectives": ["dead", "powerful", "popular"], "nouns": ["earthquake", "tourist", "island", "destination", "people"]}, "lemmatized_sentences": ["indonesia earthquake : 14 dead on tourist island of lombok .", "a powerful earthquake have strike a popular tourist destination in indonesia , kill at least 14 people ."], "lexical_attrs": {"emails": [], "urls": [], "nums": ["14", "14"]}, "sentences": ["Indonesia earthquake: 14 dead on tourist island of Lombok.", "A powerful earthquake has struck a popular tourist destination in Indonesia, killing at least 14 people."], "keywords": "indonesia, earthquake, tourist, powerful, kill, strike, popular, people, lombok, dead", "noun_chunks": ["tourist island", "Lombok", "A powerful earthquake", "a popular tourist destination", "Indonesia", "at least 14 people"], "text": "<span class=\"tooltip\" data-content=\"POS: PROPN<br> LEMMA: indonesia<br> DEP: compound\" style=\"color: red;\" >Indonesia </span><span class=\"tooltip\" data-content=\"POS: NOUN<br> LEMMA: earthquake<br> DEP: dep\" >earthquake </span><span class=\"tooltip\" data-content=\"POS: PUNCT<br> LEMMA: :<br> DEP: punct\" >: </span><span class=\"tooltip\" data-content=\"POS: NUM<br> LEMMA: 14<br> DEP: nummod\" style=\"color: red;\" >14 </span><span class=\"tooltip\" data-content=\"POS: ADJ<br> LEMMA: dead<br> DEP: ROOT\" >dead </span><span class=\"tooltip\" data-content=\"POS: ADP<br> LEMMA: on<br> DEP: prep\" >on </span><span class=\"tooltip\" data-content=\"POS: NOUN<br> LEMMA: tourist<br> DEP: compound\" >tourist </span><span class=\"tooltip\" data-content=\"POS: NOUN<br> LEMMA: island<br> DEP: pobj\" >island </span><span class=\"tooltip\" data-content=\"POS: ADP<br> LEMMA: of<br> DEP: prep\" >of </span><span class=\"tooltip\" data-content=\"POS: PROPN<br> LEMMA: lombok<br> DEP: pobj\" style=\"color: red;\" >Lombok </span><span class=\"tooltip\" data-content=\"POS: PUNCT<br> LEMMA: .<br> DEP: punct\" >. </span><span class=\"tooltip\" data-content=\"POS: DET<br> LEMMA: a<br> DEP: det\" >A </span><span class=\"tooltip\" data-content=\"POS: ADJ<br> LEMMA: powerful<br> DEP: amod\" >powerful </span><span class=\"tooltip\" data-content=\"POS: NOUN<br> LEMMA: earthquake<br> DEP: nsubj\" >earthquake </span><span class=\"tooltip\" data-content=\"POS: VERB<br> LEMMA: have<br> DEP: aux\" >has </span><span class=\"tooltip\" data-content=\"POS: VERB<br> LEMMA: strike<br> DEP: ROOT\" >struck </span><span class=\"tooltip\" data-content=\"POS: DET<br> LEMMA: a<br> DEP: det\" >a </span><span class=\"tooltip\" data-content=\"POS: ADJ<br> LEMMA: popular<br> DEP: amod\" >popular </span><span class=\"tooltip\" data-content=\"POS: NOUN<br> LEMMA: tourist<br> DEP: compound\" >tourist </span><span class=\"tooltip\" data-content=\"POS: NOUN<br> LEMMA: destination<br> DEP: dobj\" >destination </span><span class=\"tooltip\" data-content=\"POS: ADP<br> LEMMA: in<br> DEP: prep\" >in </span><span class=\"tooltip\" data-content=\"POS: PROPN<br> LEMMA: indonesia<br> DEP: pobj\" style=\"color: red;\" >Indonesia </span><span class=\"tooltip\" data-content=\"POS: PUNCT<br> LEMMA: ,<br> DEP: punct\" >, </span><span class=\"tooltip\" data-content=\"POS: VERB<br> LEMMA: kill<br> DEP: advcl\" >killing </span><span class=\"tooltip\" data-content=\"POS: ADV<br> LEMMA: at<br> DEP: advmod\" style=\"color: red;\" >at </span><span class=\"tooltip\" data-content=\"POS: ADV<br> LEMMA: least<br> DEP: advmod\" style=\"color: red;\" >least </span><span class=\"tooltip\" data-content=\"POS: NUM<br> LEMMA: 14<br> DEP: nummod\" style=\"color: red;\" >14 </span><span class=\"tooltip\" data-content=\"POS: NOUN<br> LEMMA: people<br> DEP: dobj\" >people </span><span class=\"tooltip\" data-content=\"POS: PUNCT<br> LEMMA: .<br> DEP: punct\" >. </span>", "text_tokenized": ["Indonesia", "earthquake", ":", "14", "dead", "on", "tourist", "island", "of", "Lombok", ".", "A", "powerful", "earthquake", "has", "struck", "a", "popular", "tourist", "destination", "in", "Indonesia", ",", "killing", "at", "least", "14", "people", "."], "summary": ""}