I don't have much programming experience in python, so my question can be very simple. I am working on a project for a school where we need to create a way out of user input (we want to emulate Eliza, but in a very simple way). Right now, the only thing the program does is search for keywords and respond accordingly. However, since I'm going to a French school, and everything is in French, I need to use accents (like é, è, à, á). And here the problem arises: I can’t use accents in my predefined list of keywords (so these are not keywords from the user, but in my own program: /)
Here you have the whole program:
print("Salut!")
(Here is the predefined keyword that we use to find out if there is negation, and if the user’s sentence contains some humiliating adjectives, we need to make it much bigger to make our bot more human, but it’s just a principle)
negation = ("ne", "n'", "pas", "guere", "ne", "plus", "jamais")
AnD = ("artificiel", "cree", "mecanique", "invente", "concu", "construit", "programme", "innove", "fabrique")
But here's the problem: to launch our program, we had to remove all the accents. Therefore, words such as guère, créé, mécanique, inventé, programé become guere, cree, mecanique, invente, program, and in some cases this changes the meaning of the word (for example, a program becomes a noun instead of an adjective).
adj_neg_decl = None
nega = None
def decl_non_neg_adj_neg(statement):
if (statement.endswith('.')) and (nega == False) and (adj_neg_decl == True):
print(AnD_ici + '? Mais moi je suis humain. Ca se voit pas?')
else:
print('tralalalala')
while True:
statement = raw_input("> ").lower()
if statement == "au revoir":
print("Au revoir!")
break
(Here we are just looking for negatives and adjectives - if you have another (more efficient) way to do this, I would like to hear your suggestions! I could also learn some new things :))
for i in negation:
if i in statement:
nega = True
break
else:
nega = False
for i in AnD:
if i in statement:
adj_neg_decl = True
AnD_ici = i
break
else:
adj_nej_decl = False
decl_non_neg_adj_neg(statement)
for var in (adj_neg_decl, nega):
var = None
, , , unicode utf-8, , ... ? - , ?
:)