Exemple #1
0
class Converser(object):
    def __init__(self):
        self.pub = rospy.Publisher('speech_text', String)
        rospy.Subscriber('heard_text', String, self.callback)
        rospy.init_node('converser')
        self.bot = Chat(pairs, reflections)

    def callback(self,msg):
        rospy.loginfo(rospy.get_caller_id() + ": I heard: %s", msg.data)
        utterance = self.bot.respond(msg.data)
        print(utterance)
        self.pub.publish(utterance)

    def run(self):
        rospy.spin()
Exemple #2
0
def chatty():
    print("Hi, I'm Chatty and I chat alot ;)\nPlease type lowercase English language to start a conversation. Type quit to leave ") #default message at the start
    chat = Chat(pairs, reflections)
    chat.converse()
Exemple #3
0
def chatty():
    print("Welcome to LA. Lucifer will be your guide in the investments")

    chat = Chat(pairs, reflections)
    chat.converse()
Exemple #4
0
     ("Farewell. The obstacle is the path.",
      "Farewell. Life is a journey, not a destination.",
      "Good bye. We are cups, constantly and quietly being filled."
      "\nThe trick is knowning how to tip ourselves over and let the beautiful stuff out."
      )),

    # fall through case -
    # when stumped, respond with generic zen wisdom
    #
    (r'(.*)',
     ("When you're enlightened, every word is wisdom.",
      "Random talk is useless.", "The reverse side also has a reverse side.",
      "Form is emptiness, and emptiness is form.",
      "I pour out a cup of water. Is the cup empty?")))

zen_chatbot = Chat(responses, reflections)


def zen_chat():
    print('*' * 75)
    print("Zen Chatbot!".center(75))
    print('*' * 75)
    print('"Look beyond mere words and letters - look into your mind"'.center(
        75))
    print("* Talk your way to truth with Zen Chatbot.")
    print("* Type 'quit' when you have had enough.")
    print('*' * 75)
    print("Welcome, my child.")

    zen_chatbot.converse()
Exemple #5
0
            "how to see u again soon! ^_^",
        ),
    ),
    (
        r'(.*)',
        (
            "ur funny! kekeke",
            "boooooring! talk about something else! tell me wat u like!",
            "do u like anime??",
            "do u watch anime? i like sailor moon! ^_^",
            "i wish i was a kitty!! kekekeke ^_^",
        ),
    ),
)

iesha_chatbot = Chat(pairs, reflections)


def iesha_chat():
    print("Iesha the TeenBoT\n---------")
    print(
        "Talk to the program by typing in plain English, using normal upper-")
    print('and lower-case letters and punctuation.  Enter "quit" when done.')
    print('=' * 72)
    print("hi!! i'm iesha! who r u??!")

    iesha_chatbot.converse()


def demo():
    iesha_chat()
Exemple #6
0
def chatty():
    print("Hi i am chatty")
    chat = Chat(pairs, reflections)
    chat.converse()
Exemple #7
0
def send_reply_drink(user_msg):
    chat = Chat(drink, reflections)
    reply = chat.respond(user_msg)
    return reply
Exemple #8
0
def chatear():
    print("Hola soy un bot, escribe algo para comenzar")  #mensaje por defecto
    chat = Chat(pares, mis_reflexions)
    chat.converse()
Exemple #9
0
def hugot_bot():
    print("Whats your favorite color?")
    chat = Chat(pairs, reflections)
    chat.converse()
Exemple #10
0
def chatty():
        print("Hi, I'm Bot \n How can i Help You") #default message at the start
        chat = Chat(pairs)
        chat.converse()
Exemple #11
0
def chatty():
    print(
        "FomeBot: Olá, eu sou o FomeBot, vou tentar te ajudar a encontrar a melhor opção de restaurante em Porto Alegre para matar a sua fome!"
    )
    chat = Chat(pares)
    chat.converse()
