public class

SimpleGrammarData

com.nuwarobotics.service.agent.SimpleGrammarData

Class Overview

SimpleGrammarData allow user easy to create grammar data

 //prepare local command list
 ArrayList cmdList = new ArrayList() {{
     add("今日の天気");
     add("おはよう");
 }};//you can customize this list
 //Create Grammar class object
 //NOTICE : please only use "lower case letter" as naming of grammar name
 SimpleGrammarData mGrammarData = new SimpleGrammarData("example");
 //setup local command list to grammar class
 for (String string : cmdList) {
     mGrammarData.addSlot(string);
     Log.d(TAG, "add string : " + string);
 }
 //generate grammar data
 mGrammarData.updateBody();
 //create and update Grammar to Robot
 Log.d(TAG, "createGrammar " + mGrammarData.body);
 //NOTICE : please only use "lower case letter" as naming of grammar name
 mRobotAPI.createGrammar(mGrammarData.grammar, mGrammarData.body); // Regist cmd

The body in SimpleGrammarData is JSON format and as below
 {
  "version“: 1.0,
   “grammar": "test", //grammar set name
   “command": {  //command array, if single command only, just only write single array
     "single": [
       "今日の天気",
       "おはよう"
     ],
    }
 }
 

Summary

Public Constructors
SimpleGrammarData(String grammar)
Identifier of grammar object
Public Methods
boolean addSlot(String... cmds)
Add recognize keyword as local command
Set<String> getAllCmdSet()
get all local command list
boolean updateBody()
Update grammar to system

Public Constructors

public SimpleGrammarData (String grammar)

Identifier of grammar object

Parameters
grammar grammar name

Public Methods

public boolean addSlot (String... cmds)

Add recognize keyword as local command

Parameters
cmds keyword string
Returns
  • add success or not

public Set<String> getAllCmdSet ()

get all local command list

Returns
  • string set of command list

public boolean updateBody ()

Update grammar to system

Returns
  • success or not