示例#1
0
 /**
  * featches the rules associated with the string
  *
  * @param result
  * @return
  * @throws GrammarException
  */
 RuleParse getRuleParseFromString(String result) throws GrammarException {
   BaseRecognizer jsapiRecognizer = new BaseRecognizer(getGrammar().getGrammarManager());
   try {
     jsapiRecognizer.allocate();
   } catch (Exception e) {
     e.printStackTrace();
   }
   RuleGrammar ruleGrammar = new BaseRuleGrammar(jsapiRecognizer, getGrammar().getRuleGrammar());
   RuleParse ruleParse = ruleGrammar.parse(result, null);
   return ruleParse;
 }
示例#2
0
 /**
  * Retrieves the rule parse for the given result
  *
  * @param the recognition result
  * @return the rule parse for the result
  * @throws GrammarException
  */
 RuleParse getRuleParse(Result result) throws GrammarException {
   String resultText = result.getBestFinalResultNoFiller();
   BaseRecognizer jsapiRecognizer = new BaseRecognizer(getGrammar().getGrammarManager());
   try {
     jsapiRecognizer.allocate();
   } catch (EngineException | EngineStateError e) {
     System.err.println("failed to allocate jsapi recognizer: " + e.getMessage());
   }
   RuleGrammar ruleGrammar = new BaseRuleGrammar(jsapiRecognizer, getGrammar().getRuleGrammar());
   RuleParse ruleParse = ruleGrammar.parse(resultText, null);
   return ruleParse;
 }