Exemple #12
0
  

  (r'(.*)\?',
  ( "I suppose I dont have enough information about that.",
    "Please consider whether you can answer your own question.",
    "It is confidential dear.")),

 
  (r'(.*)',
  ( "Please tell me more.",
    "Let's change focus a bit... Ask me something else.",
    "Can you be specific?",
    "Very interesting."))
)

gini_chatbot = Chat(pairs, reflections)

def gini_chat():
    print("--------------------------------------------------------------------")
    print("Talk to the program by typing in plain English, using normal upper-")
    print('and lower-case letters and punctuation.  Enter "quit" when done.')
    print('='*72)
    print("Hello. My name is GINI. How can I help you?")

    gini_chatbot.converse()

def demo():
    gini_chat()

if __name__ == "__main__":
    demo()
Exemple #13
0
 def __init__(self):
     self.pub = rospy.Publisher('speech_text', String)
     rospy.Subscriber('heard_text', String, self.callback)
     rospy.init_node('converser')
     self.bot = Chat(pairs, reflections)
def chatty(se):
    chat = Chat(pairs, reflections)
    return chat.converse(se)
    print(s)
Exemple #15
0
def chatterbox():
    print("Seu aliado foi eliminado!")
    chat = Chat(toxic, reflections)
    chat.converse()
Exemple #16
0
        ]
    ],
    [r"(.*) (sports|game) ?", [
        "I'm a very big fan of Football",
    ]],
    [r"who (.*) sportsperson ?", ["Messy", "Ronaldo", "Roony"]],
    [
        r"quit",
        [
            "BBye take care. See you soon :) ",
            "It was nice talking to you. See you soon :)"
        ]
    ],
]

chat = Chat(pairs, reflections)

# def weather(msg):
# 	city=msg.split(',')[0]
# 	country=msg.split(',')[1]
# 	apikey="5eHASm1cPxSJvZG01nAWn3fIq4QXCtTs"
# 	url="http://dataservice.accuweather.com/locations/v1/regions?apikey="+apikey
# 	regions=json.loads(url.response)
# 	for region in regions:
# 		regId=region['ID']
# 		newurl="http://dataservice.accuweather.com/locations/v1/countries/"+str(regId)+"?apikey="+apikey
# 		countries=json.loads(newurl.response)
# 		for count in countries:
# 			if(country==count):
# 				countID= count["ID"]
# 				break
Exemple #17
0
def chatty():
    print("Hi I am Chatty,You can chat with me.Say quit to exit")
    chat = Chat(pairs, reflections)
    chat.converse()
Exemple #18
0
def send_reply_price(user_msg):
    chat = Chat(price, reflections)
    reply = chat.respond(user_msg)
    return reply
def Chatbot():
    print("Hi, I am your chatbot built using nltk module")
    chatbot = Chat(pairs, reflections)
    chatbot.converse()
def chatty():
    print(
        "Hi, I'm J.A.R.V.I.S and I want to help and chat with you ! \nPlease type lowercase English language to start a conversation. Type quit to leave "
    )  #default message at the start
    chat = Chat(pairs, reflections)
    chat.converse()
            'haiii akhirnya tuan kembali :)', 'halllooo tuan <3',
            'hollllaa akhirnya :3'
        ]
    ],
    ['(.*) in (.*) is fun', ['%1 in %2 is indeed fun']],
    [
        '(.*)dimana(.*)',
        [
            'aku ini kan bot,jadi tempat ku fleksibel dimana aja,dan karena aku masih beta jadi ngikutin lokasi laptop nya tuan adit'
        ]
    ],
    ['(.*)pencipta(.*)', ['tuan adit dong']],
    [
        'how is the weather in (.*)',
        ['the weather in %1 is amazing like always']
    ],
    ['(.*)help(.*)', ['I can help you']],
    [
        '(.*)siapa(.*)',
        [
            'Haik....nama ku aera aku chat bot pertama yang di buat oleh tuan adit'
        ]
    ],
]

