Update app.py
Browse files
app.py
CHANGED
|
@@ -14,14 +14,13 @@ def joke():
|
|
| 14 |
return My_joke
|
| 15 |
|
| 16 |
|
| 17 |
-
def
|
| 18 |
#text = chatbot.get_response(name)
|
| 19 |
name = name.lower()
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
return "no found"
|
| 25 |
|
| 26 |
def greet(name):
|
| 27 |
if "who are you" in name or "who r u" in name:
|
|
@@ -32,31 +31,31 @@ def greet(name):
|
|
| 32 |
if "tell me a joke" in name or "joke" in name:
|
| 33 |
return joke()
|
| 34 |
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
p = p.replace("wikipedia","")
|
| 56 |
-
p = p.replace("com › dictionary ›","")
|
| 57 |
-
print(p)
|
| 58 |
-
return p
|
| 59 |
-
break
|
| 60 |
|
| 61 |
|
| 62 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
|
| 14 |
return My_joke
|
| 15 |
|
| 16 |
|
| 17 |
+
def wiki():
|
| 18 |
#text = chatbot.get_response(name)
|
| 19 |
name = name.lower()
|
| 20 |
+
name = name.split()[-1]
|
| 21 |
+
result = wikipedia.summary(name, sentences =20)
|
| 22 |
+
return result
|
| 23 |
+
|
|
|
|
| 24 |
|
| 25 |
def greet(name):
|
| 26 |
if "who are you" in name or "who r u" in name:
|
|
|
|
| 31 |
if "tell me a joke" in name or "joke" in name:
|
| 32 |
return joke()
|
| 33 |
|
| 34 |
+
return wiki()
|
| 35 |
+
def google():
|
| 36 |
+
url = "https://www.google.com/search?q="+name
|
| 37 |
+
r = requests.get(url)
|
| 38 |
+
|
| 39 |
+
soup = BeautifulSoup(r.text,"html.parser")
|
| 40 |
|
| 41 |
+
heading_object=soup.find_all('div')
|
| 42 |
+
n=1
|
| 43 |
+
for info in heading_object:
|
| 44 |
+
|
| 45 |
+
n=n+1
|
| 46 |
+
p=""
|
| 47 |
+
if n==9:
|
| 48 |
+
#print("------",n)
|
| 49 |
+
result = info.getText()[170:]
|
| 50 |
+
result = result.split(".")
|
| 51 |
+
for s in result[:10]:
|
| 52 |
+
p = p + "\n"+s
|
| 53 |
+
p = p.replace("org › wiki ›","")
|
| 54 |
+
p = p.replace("wikipedia","")
|
| 55 |
+
p = p.replace("com › dictionary ›","")
|
| 56 |
+
print(p)
|
| 57 |
+
return p
|
| 58 |
+
break
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
|
| 60 |
|
| 61 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|