1

我正在创建一个类似聊天机器人的应用程序,我需要知道应用程序何时达到某种状态。

目前我正在使用字符串来找出对话的主题是什么。

String usersaid = text.toString();
if (usersaid.contains("topic-relevant word") {
    execStateRelevantMethod();
}

但是我想知道是否有更可靠的方法来做到这一点。如:

if (usersaid.contains("what time is it") {
    state.set(timeQuery);
}
if (state == timeQuery) {
    execStateRelevantMethod();
}

我已经制定了这些状态命令,以向您展示我要问的意思。

4

0 回答 0