reflections
my_dummy_reflections = {'go': 'gone', 'hello': 'hey there'}

chat = Chat(pairs, my_dummy_reflections)
chat.converse()
Exemple #22
0
      "How do you think your childhood experiences relate to your feelings today?"
      )), (r'(.*)\?',
           ("Why do you ask that?",
            "Please consider whether you can answer your own question.",
            "Perhaps the answer lies within yourself?",
            "Why don't you tell me?")),
    (r'quit', ("Thank you for talking with me.", "Good-bye.",
               "Thank you, that will be $150.  Have a good day!")),
    (r'(.*)',
     ("Please tell me more.",
      "Let's change focus a bit... Tell me about your family.",
      "Can you elaborate on that?", "Why do you say that %1?", "I see.",
      "Very interesting.", "%1.", "I see.  And what does that tell you?",
      "How does that make you feel?", "How do you feel when you say that?")))

eliza_chatbot = Chat(pairs, reflections)


def eliza_chat():
    print("Therapist\n---------")
    print(
        "Talk to the program by typing in plain English, using normal upper-")
    print('and lower-case letters and punctuation.  Enter "quit" when done.')
    print('=' * 72)
    print("Hello.  How are you feeling today?")

    eliza_chatbot.converse()


def demo():
    eliza_chat()
Exemple #23
0
class JirigoChatBot(object):
    def __init__(self, data=None):
        self.jdb = JirigoDBConn()
        self.logger = Logger()
        self.query = ""
        self.project_abbr = data.get('project_abbr', None)
        self.chatObj = Chat(pairs, reflections)
        self.lemmer = WordNetLemmatizer()
        self.punctuations = dict(
            (ord(punctuation), None) for punctuation in string.punctuation)

        self.tag_map = defaultdict(lambda: wn.NOUN)
        self.tag_map['J'] = wn.ADJ
        self.tag_map['V'] = wn.VERB
        self.tag_map['R'] = wn.ADV

    def perform_lemmatization(self, tokens):
        return [self.lemmer.lemmatize(token) for token in tokens]

    def get_processed_text(self, document):
        return perform_lemmatization(
            nltk.word_tokenize(
                document.lower().translate(punctuation_removal)))

    def get_query_response(self, query):
        response_data = {}
        self.query = query
        item_no = ""
        chatbot_res = ""

        print('*' * 40)
        print(query)
        print(sent_tokenize(query))
        print(word_tokenize(query))
        print(string.punctuation)
        word_tokens = word_tokenize(query)
        lmtzr = WordNetLemmatizer()

        # print(self.perform_lemmatization(pos_tag(word_tokenize(query))))
        print(pos_tag(word_tokenize(query)))
        print('*' * 40)
        print(self.project_abbr)
        if (re.match(r'^GET_ITEM_DETAILS',
                     self.chatObj.respond(self.query),
                     flags=re.IGNORECASE)):
            for token, tag in pos_tag(word_tokens):
                lemma = lmtzr.lemmatize(token, self.tag_map[tag[0]])
                print(f'{self.project_abbr}:{lemma}')
                if (re.search(self.project_abbr, lemma, re.IGNORECASE)):
                    self.item_no = lemma
                    break
            chatbot_res = self.get_item_status()
        else:
            chatbot_res = self.chatObj.respond(self.query)

        response_data['dbQryStatus'] = 'Success'
        response_data['dbQryResponse'] = chatbot_res
        print(response_data)
        return response_data

    def bot_converse(self):
        return self.chatObj.converse()

    def get_canned_response(self):
        return self.chatObj.respond(self.query)

    def get_item_status(self):
        response_data = {}
        self.logger.debug(" Inside get_item_status")
        print("Inside get_item_status")
        print(self.item_no)
        query_sql = """  
                        SELECT item_no||' '||summary||' is in '||issue_status||' status' as item_status
                          FROM v_all_tickets_tasks vatt 
                         WHERE lower(item_no)=lower(%s)
                   """
        values = (self.item_no, )
        self.logger.debug(f'Select : {query_sql} values {values}')
        try:
            print('-' * 80)
            cursor = self.jdb.dbConn.cursor()
            cursor.execute(query_sql, values)
            data = cursor.fetchone()
            if data is None:
                print('data is none')
                data = f'Sorry, {self.item_no} doesn\'t exists'

            row_count = cursor.rowcount
            self.logger.debug(
                f'Select Success with {row_count} row(s) get_item_status  {data}'
            )
            return data[0]
        except (Exception, psycopg2.Error) as error:
            if (self.jdb.dbConn):
                print(f'Error While get_item_status {error}')
                raise
