The answer to the question about rank in C ++ chat?

I have this personal C ++ project and am stuck right now. It seems that many people have asked questions on this topic, and I would like to apologize now if this is a repeated question.

In any case, this project is a chat bot that will respond based on user input. Currently , it takes the entire query and looks for a match using long inefficient operator strings if. If he finds a match, he will respond with a specific answer.

The reason I came here is that I’m tired of writing very laborious and ineffective statements ifthat don’t even catch all the options for the same question. I am not looking for code or solutions that take data from Wikipedia or something like that. I would like the bot chat to simply answer simple questions.

During my conversation with if statements, I came up with an idea. Why don't I use keywords the same way a search engine rates web pages?

I wrote code to calculate how many times a keyword (or several different ones) exists in a query. The problem is how to evaluate them correctly in order to find the best answer? I would suggest that answers and keywords should be saved in a special way.

My list of answers to my main question:

1 .. When the request is received, rank it through the ini file, where it has the keyword (s) in the key and the answer as the value. If there are several answers, take another keyword and find it, as well as the original (zoom out). Doing this enough time should give the correct answer.

Pros: it fits what I need to do, and this is what I can understand in C ++.

Cons: seems long and inefficient, almost like plunging into if statements again ...

2. Using the SQL database, tell her to find the answer. Not sure how this will be done.

Pros: It will be light weight, since the database computer will handle the search and can be quite detailed.

: , ++. , , , if.

3. , , , , - AIML ( ).

: - .

: "" , , , AIML.

, - , ++, , . , , - ++. PHP, ++.

+5
1

- IRC , AIML . , , . AIML - , , . AIML, ++, "" ( ) AIML. , ( , ) libaiml.xml(, AIML ):

#include <aiml.h>
// ...
using namespace aiml;

// setup Ai bot:
cInterpreter* interpreter = cInterpreter::newInterpreter();

try {
    if(!interpreter->initialize("libaiml.xml"))
        throw 1;
} catch(int _ret) {
    cout << "ERROR: " << interpreter->getErrorStr(interpreter->getError())
         << " (" << interpreter->getError() << ")" << endl;
    if(!interpreter->getRuntimeErrorStr().empty())
        cout << "Runtime Error: " << interpreter->getRuntimeErrorStr() << endl;
}

interpreter->respond(message, "name", result);, . libaiml ( libxml2), http://www.alicebot.org/downloads/programs.html.(scroll ++, libaiml; , std_utils). , - , . , libaiml , .

XML, . http://www.alicebot.org/TR/2011/. ( libaiml).

!

0

All Articles