⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lm_11.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
      // debug message      //      debug_string.assign(L"debug 14");      debug_string.debug(L"point");            // getting current rule name;    //    GraphArc<SearchNode>* current_arc;    current_arc = subgroup_list_a.getCurr();        // check if the arc has been processed and put into subgroup_table_a    //    boolean is_subgroup = false;    for(long i = 0; i < subgroup_table_a.length(); i++) {       SingleLinkedList<GraphArc<SearchNode> > tmp_group;       tmp_group = subgroup_table_a(i);      // debug message      //      debug_string.assign(L"debug 15");      debug_string.debug(L"point");               // loop through all GraphArcs       //       for(boolean more_arcs = tmp_group.gotoFirst();	   more_arcs; more_arcs = tmp_group.gotoNext()) {      // debug message      //      debug_string.assign(L"debug 16");      debug_string.debug(L"point");        	 // get current arc	 //	 GraphArc<SearchNode>* tmp_arc;	 tmp_arc = tmp_group.getCurr();	 if(current_arc->eq(*tmp_arc)) {	   is_subgroup = true;	   break;	 }           }       if(is_subgroup)	 break;           }        if(is_subgroup) {            // debug message      //      debug_string.assign(L"debug 17");      debug_string.debug(L"point");              continue;    }       SingleLinkedList<GraphArc<SearchNode> > new_group;    new_group.insert(current_arc);    float weight = current_arc->getWeight();    GraphVertex<SearchNode>* current_vert = current_arc->getVertex();    boolean more_a = subgroup_list_a.gotoNext();    while(more_a) {      GraphArc<SearchNode>* next_arc;      next_arc = subgroup_list_a.getCurr();      GraphVertex<SearchNode>* next_vert = next_arc->getVertex();      float next_weight = next_arc->getWeight();      if(weight == next_weight && current_vert->compareVertices(*next_vert)) {	new_group.insert(next_arc);	//subgroup_list_a.remove(next_arc);      }      more_a = subgroup_list_a.gotoNext();    }// end while(more_a)    subgroup_table_a.concat(new_group);    more_a = subgroup_list_a.gotoFirst();  }// end for(more_arcs)     Vector<SingleLinkedList<GraphArc<SearchNode> > > subgroup_table_tmp;  Long num_subgroup = subgroup_table_a.length();      // loop through all new group  //  for (long k =0; k < subgroup_table_a.length(); k++) {    SingleLinkedList<GraphArc<SearchNode> > new_group;    new_group = subgroup_table_a(k);          // debug message      //      debug_string.assign(L"debug 18");      debug_string.debug(L"point");            // loop through all GraphArcs    //    for(boolean more_arcs = new_group.gotoFirst();	more_arcs; more_arcs = new_group.gotoNext()) {      // debug message      //      debug_string.assign(L"debug 19");      debug_string.debug(L"point");              // getting current rule name;      //      GraphArc<SearchNode>* current_arc;      current_arc = new_group.getCurr();            SingleLinkedList<GraphArc<SearchNode> > new_sub_group;      new_sub_group.insert(current_arc);      GraphVertex<SearchNode>* current_vert = current_arc->getVertex();      SingleLinkedList<Long> common_parent;      Vector<Float> common_weight;      for(long i = 0; i < num_vertices_a; i++){	      // debug message      //      debug_string.assign(L"debug 20");      debug_string.debug(L"point");        	if(!(verts_a[i])->eq(*current_vert)) {	  // loop through all the available arcs starting from the current vertex	  //	  for (boolean more_paths = verts_a[i]->gotoFirst(); more_paths;	       more_paths = verts_a[i]->gotoNext()) {      // debug message      //      debug_string.assign(L"debug 21");      debug_string.debug(L"point");        	    // get the next vertex and its weight	    //	    GraphArc<SearchNode>* tmp_arc = verts_a[i]->getCurr();	    GraphVertex<SearchNode>* next_vert = tmp_arc->getVertex();	    float weight = tmp_arc->getWeight();	    if(next_vert->eq(*current_vert)) {	      Long index(i);	      common_parent.insert(&index);	      Float tmp_weight;	      tmp_weight.assign(weight);	      common_weight.concat(tmp_weight);	      break;	    }	  }// end for( boolean more_paths)	}// end if(!(verts_a[i])      }            boolean more_ab = new_group.gotoNext();        while(more_ab) {      // debug message      //      debug_string.assign(L"debug 22");      debug_string.debug(L"point");        	GraphArc<SearchNode>* next_arc;	next_arc = new_group.getCurr();	GraphVertex<SearchNode>* next_vert = next_arc->getVertex();	long j, match;	j =0;	match = 0;		// checking if current_vert and next_vert has common parent and weight	//	for(boolean more_p = common_parent.gotoFirst();	    more_p; more_p = common_parent.gotoNext()) {	  GraphVertex<SearchNode>* common_vertex;	  Long *common_vertex_index;	  common_vertex_index = common_parent.getCurr();	  common_vertex = verts_a[(long)*common_vertex_index];	  for (boolean more_paths = common_vertex->gotoFirst(); more_paths;	       more_paths = common_vertex->gotoNext()) {	    	    // get the next vertex and its weight	    //	    GraphArc<SearchNode>* tmp_arc = common_vertex->getCurr();	    GraphVertex<SearchNode>* tmp_vert = tmp_arc->getVertex();	    float weight = tmp_arc->getWeight();	    if(next_vert->eq(*tmp_vert) && common_weight(j).eq(weight)) {	      match++;	      break;	    }	  }// end for( boolean more_paths)	  j++;	}		if(j == match ) {      // debug message      //      debug_string.assign(L"debug 23");      debug_string.debug(L"point");        	  new_sub_group.insert(next_arc);	  //new_group.remove(next_arc);	}      // debug message      //      debug_string.assign(L"debug 24");      debug_string.debug(L"point");        	more_ab = new_group.gotoNext();        }// end while(more_ab)      // debug message      //      debug_string.assign(L"debug 25");      debug_string.debug(L"point");              subgroup_table_tmp.concat(new_sub_group);    } //end for)boolean more_arcs)  }// end for(!subgroup_table_a)   // exit gracefully  //  return true;}// method: digraphToJSGF//// arguments://   DiGraph<SearchNode> graph_a: (input) a DiGraph object to be converted//   SearchSymbol grammar_name_a: (input) the JSGF grammar name for the graph//// return: (output) a JSGF grammar string converted from DiGraph//// This method converts the input grammar from NATIVE format// to JSGF format. Each SearchSymbol is picked up from the input symbol table// according to the SearchNode index in the graph.//                 String LanguageModel::digraphToJSGF(DiGraph<SearchNode>& graph_a,				    SearchSymbol grammar_name_a) {    // declare and initialize a JSGF grammar string  //  String JSGF_output(L"  // Define the grammar name\n");  JSGF_output.concat(L"  grammar network.grammar.");  JSGF_output.concat(grammar_name_a);  JSGF_output.concat(L";\n\n");  JSGF_output.concat(L"  // Define the rules\n");  JSGF_output.concat(L"  public");  String debug_string;  // get all vertices in the input graph  //  long num_vertices = graph_a.length() + 2;  GraphVertex<SearchNode>* verts[num_vertices];  // set the first vertex  //  verts[0] = graph_a.getStart();    graph_a.gotoFirst();  for(long i = 1; i < num_vertices - 1; i++) {    verts[i] = (GraphVertex<SearchNode>*)graph_a.getCurr();    graph_a.gotoNext();  }  // set the last vertex  //  verts[num_vertices - 1] = graph_a.getTerm();  // set the rules names  //  String rule_names[num_vertices];  // init the initial rule names  //  rule_names[0].assign(L"ISIP_JSGF_1_0_START");  rule_names[num_vertices - 1].assign(L"ISIP_JSGF_1_0_TERM");  for (int i = 1; i < num_vertices -1 ; i++){    rule_names[i].assign(L"extention");    rule_names[i].concat((long)i);  }  // set the rule bodies  //  String rule_bodies[num_vertices];  GraphVertex<SearchNode>* curr_vert = (GraphVertex<SearchNode>*) NULL;    for (int i = 0; i < num_vertices; i++){    // get current vertex    //    curr_vert = verts[i];    // set the symbol name    //    SearchSymbol symbol_name;    if (verts[i]->isStart()){      symbol_name.assign(L"<ISIP_JSGF_1_0_START>");    }    else if (verts[i]->isTerm()){      symbol_name.assign(L"<ISIP_JSGF_1_0_TERM>");    }    else{      verts[i]->getItem()->getSymbol(symbol_name);    }        rule_bodies[i].assign(symbol_name);        // seperate the symbol name from    // following tokens    //    rule_bodies[i].concat(L" ");    String vertices_rule;        int flag = 0;        // loop through all the available arcs starting from the current vertex    //    for (boolean more_paths = curr_vert->gotoFirst(); more_paths;	 more_paths = curr_vert->gotoNext()) {      // get current arc      //      GraphArc<SearchNode>* curr_arc = curr_vert->getCurr();      float weight = curr_arc->getWeight();      GraphVertex<SearchNode>* tmp_vert = curr_arc->getVertex();      int index = -1;      for (index = 0; index < num_vertices; index++){	if ( verts[index] == tmp_vert ){	  break;	}      }      String rule_name = rule_names[index];            // write the rule      //      // if it is the first one      //      if ( flag == 0){	vertices_rule.concat(L"( /");      }      else {	vertices_rule.concat(L"| ( /");	      }            vertices_rule.concat(weight);      vertices_rule.concat(L"/ <");      vertices_rule.concat(rule_name);	      vertices_rule.concat(L"> )");      flag++;    }    // group all next vertices    //    if ( flag > 1 ){      String tmp_body(L"(");      tmp_body.concat(vertices_rule);      tmp_body.concat(L")");      rule_bodies[i].concat(tmp_body);    }    else {      rule_bodies[i].concat(vertices_rule);    }      }      // write the whole rule  //  for (int i = 0; i < num_vertices; i++){    // set the rule name    //    String rule_name;        if (verts[i]->isStart()){      rule_name.assign(grammar_name_a);    }    else if (verts[i]->isTerm()){      continue;    }    else{      rule_name = rule_names[i];    }        JSGF_output.concat(L"  ");    JSGF_output.concat(L"<");    JSGF_output.concat(rule_name);    JSGF_output.concat(L"> = ");    JSGF_output.concat(rule_bodies[i]);    JSGF_output.concat(L" ;\n");      }    // return the JSGF grammar string  //  return JSGF_output;}

⌨️ 快捷键说明

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