Exemple #24
0
         "Appear at points which the enemy must hasten to defend; march swiftly to places where you are not expected.")),

    (r'[V-Zv-z](.*)',
        ("It is a matter of life and death, a road either to safety or to ruin.",
         "Hold out baits to entice the enemy. Feign disorder, and crush him.",
         "All men can see the tactics whereby I conquer, but what none can see is the strategy out of which victory is evolved.",
         "Do not repeat the tactics which have gained you one victory, but let your methods be regulated by the infinite variety of circumstances.",
         "So in war, the way is to avoid what is strong and to strike at what is weak.",
         "Just as water retains no constant shape, so in warfare there are no constant conditions.")),

    (r'(.*)',
        ("Your statement insults me.",
         ""))
)

suntsu_chatbot = Chat(pairs, reflections)


def suntsu_chat():
    print("Talk to the program by typing in plain English, using normal upper-")
    print('and lower-case letters and punctuation.  Enter "quit" when done.')
    print('=' * 72)
    print("You seek enlightenment?")

    suntsu_chatbot.converse()


def demo():
    suntsu_chat()

Exemple #25
0
def firstChatbot():
    print("Hai Saya STIKBOTS kamu siapa ?")
    chatbot = Chat(pairs, reflections)
    chatbot.converse()
Exemple #26
0
    ),
    (
        r"Hello(.*)",
        ("Oh good, somebody else to talk to. Joy.", "'Hello'? How original..."),
    ),
    (
        r"(.*)",
        (
            "I'm getting bored here. Become more interesting.",
            "Either become more thrilling or get lost, buddy.",
            "Change the subject before I die of fatal boredom.",
        ),
    ),
)

rude_chatbot = Chat(pairs, reflections)


def rude_chat():
    print("Talk to the program by typing in plain English, using normal upper-")
    print('and lower-case letters and punctuation.  Enter "quit" when done.')
    print("=" * 72)
    print("I suppose I should say hello.")

    rude_chatbot.converse()


def demo():
    rude_chat()

Exemple #27
0
def chatty(userText):
    chat = Chat(pairs, reflections)
    userText=userText.lower()
    return chat.respond(userText)
