コード例 #1
0
ファイル: converser_nltk.py プロジェクト: encs-humanoid/ai
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()
コード例 #2
0
ファイル: chatbot.py プロジェクト: SomeshKb/Machine-Learning
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()
コード例 #3
0
ファイル: chat.py プロジェクト: suryaajha/lp1
def chatty():
    print("Welcome to LA. Lucifer will be your guide in the investments")

    chat = Chat(pairs, reflections)
    chat.converse()
コード例 #4
0
ファイル: zen.py プロジェクト: aczapata/twitter
     ("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()
コード例 #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()
コード例 #6
0
def chatty():
    print("Hi i am chatty")
    chat = Chat(pairs, reflections)
    chat.converse()
コード例 #7
0
def send_reply_drink(user_msg):
    chat = Chat(drink, reflections)
    reply = chat.respond(user_msg)
    return reply
コード例 #8
0
def chatear():
    print("Hola soy un bot, escribe algo para comenzar")  #mensaje por defecto
    chat = Chat(pares, mis_reflexions)
    chat.converse()
コード例 #9
0
ファイル: four_a.py プロジェクト: bluemner/nlp-cs723
def hugot_bot():
    print("Whats your favorite color?")
    chat = Chat(pairs, reflections)
    chat.converse()
コード例 #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()
コード例 #11
0
ファイル: Fomebot.py プロジェクト: cintia-valente/chatbot
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()
コード例 #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()
コード例 #13
0
ファイル: converser_nltk.py プロジェクト: encs-humanoid/ai
 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)
コード例 #14
0
def chatty(se):
    chat = Chat(pairs, reflections)
    return chat.converse(se)
    print(s)
コード例 #15
0
def chatterbox():
    print("Seu aliado foi eliminado!")
    chat = Chat(toxic, reflections)
    chat.converse()
コード例 #16
0
ファイル: flask_app.py プロジェクト: syri0/simba
        ]
    ],
    [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
コード例 #17
0
def chatty():
    print("Hi I am Chatty,You can chat with me.Say quit to exit")
    chat = Chat(pairs, reflections)
    chat.converse()
コード例 #18
0
def send_reply_price(user_msg):
    chat = Chat(price, reflections)
    reply = chat.respond(user_msg)
    return reply
コード例 #19
0
def Chatbot():
    print("Hi, I am your chatbot built using nltk module")
    chatbot = Chat(pairs, reflections)
    chatbot.converse()
コード例 #20
0
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()
コード例 #21
0
            '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()
コード例 #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()
コード例 #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
コード例 #24
0
ファイル: suntsu.py プロジェクト: wardbradt/nltk
         "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()

コード例 #25
0
def firstChatbot():
    print("Hai Saya STIKBOTS kamu siapa ?")
    chatbot = Chat(pairs, reflections)
    chatbot.converse()
コード例 #26
0
ファイル: rude.py プロジェクト: HoaLD20/Python
    ),
    (
        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()

コード例 #27
0
def chatty(userText):
    chat = Chat(pairs, reflections)
    userText=userText.lower()
    return chat.respond(userText)
コード例 #28
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()
コード例 #29
0
    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"
コード例 #30
0
def jarvischat():
    print("heyya! tell me what i can do?")  #default message at the start
    chat = Chat(pairs, reflections)
    chat.converse()
コード例 #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)

コード例 #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()
コード例 #33
0
ファイル: Chatbot.py プロジェクト: jayant2014/MyML
         (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():
コード例 #34
0
ファイル: aino.py プロジェクト: prabhatsaini91/NLP-TA
    "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
コード例 #35
0
ファイル: 5_matching.py プロジェクト: aigamedev/nuclai15
def main():
	print("OK, let's play a game of resistance!")
	chatbot = Chat(pairs, reflections)
	chatbot.converse()