-
-
Save bhavyagaur99/81cea8a1c5e8e5bfc108bbab54312a01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# You need to have requests library installed. | |
# You will need to replace the API key with your own. | |
# Exceptions thrown are not handled since this is a sample code. | |
import requests | |
api_key = '***<replace your key here>***' | |
text = '''I believe that it is fundamental to have an | |
overview of the history that later formed Computer Science. | |
People know work of individuals such as Dijkstra. | |
But, there are several individuals who led to computers | |
even existing. It was a process that started in the early | |
800s, and started to grow in the 1800s and the 1900s. | |
How did simple changes in voltage develop machines such | |
as computers? It is incredible that the works of individuals | |
across different centuries led to computers. It is important | |
to explore the process of how these concepts are discovered. | |
300 BC In 300 BC Euclid writes a series of 13 books called | |
Elements. The definitions, theorems, and proofs covered in | |
the books became a model for formal reasoning. Elements was | |
instrumental in the development of logic modern science. It | |
is the first documented work in Mathematics that used a | |
series of numbered chunks to break down the solution to a | |
problem. 300 BC 800 AC Following Euclid, notes about recipes, | |
etc. were the closest thing to how we think at algorithms | |
today. Also, there was also the inventions of mathematical | |
methods. For example, Sieve of Eratosthenes, Euclid s | |
algorithms, and methods for factorization square roots. | |
It seems common to us now to list things out in the order | |
we will do them in. But, in Mathematics at that time it was | |
not a common idea. 800s The story really starts in the 800s | |
where we meet a person named al Khw rizm . His name roughly | |
translates to Algoritmi, in Latin, and he develops a technique | |
called Algorism. Algorism is the technique of performing arithmetic | |
with Hindu Arabic numerals. Al Khw rizm is considered to be the | |
grandfather of Computer Science.''' | |
def get_summary(text, api_key, language='english', summary_percent=10): | |
url = 'https://text-analysis12.p.rapidapi.com/summarize-text/api/v1.1' | |
payload = { | |
'language': language, | |
'text': text, | |
'summary_percent': summary_percent | |
} | |
headers = { | |
'content-type': 'application/json', | |
'x-rapidapi-host': 'text-analysis12.p.rapidapi.com', | |
'x-rapidapi-key': api_key | |
} | |
response = requests.post(url=url, json=payload, headers=headers) | |
return response.json()['summary'] | |
print('Summary with 25% of the text:') | |
print(get_summary(text, api_key, 'english', 25)) | |
print() | |
print('Summary with 10% of the text:') | |
print(get_summary(text, api_key)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment