lm_09.cc

来自「这是一个从音频信号里提取特征参量的程序」· CC 代码 · 共 98 行

CC
98
字号
// file: $isip/class/asr/LanguageModel/lm_09.cc// version: $Id: lm_09.cc,v 1.6 2002/07/16 03:11:39 wang Exp $//// isip include files//#include "LanguageModel.h"#include <Console.h>// method: readJSGF//// arguments://      Sof& sof_a: (input) pointer pointing to the Sof file to be read//      Vector<String>& nonspeech_symbol_list_a: (output) non-speech symbols//      Vector<String>& sub_symbol_list_a: (output) symbol list//      DiGraph<String>& graph_a: (output) graph converted from the file//      String sub_graph_name_d: (output) grammar name for the graph//// return: a boolean value indicating status//boolean LanguageModel::readJSGF(Sof& sof_a,				Vector<String>& nonspeech_symbol_list_a,				Vector<String>& sub_symbol_list_a,				DiGraph<String>& sub_graph_a,				String& sub_graph_name_a) {  // declare a JSGF parser  //  JSGFParser parser;  // count the number of expression lines read into the parser  //  long expression_counter = 0;    // a temporary string to hold each line of grammar in the following loop  //  String JSGF_line, grammar_str;  sof_a.gets(JSGF_line, Sof::BUFFER_SIZE);    // read all lines of the JSGF grammar file until  // "};" indicating the end of the grammar is reached  //  while(!JSGF_line.eq(L"};", true)) {      // read each line of the grammar file    // and set the line as an expression in the JSGF parser    //    if(!JSGF_line.eq(L"", true)) {      parser.setExpression(JSGF_line);      expression_counter++;      grammar_str.concat(JSGF_line);      grammar_str.concat(L"\n");    }    // read next line    //    sof_a.gets(JSGF_line, Sof::BUFFER_SIZE);  }  // parse the JSGF grammar and convert it to a ISIP DiGraph in the parser  //  parser.parseJSGF(graph_start_d, graph_term_d);  // check if this grammar is the definition for the non-speech symbols  //  if (isNonSpeechDefinition(grammar_str)) {    nonspeech_symbol_list_a = parser.getSymbolList();  }  else {    // pass symbol list of the current JSGF grammar    //    sub_symbol_list_a = parser.getSymbolList();    // get the DiGraph from the parser    //    sub_graph_a = parser.getGraph();        // get the grammar name from the parser    //    String graph_name = parser.getGrammarName();    String sub_str;    String delim(L". ;");    long pos = 7;        while(graph_name.tokenize(sub_str, pos, delim)) {      sub_graph_name_a = sub_str;    }  } // else end    // exit gracefully  //  return true;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?