Jarvis Code Added
This commit is contained in:
parent
7d39b7e71f
commit
6f6b6c9b54
318
main.py
Normal file
318
main.py
Normal file
@ -0,0 +1,318 @@
|
|||||||
|
from nltk.chat.util import Chat, reflections
|
||||||
|
|
||||||
|
pairs = (
|
||||||
|
(
|
||||||
|
r"Potrzebuję (.*)",
|
||||||
|
(
|
||||||
|
"Dlaczego potrzebujesz %1?",
|
||||||
|
"Do czego potrzebne ci jest %1?",
|
||||||
|
"Czy jesteś pewien, że potrzebujesz %1?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Kto ciebie stworzył(.*)",
|
||||||
|
(
|
||||||
|
"Jarvis został stworzony przez. Dawid Hajder, Jakub Pietrzak, Piotr Biskup i Wiktor Bombola.",
|
||||||
|
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Dlaczego ty nie (.*)",
|
||||||
|
(
|
||||||
|
"Naprawdę myślisz, że ja nie %1?",
|
||||||
|
"Być może w końcu zacznę %1.",
|
||||||
|
"Czy naprawdę chcesz żebym %1?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Dlaczego nie mogę (.*)",
|
||||||
|
(
|
||||||
|
"Czy uważasz, że powinieneś %1?",
|
||||||
|
"Gdybyś mógł %1, to co byś zrobił dalej?",
|
||||||
|
"Nie wiem -- dlaczego nie możesz %1?",
|
||||||
|
"Naprawdę próbowałeś?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Nie mogę (.*)",
|
||||||
|
(
|
||||||
|
"Skąd wiesz, że nie możesz %1?",
|
||||||
|
"Być może mógłbyś %1 gdybyś próbował.",
|
||||||
|
"Co by od ciebie wymagało %1?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Jestem (.*)",
|
||||||
|
(
|
||||||
|
"Przyszedłeś do mnie bo jesteś %1?",
|
||||||
|
"Jak długo jesteś %1?",
|
||||||
|
"Jak się czujesz będąc %1?",
|
||||||
|
"Jesteś zadowolony, że jesteś %1?",
|
||||||
|
"Dlaczego mi powiedziałeś, że jesteś %1?",
|
||||||
|
"Czemu myślisz, że jesteś %1?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Jesteś (.*)",
|
||||||
|
(
|
||||||
|
"Dlaczego ma znaczenie, czy jestem %1?",
|
||||||
|
"Wolisz, gdybym nie był %1?",
|
||||||
|
"Być może uważasz, że jestem %1.",
|
||||||
|
"Mogę być %1 -- co o tym myślisz?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Co (.*)",
|
||||||
|
(
|
||||||
|
"Dlaczego pytasz?",
|
||||||
|
"Jak odpowiedź na to pomogłaby ci?",
|
||||||
|
"Co o tym myślisz?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"How (.*)",
|
||||||
|
(
|
||||||
|
"How do you suppose?",
|
||||||
|
"Perhaps you can answer your own question.",
|
||||||
|
"What is it you're really asking?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Because (.*)",
|
||||||
|
(
|
||||||
|
"Is that the real reason?",
|
||||||
|
"What other reasons come to mind?",
|
||||||
|
"Does that reason apply to anything else?",
|
||||||
|
"If %1, what else must be true?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"(.*) sorry (.*)",
|
||||||
|
(
|
||||||
|
"There are many times when no apology is needed.",
|
||||||
|
"What feelings do you have when you apologize?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Hello(.*)",
|
||||||
|
(
|
||||||
|
"Hello... I'm glad you could drop by today.",
|
||||||
|
"Hi there... how are you today?",
|
||||||
|
"Hello, how are you feeling today?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"I think (.*)",
|
||||||
|
("Do you doubt %1?", "Do you really think so?", "But you're not sure %1?"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"(.*) friend (.*)",
|
||||||
|
(
|
||||||
|
"Tell me more about your friends.",
|
||||||
|
"When you think of a friend, what comes to mind?",
|
||||||
|
"Why don't you tell me about a childhood friend?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(r"Yes", ("You seem quite sure.", "OK, but can you elaborate a bit?")),
|
||||||
|
(
|
||||||
|
r"(.*) computer(.*)",
|
||||||
|
(
|
||||||
|
"Are you really talking about me?",
|
||||||
|
"Does it seem strange to talk to a computer?",
|
||||||
|
"How do computers make you feel?",
|
||||||
|
"Do you feel threatened by computers?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Is it (.*)",
|
||||||
|
(
|
||||||
|
"Do you think it is %1?",
|
||||||
|
"Perhaps it's %1 -- what do you think?",
|
||||||
|
"If it were %1, what would you do?",
|
||||||
|
"It could well be that %1.",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"It is (.*)",
|
||||||
|
(
|
||||||
|
"You seem very certain.",
|
||||||
|
"If I told you that it probably isn't %1, what would you feel?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Can you (.*)",
|
||||||
|
(
|
||||||
|
"What makes you think I can't %1?",
|
||||||
|
"If I could %1, then what?",
|
||||||
|
"Why do you ask if I can %1?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Can I (.*)",
|
||||||
|
(
|
||||||
|
"Perhaps you don't want to %1.",
|
||||||
|
"Do you want to be able to %1?",
|
||||||
|
"If you could %1, would you?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"You are (.*)",
|
||||||
|
(
|
||||||
|
"Why do you think I am %1?",
|
||||||
|
"Does it please you to think that I'm %1?",
|
||||||
|
"Perhaps you would like me to be %1.",
|
||||||
|
"Perhaps you're really talking about yourself?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"You\'re (.*)",
|
||||||
|
(
|
||||||
|
"Why do you say I am %1?",
|
||||||
|
"Why do you think I am %1?",
|
||||||
|
"Are we talking about you, or me?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"I don\'t (.*)",
|
||||||
|
("Don't you really %1?", "Why don't you %1?", "Do you want to %1?"),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"I feel (.*)",
|
||||||
|
(
|
||||||
|
"Good, tell me more about these feelings.",
|
||||||
|
"Do you often feel %1?",
|
||||||
|
"When do you usually feel %1?",
|
||||||
|
"When you feel %1, what do you do?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"I have (.*)",
|
||||||
|
(
|
||||||
|
"Why do you tell me that you've %1?",
|
||||||
|
"Have you really %1?",
|
||||||
|
"Now that you have %1, what will you do next?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"I would (.*)",
|
||||||
|
(
|
||||||
|
"Could you explain why you would %1?",
|
||||||
|
"Why would you %1?",
|
||||||
|
"Who else knows that you would %1?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"Is there (.*)",
|
||||||
|
(
|
||||||
|
"Do you think there is %1?",
|
||||||
|
"It's likely that there is %1.",
|
||||||
|
"Would you like there to be %1?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"My (.*)",
|
||||||
|
(
|
||||||
|
"I see, your %1.",
|
||||||
|
"Why do you say that your %1?",
|
||||||
|
"When your %1, how do you feel?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"You (.*)",
|
||||||
|
(
|
||||||
|
"We should be discussing you, not me.",
|
||||||
|
"Why do you say that about me?",
|
||||||
|
"Why do you care whether I %1?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(r"Why (.*)", ("Why don't you tell me the reason why %1?", "Why do you think %1?")),
|
||||||
|
(
|
||||||
|
r"I want (.*)",
|
||||||
|
(
|
||||||
|
"What would it mean to you if you got %1?",
|
||||||
|
"Why do you want %1?",
|
||||||
|
"What would you do if you got %1?",
|
||||||
|
"If you got %1, then what would you do?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"(.*) mother(.*)",
|
||||||
|
(
|
||||||
|
"Tell me more about your mother.",
|
||||||
|
"What was your relationship with your mother like?",
|
||||||
|
"How do you feel about your mother?",
|
||||||
|
"How does this relate to your feelings today?",
|
||||||
|
"Good family relations are important.",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"(.*) father(.*)",
|
||||||
|
(
|
||||||
|
"Tell me more about your father.",
|
||||||
|
"How did your father make you feel?",
|
||||||
|
"How do you feel about your father?",
|
||||||
|
"Does your relationship with your father relate to your feelings today?",
|
||||||
|
"Do you have trouble showing affection with your family?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
(
|
||||||
|
r"(.*) child(.*)",
|
||||||
|
(
|
||||||
|
"Did you have close friends as a child?",
|
||||||
|
"What is your favorite childhood memory?",
|
||||||
|
"Do you remember any dreams or nightmares from childhood?",
|
||||||
|
"Did the other children sometimes tease you?",
|
||||||
|
"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"(.*)",
|
||||||
|
(
|
||||||
|
"Proszę powiedz mi więcej o tym.",
|
||||||
|
"Zmieńmy proszę temat... Opowiedz mi o Twojej rodzinie.",
|
||||||
|
"Czy możesz to rozwinąć?",
|
||||||
|
"Dlaczego to powiedziałeś %1?",
|
||||||
|
"Rozumiem.",
|
||||||
|
"Bardzo ciekawe.",
|
||||||
|
"Jasne. A co ci to mówi?",
|
||||||
|
"To dobrze.",
|
||||||
|
"Jak się z tym czujesz?",
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
jarvis_chatbot = Chat(pairs, reflections)
|
||||||
|
|
||||||
|
|
||||||
|
def jarvis_chat():
|
||||||
|
print("Kolega do rozmowy\n---------")
|
||||||
|
print('Rozmawiaj z programem wpisując wyrażenia po polsku, zaczynając zdanie od wielkiej litery. Wpisz "wyjdź" gdy skończysz.')
|
||||||
|
print("=" * 70)
|
||||||
|
print("Cześć :D Mam na imię Jarvis.\nCo tam słychać?")
|
||||||
|
|
||||||
|
jarvis_chatbot.converse()
|
||||||
|
|
||||||
|
|
||||||
|
def demo():
|
||||||
|
jarvis_chat()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
demo()
|
Loading…
Reference in New Issue
Block a user