def chatty():
    print(
        "Hi, I'm Chatty and I chat alot ;)\nPlease type lowercase English language to start a conversation. Type quit to leave "
    )  #default message at the start
    chat = Chat(pairs, reflections)
    chat.converse()
    def ngobrolClicked(self):
        pairs = [
            [
                r"hai|hi|hey|hello|Apa Kabar|Ada orang?|apakah ada orang?|hola",
                [
                    "Hello", "Hey, ada yang bisa dibantu?", "Selamat Datang",
                    "Hi, Kaka", "Hi, Apakah ada yang bisa saya bantu?"
                ]
            ],
            [
                r"Dah|Sampai bertemu lagi|Selamat Tinggal|Terima kasih|Trims|Oke",
                [
                    "Semoga harimu menyenangkan!!!",
                    "Senang berbincang dengan kamu", "Senang bisa membantu"
                ]
            ],
            [
                r"Berapa usiamu?|Berapa umur kamu?|Umur?",
                [
                    "Usia hanya sebuah angka",
                    "Aku robot aku tak mengenal umur", "umur 2 hari",
                    "Umur saya tak terhingga"
                ]
            ],
            [
                r"Siapa Namamu?|Siapa Namamu|Nama",
                ["Panggil saya Chatbot", "Chatbot, itu namaku"]
            ],
            [r"Sedang apa?|Nanya|Chatbot", ["Saya disini siap membantu anda"]],
            [
                r"Saya ingin membeli sesuatu|Apa saja yang kamu rekomendasikan?|Mau beli",
                [
                    "Silahkan pilih : 1. KYT 2. HRC 3. Hiu",
                    "Tergantung kamu ingin helm seperti apa? 1. KYT 2. HRC 3. Hiu",
                    "1. KYT 2. HRC 3. Hiu"
                ]
            ],
            [
                r"Kapan toko mulai buka?|Apakah ini buka?|Berapa lama toko ini buka?",
                [
                    "Kami buka pukul 7 pagi",
                    "Kami buka dari hari senin hingga senin lagi!",
                    "07.00 sampai 19.00"
                ]
            ],
            [
                r"Berapa harga helm?|Saya mau tau harganya|harga",
                [
                    "Merk apa kaka?", "Tolong sebutkan merknya :)",
                    "Hmmm tolong sebutkan merknya :)",
                    "mulai dari 50rb anda sudah mendapat helm kaka"
                ]
            ],
            [
                r"Apa ini?",
                [
                    "Ini adalah layanan chatbot penjualan helm",
                    "Saya robot kaka"
                ]
            ],
            [
                r"Merk NHK|NHK",
                [
                    "Harganya mulai dari Rp.300rb",
                    "300rb saja sudah bisa dibeli :)"
                ]
            ],
            [
                r"Merk KYT|KYT",
                [
                    "Untuk itu harganya 330rb, ukuran berapa?",
                    "Cukup 330rb saja, Ukuran berapa?"
                ]
            ],
            [
                r"Merk Hiu|Hiu",
                [
                    "Itu sangat terjangkau harganya, hanya 50rb, Ukuran berapa?",
                    "50rb saja, Ukuran berapa?"
                ]
            ],
            [
                r"Saya ambil itu|ambil itu|mau yang itu|beli yang itu|pesan yang itu|pesan|beli",
                [
                    "Oke kaka lanjutkan ke pembayaran",
                    "Siap :) setelah bayar helm akan langsung dikemas",
                    "Silahkan lanjutkan ke kasir kaka"
                ]
            ],
            [
                r"ukuran(.*)",
                ["ukuran %1, oke segera dikirim setelah pembayaran :)"]
            ],
            [
                r"(.*)",
                [
                    "Saya tidak mengerti", "Bisa katakan hal lain?",
                    "Aduh bingung, saya tidak mengerti"
                ]
            ],
        ]

        chat = Chat(pairs, reflections)
        print('=' * 72)
        s = ""
        while s != "quit":
            s = "quit"
            try:
                inp = self.le.text()
                print(inp)
                # self.ngobrolClicked(inp, None)
                user = "******" + inp
                self.listWidget.addItem(user)
                s = inp.lower()
            except EOFError:
                print(s)
                self.listWidget.addItem(s)
                # self.ngobrolClicked(None, s)
            if s:
                respond = chat.respond(s)
                print(respond)
                bot = "Bot > " + respond
                # self.ngobrolClicked(respond, None)
                self.listWidget.addItem(bot)
                s = "quit"
Exemple #30
0
def jarvischat():
    print("heyya! tell me what i can do?")  #default message at the start
    chat = Chat(pairs, reflections)
    chat.converse()
