em có một bài tập nhờ a chỉ hộ em với:
em cần viêt 1 chương trình như con gà simsimi tức là khi người dùng nhập 1 dòng input, thì chương trinh sẽ trả lời gì đó có liên quan
ví dụ:
“My dad is a good person”
chương trình phải trả lời lại gì đó như là
“tell me more about your dad”
thầy chỉ hướng dẫn là
There are two main components to ELIZA:
Parsing the user’s input into a list of words (ignoring spaces, punctuation, and upper/lower-case distinctions)
Matching the list of words against the patterns that are to be recognized. More specific patterns should be checked first, and more general patterns only tried if no specific match was found.
For the first part, you’ll probably want to use a vector to contain the list of words. You can read a full line of input using getline(), and then scan through it one character at a time, either constructing a new word, adding the character to the current word, adding the word to the vector, or skipping over the character (depending on whether the character is a letter, punctuation, etc.)
For the second part, although you could use a large if-else chain and hard-code all the patterns, you should try to see if you can come up with a way of storing the patterns, and then searching through them generically.
xin anh giúp em 1 chương trình mẫu để em nghiệm lại, bài này sẽ là kì thi final của em, em không có copy ạ, em được phép nghiên cứu các tài liệu bên ngoài, và em sẽ phải viết lại trong lớp nên sẽ không thể copy được.