AIMLProcessorExtension: tag not working in aiml

2019-05-24 10:27发布

I am trying to create my own tag in aiml using program tab. The tag is not working. What is the problem?

Java code:

public class AIMLExtension implements AIMLProcessorExtension{
  public Set<String> extensionTagNames = Utilities.stringSet("check");
  @Override
  public Set<String> extensionTagSet() {
    // TODO Auto-generated method stub
    return extensionTagNames;
  }

  private String contactId(Node node, ParseState ps) {
    return "Success :P";
  }

  @Override
  public String recursEval(Node node, ParseState ps) {
    // TODO Auto-generated method stub
    try {
        String nodeName = node.getNodeName();
        if (nodeName.equals("check"))
            return contactId(node, ps);
        else return (AIMLProcessor.genericXML(node, ps));
    } catch (Exception ex) {
        ex.printStackTrace();
        return "";
    }
  }
}

AIML code: I am getting I have no answerfor the below code.

<category>
  <pattern>CHECKING EXTENSION</pattern>
  <template>RESTCALL <check> </template>
</category>

AIML code : I am getting RESTCALL <check/> itself for the below code.

<category>
  <pattern>CHECKING EXTENSION</pattern>
  <template>RESTCALL <check/> </template>
</category>

标签: java aiml
1条回答
倾城 Initia
2楼-- · 2019-05-24 11:09

Explore program-ab and see how its tags work. I created a tag by replicating code for person tag in program ab code.

查看更多
登录 后发表回答