Extract the most important information from large amount of texts.
Generate extractive summaries with the most relevant sentences of a news article.
Get an overall picture of the health of your brand, a quick snapshot you can use as a key performance indicator.
Prioritize which pieces of feedback need more attention from your customer communication channles.
Identify actionable insights from business communications.
Automatically identify harmful language from user-generated content or online communities.
# pip install -U codeq-nlp-api
# Call the API
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
# If pipeline is None, the API will execute all NLP modules
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Print the output
print(document.pretty_print())
Copy code
White House chief of staff Mick Mulvaney and the president’s son-in-law and senior White House adviser Jared Kushner are trying to take the lead on the West Wing’s response to the impeachment inquiry, officials said. Mulvaney has led several meetings this week with White House officials on impeachment, which have included Kushner, a key conduit with the president’s re-election campaign. The Trump campaign has rolled out three impeachment-related ads in the last week, all echoing Trump’s language on corruption and accusing Democrats of leading a coup to remove him from office.
https://www.washingtontimes.com/news/2021/jan/8/sadiq-khan-declares-major-incident-over-covid-19/
https://www.cbsnews.com/news/times-square-new-years-eve-nypd-officers-injured-suspect-shot-2023-01-01/
My friend had the original SoundLink and it was phenomenal. So I thought I would have to get one. However, this new speaker sounds very bad!
The Nintendo Switch is a great console. My issue is that games are ridiculously expensive. So many are over priced. Also, the monthly subscription only gives you access to old fashion 80s games.
I'm writing because I'm worried about my retirement plan. I'm about to retire in a year but this nasty market crash has slashed my life investments in half. This is a disaster! What do you suggest I should do now? I really need your advice because I'm starting to panic. Please let me know as soon as possible.
I have an urgent meeting this morning with the risk mitigations guys. Could you please send me the report you showed me yesterday about our emerging markets positions as soon as possible? Also, could you please tell Katie to come by my office this afternoon? I'd like to get her take on how next year's estimates are looking right now. By the way and before I forget, I promise I'll let you know about the birthday party this weekend asap.
What you just said is utterly retarded. Illegals just take good American jobs and are mostly criminals and rapists. Do not come to the US illegally or we'll have to teach you a lesson. Go back to your shitty country, Mexican!
Oi freak why don't you shut up! You're just another sand nigger trying to destroy America. Take you BLM bullshit and shove it up your nasty ass. Go fuck yourself, mudslime!
The hotel location is perfect. Located directly across from the metro so it is easy to get everywhere. But the rooms are in great need of an upgrade. I had a king room with no view, and poor lighting. The color scheme in the room was drab and kind of depressing.
I really loved this "device" the first few months I had it and was ready to purchase more in this collection (Big Echo, Show, etc.) However, about 6 weeks ago my echo lost the ability to pause and play, which is very frustrating.
I just love it when people make plans for me without actually including me in this process
This evil snake is Muslim Hussein Obama & the Muslim Brotherhood's plant in Washington, just like Muslim Hussein Obama was a plant for The NWO Globalist Socialist Elitist demoKKKrats
Illegals just take good American jobs and are mostly criminals and rapists.
Hello John, we need to finish the templates this week. Send me your changes as soon as you can. Also let me know your available times for the meeting before the end of the next week.
Hello John, this is a reminder of the company's Christmas party. Please confirm your assistance within the next two weeks.
Hello John! How are you? Please send me your changes as soon as you can. Thank you!
White House chief of staff Mick Mulvaney and the president’s son-in-law and senior White House adviser Jared Kushner are trying to take the lead on the West Wing’s response to the impeachment inquiry, officials said. Mulvaney has led several meetings this week with White House officials on impeachment, which have included Kushner, a key conduit with the president’s re-election campaign. The Trump campaign has rolled out three impeachment-related ads in the last week, all echoing Trump’s language on corruption and accusing Democrats of leading a coup to remove him from office.
A gunman who shot dead a uniformed officer outside the Biloxi police station remained on the run on Monday, the subject of an intense manhunt along Mississippi’s Gulf coast. It was unclear what prompted the killing of Officer Robert McKeithen, a 23-year veteran who was scheduled to retire this year. Biloxi’s police chief, John Miller, said police did not know if he was targeted, or the victim of a random act. The animal that did this is still on the run, Miller told reporters. We’re going to do everything within our power to bring him to justice for Robert and his family. Authorities say the man approached McKeithen in the station’s parking lot on Sunday night and shot him multiple times, either before or after coming inside the station.
https://edition.cnn.com/2021/01/07/tech/capitol-riots-cybersecurity/index.html
https://techcrunch.com/2021/01/07/youtube-election-strikes/
Tesla almost died earlier this year, Elon Musk said in an interview with Axios that aired on HBO. Musk said the company was "bleeding money like crazy" as it worked through the Model 3 production ramp in the spring and summer. He said the company "came within single-digit" weeks of death before it was able to meet its Model 3 production goals.
The DOSS are great affordable speakers. I'll update my review in a few weeks! But my initial reaction is WOW. For the price the sound is great. The base is not bad either.
Apple buys edge-based AI startup Xnor.ai for a reported $200M.
Well-known liberal billionaire George Soros said he believes Facebook will work with Trump to get the president re-elected.
The quick brown fox jumped over the lazy dog.
Generates a list of values for each sentence indicating the predicted sentiment label.
sentence.sentiments
sentence.scores['sentiment']
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Positive
Neutral
Negative
Generates a list of values for each sentence indicating the predicted emotion label.
sentence.emotions
sentence.scores['emotion']
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Anger
Disgust/Dislike
Fear
Joy/Like
Sadness
Surprise
Excitement
Angst
No emotion
Generates a label predicting if a sentence is sarcastic or not.
sentence.sarcasm
sentence.scores['sarcasm']
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Sarcastic
Non-sarcastic
Generates a list of values for each sentence indicating the types of abuse detected.
sentence.abuse
sentence.scores['abuse']
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Offensive
Obscene/scatologic
Threatening/hostile
Insult
Hate speech/racist
Unknown abuse
Non-abusive
Generates a list of tags indicating the predicted speech acts of a sentence.
sentence.speech_acts
sentence.scores['speechact']
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
statement
Conveys information from the speaker to the hearer.
command/request
Attempts to either impart an obligation on the hearer to do a certain task for the speaker or which asks the hearer to do such a task.
question
Imparts a request the hearer to give some type of information to the speaker.
desire/need/hope
Reports something that the speaker wants, needs, or hopes for, whether or not the hearer is involved or has the power to help realize this desire, need, or hope.
commitment/promise
Expresses that the speaker plans to do some stated action in the future.
evaluation
Speaker's subjective opinion about one or more people, things, events or other entities.
speculation
Speaker's uncertain belief about some event or state of affairs of the world, whether possible event/state of affairs would be in the past, present, or future.
suggestion/recommendation
Speaker's belief about the optimal course of action for some party, whether the group includes the hearer or not.
regret
The speaker would prefer that some past event or state of affairs had not occurred the way it did, whether or not the situation was caused by the speaker.
greeting
Expresses acknowledgement to the hearer, often in a conventionalized way, often in the event of the speaker and the hearer meeting, parting company, or acknowledging some recognized holiday.
permission
Expresses to the hearer that the speaker allows the hearer to perform some action, and presupposes that the speaker believes that they have the authority to grant or withhold such permission.
offer
The speaker is willing to give some object to, or do some task for, the hearer, if the hearer so desires and will accept the offer.
gratitude
The speaker is thankful for something that some party, often but not always the hearer, has done or was involved with, often in a conventionalized way.
congratulation
The speaker is proud of the hearer for some accomplishment.
disagreement
The speaker disagrees with something that the hearer has recently said.
apology/condolence
Expresses remorse for something that the speaker has done or failed to do, or which commiserates with some misfortune that the hearer has experienced.
agreement
The speaker agrees with something that the hearer has recently said.
well-wishing
The speaker hopes that the hearer will have good fortune in the future, often in a conventionalized way.
warning
Expresses that some misfortune may, or definitely will, befall some party, often the hearer but some times a third party or the speaker; sometimes the misfortune is unconditional, but sometimes the warning expresses that misfortune will occur unless someone performs or refrains from performing a certain action.
introduction
Acts to bring the hearer in acquaintance with some party, either the speaker or some third party.
unknown speech act
A sentence which cannot be classified in any of the above ways, sometimes because it cannot be interpreted; sometimes because it is in a different language than the one (English) that this classifier was built for; sometimes because it is a short interjection; etc.
Generates a list of tags indicating the predicted type of question, if a sentence is classified as such.
sentence.question_types
sentence.scores['question']
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
qy - Yes/No question
qo - Open-ended question
qr - Or question
qt - Task question
UNKNOWN - Unknown question type
Generates different values including whether a sentence is predicted to be a task, and if so, it returns a dictionary that includes a list of tags indicating its predicted task type and priority.
sentence.is_task
sentence.task_actions
sentence.scores['task']
sentence.scores['task_actions']
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
email
call
open_attachment
open_browser
text
deadline
open_calendar
unknown_task_action
Generates an extractive summary with the most relevant sentences of the input text.
document.summary
summary_length Indicates the desired size of the output summary:
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates an extractive summary with the most relevant sentences of a news article. The input text must be a valid URL. The content of the article is stored as the raw_text of the document. The metadata of the news article is stored on a single dict and includes the url, image, date and author.
document.raw_text
document.summary
document.news_article
summary_length Indicates the desired size of the output summary:
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates an extractive summary with the most relevant sentences of the input text in their compressed form, independently if the compress is specified in the pipeline or not.
document.compressed_summary
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Provides, where applicable, a shortened version of a sentence that gives its main point without extraneous clauses. It uses the output of the dependency parser Annotator to determine parts of the sentence that serve to modify, explain, or embellish the main points and strips them off, leaving only the core information provided by the sentence.
sentence.compressed_sentence
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates a list of keyphrases to capture the topics covered by the document, in order from most to least relevant. Keyphrases can be retrieved with or without relevance scores.
document.keyphrases
document.keyphrases_scored
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Produces a list of named entities found in a sentence, containing the tokens of the entity, its type and its span positions.
sentence.named_entities
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
PER
LOC
ORG
MISC
DATE
MONEY
URL
PHONE
EMAIL
TWITTERNAME
TRACKINGNUMBER
AIRLINECODE
AIRLINENAME
AIRPORTCODE
AIRPORTNAME
EMOJI
SMILIE
Generates a list of resolved pronominal coreferences.
A coreference is a dictionary that includes 'mention', 'referent', 'first_referent'.
Each of those elements is a tuple containing a coreference id, the tokens and the span of the item. Additionally, each coreference dictionary contains a coreference chain (all the ids of the linked mentions) and the first referent of a chain.
sentence.coreferences
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Produces a list of tuples indicating the salience of named entities, that is how central they are to the content input document. Each tuple contains a boolean indicating if the entity is salient or not and its salience score.
sentence.named_entities
sentence.named_entities_salience
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates a list of tuples for each sentence with all resolved date entities given a relative date (by default today). The output includes the date entity, its tokens span and the resolved timestamp.
sentence.dates
date_referent Indicate the desired date to be used as referent for the resolution. The format of this variable needs to be 'year-month-day hour:minutes:seconds'
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates a list of dictionaries containing the retrieved predicates of each sentence, their lemmas, the constituents of the sentence found to be arguments of each predicate, and the classified argument type.
sentence.semantic_roles
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Agent/Experiencer
Patient/Theme/Affected
Beneficiary/Goal/Predicate/Comitative
Destination/EndingPoint/Source
Location
Speaker/Addressee/Conjunction/Interjection
Manner/Means/Extent
Modal
Cause
Temporal
EventModifier/Purpose
Negative
Groups the tokens of the sentence into small, non-overlapping groups based on prominent parts of speech, such as NP chunks ("the tall person") or VP chunks ("will leave").
sentence.chunks
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
CoNLL
We use the labels of the CoNLL-2000
Generates a list of dependencies in 3-tuples consisting of head, dependent and relation.
Head and dependent are in the format "token@@@position".
Positions are 1-indexed, with 0 being the index for the root.
sentence.dependencies
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Stanford Parser Dependencies
Our dependency labels mostly follow the basic dependencies given in section 2 of the Stanford Parser Dependencies (3.5.2), except for the following distinctions
* we do not use dependency labels which apply only to collapsed dependencies or which are labeled as "additional dependencies",
* we do not use the labels "goeswith" or "cop",
* we introduce the novel label "ncomp".
Generates a list containing the Part of Speech tag for each sentence token.
sentence.pos_tags
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Penn Treebank
We use the PoS labels of the Penn Treebank
Generates a version of the input raw text broken into smaller discrete units (tokens).
document.tokens
sentence.tokens
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates the base word (lemma) version of the input text’s tokens.
sentence.lemmas
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates the base root (stem) version of the input text’s tokens.
sentence.stems
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Produces a list of tokens after removing common stopwords from the text.
sentence.tokens_filtered
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates the naturally proper cased version of the input text’s tokens.
sentence.truecase_sentence
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates the proper grammatically cased version of the truecased input text’s tokens.
sentence.detruecase_sentence
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Removes typical Twitter artifacts like user mentions and URLs, segment hashtags and generates a cleaner version of the input text’s tokens.
sentence.tokens_clean
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates a list of sentences from a raw text.
document.sentences
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences:
Generates a label indicating the language of the text and its probability.
document.language
document.language_probability
from codeq_nlp_api import CodeqClient
client = CodeqClient(user_id="YOUR_USER_ID", user_key="YOUR_USER_KEY")
pipeline = None
text = "YOUR TEXT"
document = client.analyze(text, pipeline, summary_length="", date_referent="")
# Output
for sentence in document.sentences: