Arafath10 commited on
Commit
69b4c9c
1 Parent(s): f05c087

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -30
app.py CHANGED
@@ -14,14 +14,13 @@ def joke():
14
  return My_joke
15
 
16
 
17
- def qq():
18
  #text = chatbot.get_response(name)
19
  name = name.lower()
20
- if "what" in name or "who" in name or "how to" in name:
21
- result = wikipedia.summary(name, sentences =10)
22
- return result
23
- else:
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
- url = "https://www.google.com/search?q="+name
38
- r = requests.get(url)
39
-
40
- soup = BeautifulSoup(r.text,"html.parser")
41
-
42
- heading_object=soup.find_all('div')
43
- n=1
44
- for info in heading_object:
45
-
46
- n=n+1
47
- p=""
48
- if n==9:
49
- #print("------",n)
50
- result = info.getText()[170:]
51
- result = result.split(".")
52
- for s in result[:10]:
53
- p = p + "\n"+s
54
- p = p.replace("org › wiki ›","")
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")