Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
import textwrap #package that allows to choose lenght of the lines that are printed -> font:https://stackoverflow.com/questions/16430200/a-good-way-to-make-long-strings-wrap-to-newline-in-python
import wikipedia #package that allows search in wikipedia database to get information of certain topic -> font:https://pypi.org/project/wikipedia/
""" defines the key word and searches in wikipedia for the meaning """
def wikiSearch(sentence):
totalSize = len(sentence)
word = ""
for i in range(totalSize):
if "what is" in sentence:
if i <= 7:
continue
else:
word = word + sentence[i]
if "wiki" in sentence:
if i <= 4:
continue
else:
word = word + sentence[i]
if "who is" in sentence:
if i <= 6:
continue
else:
word = word + sentence[i]
try:
meaning = (wikipedia.summary(str(word), sentences=2)) #gets the first 2 sentences of wikipedia when searching for meaning of word
fullMeaning = (wikipedia.summary(str(word), sentences=20)) #gets the first 20 sentences of wikipedia when searching for meaning of word
print(textwrap.fill(meaning, 80)) #formats the lenght of the lines that are printed
answer = input("\nDo you want to know more about this?\nYes or No: ")
answer = answer.lower()
if "yes" in answer or "y" in answer:
print(textwrap.fill(fullMeaning, 120))
except:
print("Sorry, I do not understand")