/** * Set the enabled state of the listed rule. * * @param ruleName * the name of the rule. * @param enabled * the new enabled state. */ public void SetEnabled(String ruleName, bool enabled) { JSGFRuleState state = Rules.Get(ruleName); if (state._isEnabled != enabled) { state._isEnabled = enabled; } }
public bool IsEnabled(String ruleName) { JSGFRuleState state = Rules.Get(ruleName); if (state != null) { return(state._isEnabled); } return(false); }
/** * Test whether the specified rule is public. * * @param ruleName * the name of the rule. */ public bool IsRulePublic(String ruleName) { JSGFRuleState state = Rules.Get(ruleName); if (state == null) { return(false); } return(state.IsPublic); }
/** * Return the data structure for the named rule. * * @param ruleName * the name of the rule. */ public JSGFRule GetRule(String ruleName) { JSGFRuleState state = Rules.Get(ruleName); if (state == null) { return(null); } return(state.rule); }
/** * Gets the Rule with the given name after it has been stripped, or throws * an Exception if it is unknown. */ private JSGFRule GetKnownRule(String ruleName) { JSGFRuleState state = Rules.Get(ruleName); if (state == null) { throw new ArgumentException("Unknown Rule: " + ruleName); } return(state.rule); }
/** * add a sample sentence to the list of sample sentences that go with the * specified rule */ public void AddSampleSentence(String ruleName, String sample) { JSGFRuleState state = Rules.Get(ruleName); if (state == null) { return; } state.Samples.Add(sample); }
/** * Returns a string containing the specification for this grammar. * * @return specification for this grammar. */ public override String ToString() { StringBuilder sb = new StringBuilder(); sb.Append("#JSGF V1.0;").Append(_lineSeparator); sb.Append(_lineSeparator); sb.Append(FormatComment(_grammarDocComment)); sb.Append(_lineSeparator); sb.Append("grammar ").Append(_name).Append(';').Append(_lineSeparator); sb.Append(_lineSeparator); // Set of comment keys (The import such comment belongs to). var docComments = _importDocComments.keySet(); for (int i = 0; i < Imports.Count; i++) { String curImport = '<' + Imports[i].GetRuleName() + '>'; if (docComments.Contains(curImport)) { sb.Append(FormatComment(_importDocComments.get(curImport))); sb.Append(_lineSeparator); sb.Append("import ").Append(curImport + ';').Append(_lineSeparator); sb.Append(_lineSeparator); } } docComments = _ruleDocComments.keySet(); foreach (var entry in Rules) { var rule = entry.Key; if ((docComments.Count > 0) && docComments.Contains(rule)) { sb.Append(FormatComment(_ruleDocComments.get(rule))).Append(_lineSeparator); } JSGFRuleState state = entry.Value; if (state.IsPublic) { sb.Append("public "); } sb.Append('<').Append(rule).Append("> = ").Append(state.rule).Append(';').Append(_lineSeparator); sb.Append(_lineSeparator); } return(sb.ToString()); }
public void SetRuleChanged(String ruleName, bool changed) { JSGFRuleState state = Rules.Get(ruleName); state.IsChanged = changed; }
public bool IsRuleChanged(String ruleName) { JSGFRuleState state = Rules.Get(ruleName); return(state.IsChanged); }
/** * Set a rule in the grammar either by creating a new rule or updating an * existing rule. * * @param ruleName * the name of the rule. * @param rule * the definition of the rule. * @param isPublic * whether this rule is public or not. */ public void SetRule(String ruleName, JSGFRule rule, bool isPublic) { JSGFRuleState state = new JSGFRuleState(rule, true, isPublic); Rules.Put(ruleName, state); }