Exemple #31
0
from nltk.chat.util import Chat, reflections
from gtts import gTTS
import playsound
import wikipedia
import os
from wikiNepali import *
from mysqlDataFetch import *
from googletrans import Translator
nepaliDictionary = [
    [
        "(नमस्कार|नमस्ते|हेल्लो|Hello|namaste|namaskar)",
        ["नमस्ते, हजुरलाई पाइला टेक्नोलोजीमा स्वागत छ।"]
    ],
]

chatNepali = Chat(nepaliDictionary, reflections)
translator = Translator()


def quitingNepali(lang, userName):
    speakNepali("Main", lang)


def speakNepali(speakText, lang):
    myobj = gTTS(text=speakText, lang=lang, slow=False)
    audio_file = "welcome.mp3"
    myobj.save(audio_file)
    playsound.playsound(audio_file)
    os.remove(audio_file)

Exemple #32
0
        r"how (.*) health(.*)",
        [
            "I'm a computer program, so I'm always healthy ",
        ]
    ],
    [r"(.*) (sports|game) (.*)?", [
        "I'm a very big fan of Football",
    ]],
    [r"who (.*) sportsperson ?", ["Messy", "Ronaldo", "Roony"]],
    [r"who (.*) (moviestar|actor)(.*)?", ["Brad Pitt"]],
    [
        r"quit",
        [
            "BBye take care. See you soon :) ",
            "It was nice talking to you. See you soon :)"
        ]
    ],
]


def chatty():
    print(
        "Hi, I'm Chitti and I chat alot ;)\nPlease type lowercase English language to start a conversation. Type quit to leave "
    )  # default message at the start


chat = Chat(pairs, reflections)
chat.converse()
if __name__ == "__main__":
    chatty()
Exemple #33
0
         (r'(.*)\?',
          ("Why do you ask that?",
           "Please consider whether you can answer your own question.",
           "Perhaps the answer lies within yourself?",
           "Why don't you tell me?")),
         (r'quit', ("Thank you for talking with me.", "Good-bye.",
                    "Thank you, that will be $150.  Have a good day!")),
         (r'(.*)',
          ("Please tell me more.",
           "Let's change focus a bit... Tell me about your family.",
           "Can you elaborate on that?", "Why do you say that %1?", "I see.",
           "Very interesting.", "%1.", "I see.  And what does that tell you?",
           "How does that make you feel?",
           "How do you feel when you say that?")))

eliza_chatbot = Chat(pairs, reflections)


def eliza_chat():
    print("Therapist\n---------")
    print(
        "Talk to the program by typing in plain English, using normal upper-")
    print('and lower-case letters and punctuation. Enter "quit" when done.')
    print('=' * 72)
    print("Hello. How are you feeling today?")


eliza_chatbot.converse()


def demo():
Exemple #34
0
    "Thank you, that will be $150.  Have a good day!")),

  (r'(.*)',
  ( "Please tell me more.",
    "Let's change focus a bit... Tell me about your family.",
    "Can you elaborate on that?",
    "Why do you say that %1?",
    "I see.",
    "Very interesting.",
    "%1.",
    "I see.  And what does that tell you?",
    "How does that make you feel?",
    "How do you feel when you say that?"))
)

aino_chatbot = Chat(pairs, reflections)


location_id = "INXX0096"
location_name = "New Delhi"
weather_com_result = pywapi.get_weather_from_weather_com(location_id)
date = time.strftime("%A %B %d %Y")
t = time.strftime("%I %M %p")

speak = "Hi. Today's " + time.strftime("%A %d") + " of " + time.strftime("%B %Y") + \
		". The time is " + time.strftime("%I %M %p") + ". It is " + \
		string.lower(weather_com_result['current_conditions']['text']) + " and " + \
		weather_com_result['current_conditions']['temperature'] + " degree celsius now in " + \
		location_name + ". My name is AINO. How do you do? What is your name?"

print speak
Exemple #35
0
def main():
	print("OK, let's play a game of resistance!")
	chatbot = Chat(pairs, reflections)
	chatbot.converse()