File size: 1,615 Bytes
e641e34
92ad35f
42ea31f
 
d2525f1
 
 
 
 
 
 
 
 
 
 
f3af7d2
69b4c9c
42ea31f
6b23616
69b4c9c
 
 
 
e641e34
42ea31f
f345069
 
 
d2525f1
 
 
 
0a79801
69b4c9c
 
 
 
 
 
0a79801
69b4c9c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42ea31f
 
7845b8a
e641e34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import gradio as gr
import wikipedia
import requests
from bs4 import BeautifulSoup
import pyjokes



def joke():
    # importing installed library

    My_joke = pyjokes.get_joke(language="en", category="neutral")

    return My_joke


def wiki():
        #text = chatbot.get_response(name)
    name = name.lower()
    name = name.split()[-1]
    result = wikipedia.summary(name, sentences =20)
    return result


def greet(name):
        if "who are you" in name or "who r u" in name:

            return "im ssebowa.org created Chatbot"


        if "tell me a joke" in name or "joke" in name:
            return joke()

        return wiki()
        def google():    
            url = "https://www.google.com/search?q="+name
            r = requests.get(url)
    
            soup = BeautifulSoup(r.text,"html.parser")
            
            heading_object=soup.find_all('div')
            n=1
            for info in heading_object:
    
                n=n+1
                p=""
                if n==9:
                        #print("------",n)
                        result = info.getText()[170:]
                        result = result.split(".")
                        for s in result[:10]:
                                p = p + "\n"+s
                        p = p.replace("org › wiki ›","")
                        p = p.replace("wikipedia","")
                        p = p.replace("com › dictionary ›","")
                        print(p)
                        return p
                        break    


iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()