quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_mmedia.a #include <LanguageModelJSGF.h> boolean read(Sof& sof, long tag, const String& cname = CLASS_NAME); HierarchicalDigraph& getHDigraph();
description:Sof sof; sof.open("lm_jsgf_obj.sof", File::READ_ONLY); LanguageModelJSGF lmjsgf; lmjsgf.read(sof, 0); HierarchicalDigraph hg; hg.assign(lmjsgf.getHDigraph());
static const String LanguageModelJSGF::CLASS_NAME = L"LanguageModelJSGF";
static const SearchSymbol LanguageModelJSGF::START_SYMBOL = L"S";
static const SearchSymbol LanguageModelJSGF::TERM_SYMBOL = L"T";
static const long LanguageModelJSGF::DEF_LEVEL = -1;
static const String LanguageModelJSGF::DEF_PARAM = L"";
static const String LanguageModelJSGF::PARAM_GRAMMARS = L"grammars";
static const String LanguageModelJSGF::TOP_GRAMMAR_NAME = L"sentence";
static const String LanguageModelJSGF::COMMENT_GRAMMAR_NAME = L"// Define the grammar name";
static const String LanguageModelJSGF::COMMENT_TERM_SYMBOL = L"// Define the ISIP graph terminal symbol";
static const String LanguageModelJSGF::COMMENT_START_SYMBOL = L"// Define the ISIP graph start symbol";
static const String LanguageModelJSGF::COMMENT_RESERVED_GRAMMAR = L"// Define the ISIP reserved grammar name";
static const String LanguageModelJSGF::COMMENT_SYMBOLS = L"// Define the symbols";
static const String LanguageModelJSGF::COMMENT_RULES = L"// Define the rules";
static const String LanguageModelJSGF::COMMENT_CONTEXT_RULE = L"// Define the context rule";
static const String LanguageModelJSGF::PARAM_JSGF_START_SYMBOL(L"ISIP_JSGF_1_0_START");
static const String LanguageModelJSGF::PARAM_JSGF_TERM_SYMBOL(L"ISIP_JSGF_1_0_TERM");
static const String LanguageModelJSGF::START_SYMBOL_REFERENCE(L"ISIP_JSGF_START");
static const String LanguageModelJSGF::TERM_SYMBOL_REFERENCE(L"ISIP_JSGF_TERM");
static const String LanguageModelJSGF::OPERATOR_OPENPARENS(L"(");
static const String LanguageModelJSGF::OPERATOR_CLOSEPARENS(L")");
static const String LanguageModelJSGF::OPERATOR_OPENANGLEBRACKET(L"<");
static const String LanguageModelJSGF::OPERATOR_CLOSEANGLEBRACKET(L">");
static const String LanguageModelJSGF::OPERATOR_FWDSLASH(L"/");
static const String LanguageModelJSGF::OPERATOR_EQUALS(L"=");
static const String LanguageModelJSGF::OPERATOR_ALTERNATION(L"|");
static const String LanguageModelJSGF::OPERATOR_SEMICOLON(L";");
static const long LanguageModelJSGF::OPERATOR_OPEN_POS = 0;
static const long LanguageModelJSGF::OPERATOR_CLOSE_POS = 1;
static const String LanguageModelJSGF::KEYWORD_PUBLIC(L"public");
static const String LanguageModelJSGF::KEYWORD_GRAMMAR(L"grammar");
static const String LanguageModelJSGF::GRAMMAR_DEF_BASE(L"network.grammar.");
static const String LanguageModelJSGF::PARAM_UNDERSCORE(L"_");
static const String LanguageModelJSGF::PARAM_JSGF_VERSION(L"#JSGF V1.0;");
static const String LanguageModelJSGF::CONTEXT_LABEL_PREFIX(L"G_");
static const String LanguageModelJSGF::RULE_NAME_BASE(L"extension");
static const long ERR = 100102;
HierarchicalDigraph hg_d;
RuleModel abnf_model_d;
Vector< Vector < Vector<JSGFToken> > > grammars_d;
static MemoryManager mgr_d;
SearchSymbol start_symbol_d;
SearchSymbol
static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* msg) const;
~LanguageModelJSGF();
LanguageModelJSGF();
boolean assign(const LanguageModelJSGF& arg);
boolean assign(const LanguageModelBase& arg);
boolean read(Sof& sof, long tag, const String& cname = CLASS_NAME);
boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean write(Sof& sof, long tag, const String& cname = CLASS_NAME) const;
boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;
long sofSize() const;
boolean eq(const LanguageModelJSGF& arg) const;
boolean eq(const LanguageModelBase& arg) const;
boolean clear(Integral::CMODE ctype);
const String& className() const;
RuleModel getRuleModel();
RuleModel getABNFRuleModel();
boolean setRuleModel(const RuleModel& rm_a);
boolean setABNFRuleModel(const RuleModel& rm_a);
Vector< Vector < Vector<JSGFToken> > >getJSGFGrammars();
boolean setJSGFGrammars(Vector< Vector < Vector<JSGFToken> > > grammars_a);
boolean writeGrammars(Sof& sof, long level, HierarchicalDigraph& h_digraph) const;
boolean writeSymbolType(Sof& sof, long level, const String& pname, Vectorsymbol_list) const;
boolean writeContextMapping(Sof& sof, long level, HierarchicalDigraph& h_digraph) const;
boolean readSymbolType(Sof& sof, long level, const String& pname, Vector& symbol_list_a, SofParser& parser);
boolean readGrammars(Sof& sof, const String& pname, long level, boolean use_context, Vector* symbol_table, SofParser& parser);
boolean readJSGF(Sof& sof, String grammar, Vector& sub_symbol_list, DiGraph & sub_graph, String& sub_graph_name);
boolean readContextMapping(Sof& sof, const String& pname, long level, SofParser&parser);
boolean alignGraphs(Vector<Vector<JSGFToken> >& token_vector, Vector<SearchSymbol>& symbol_table, Vector<String>& graph_name_list);
boolean convertGraph(DiGraph<String>& symbol_graph, DiGraph<SearchNode>& node_graph, long& num_symbols, long level);
ProductionRuleSet convertJSGFtoABNF(Vectorgrammar);
Vector<JSGFToken> convertBNFtoJSGF(ProductionRuleSet rules);
ProductionRule findRule(String ruleref, ProductionRuleSet rules);
boolean convertTokensToString(Vectortoken_grammar, String& string_grammar) const;
// declare an sof object to parse the file // Sof sof; // open the file for reading // sof.open("lm_jsgf_obj.sof", File::READ_ONLY); // declare a LMJSGF object to read the grammars // LanguageModelJSGF lmjsgf; // read the grammars // lmjsgf.read(sof, 0); // declare an HierarchicalDigraph object to store the grammars in DiGraph form // HierarchicalDigraph hg; // retrieve the grammars from the LMJSGF object, and store them in the HD object // hg.assign(lmjsgf.getHDigraph());