Python wrapper for the TLDR text summarization and analysis API.
Project description
tldr-python
Python wrapper for the TLDR text summarization and analysis API available on RapidAPI.
Installation
pip install tldr-python
Introduction - Getting Started
tldr-python is a wrapper over the TLDR text summarization and analysis API. To use this API, create an account on RapidAPI and subscribe to the API.
Once you have a RapidAPI key, initialize a TLDR instance as demonstrated below.
from tldr_python import TLDR
tldr = TLDR('<your RapidAPI key>')
Text Summarization
You can use TLDR to summarize articles on the web with the summarize function. This function accepts either a URL or the raw text of an article on the web.
We can summarize a Wikipedia article about Python using the code below.
summary = tldr.summarize('https://en.wikipedia.org/wiki/Python_(programming_language)', max_sentences=3)
print(summary.text)
The code above produces the following summary:
'[34][35][36][37][38] History[edit] Python was conceived in the late 1980s[39] by Guido van Rossum at Centrum Wiskunde & Informatica (CWI) in the Netherlands as a successor to ABC programming language, which was inspired by SETL,[40] capable of exception handling and interfacing with the Amoeba operating system.[67] The standard library has two modules (itertools and functools) that implement functional tools borrowed from Haskell and Standard ML.[69] Alex Martelli, a Fellow at the Python Software Foundation and Python book author, writes that "To describe something as \'clever\' is not considered a compliment in the Python culture.'
Keyword Extraction
We can also extract keywords from an article as shown below.
keywords = tldr.extract_keywords('https://en.wikipedia.org/wiki/Python_(programming_language)', n_keywords=3)
print(keywords.json)
The result of the code above is a JSON list with the top three scored keywords from the article.
[{'keyword': 'python', 'score': 402}, {'keyword': 'language', 'score': 68}, {'keyword': 'software', 'score': 47}]
Sentiment Analysis
We can also analyze the sentiment of an article with the analyze_sentiment function. This function returns a Sentiment object with sentiment and polarity attributes.
sentiment = tldr.analyze_sentiment('https://en.wikipedia.org/wiki/Python_(programming_language)')
print(sentiment.json)
The code above gives a dictionary with the sentiment and polarity of the article.
{'sentiment': 'positive', 'polarity': 0.10235096701177092}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tldr-python-1.0.0.tar.gz.
File metadata
- Download URL: tldr-python-1.0.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.7.6 Darwin/19.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4b8e309f79f6fcd3aea671652ba261e4f9084fbd6223c8e798e25dbd9dca088
|
|
| MD5 |
20d984abf283fd1afd12df7b226f34cf
|
|
| BLAKE2b-256 |
c8ab4f298fcc45e0ca5c90401ceeea9682ad366cee0e628638cb8771dac7f268
|
File details
Details for the file tldr_python-1.0.0-py3-none-any.whl.
File metadata
- Download URL: tldr_python-1.0.0-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.6 CPython/3.7.6 Darwin/19.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7206e50a6ceba1eefe36e71c3c56fadccedb4306fd4083f02cfe80cc6be87a51
|
|
| MD5 |
aa6aed21933511246d81fa918a7bd938
|
|
| BLAKE2b-256 |
70c60212915e906c45ea41dace4424916b7226fe25ee367379aea93546325b0e
|