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

📄 jp_09.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
            // add the vertex_index into start_a list if its parent is optional      //      if (is_optional) {	start_a.concat(next);	is_optional = false;      }            for(int i = 0; i < end_a.length(); i++) {	long end_index = end_a(i).vertex_index_d;	GraphVertex<String>* parent_vert = vertex_list_d[end_index];	boolean find_arc = findArcIndex(end_index, next.vertex_index_d);	if(!find_arc) {	    	  Pair< Long, Long> pair;	  Long t_1(end_index);	  Long t_2(next.vertex_index_d);	  pair.assign(t_1, t_2);	        	  arc_index_d.concat(pair);	  //draw arc from parent to child (next)	  //	  if (!epsilon) {	    graph_d.insertArc(parent_vert, child_vert, false, weight);	  }	  else {	    graph_d.insertArc(parent_vert, child_vert, true);	  }	}      } // end for loop(i=0)            if ((op_token2 != (JSGFToken*)NULL) &&	  (op_token2->operator_d[0].eq(L"*"))) {	end_a.concat(next);      }      else {	if(end_a.length() != 0) {	  end_a.clear(Integral::RELEASE);	}	end_a.concat(next);	      }    }    // if the next token is ( leading a grouping unit    // recursively process the grouped rule expansion    //    else if (next.operator_d[0].eq(L"(")) {            Vector<JSGFToken> sub_start;      Vector<JSGFToken> sub_end;      // get weight      //      boolean epsilon = true;      float weight = 0.0;      if (next.weighted_terminal_d) {	epsilon = false;	weight = next.weight_d;      }	             drawUnit(sub_start, sub_end, false);            JSGFToken* op_token2 = (JSGFToken*)NULL;      boolean is_loop = false;      boolean is_optional = false;	      // determining if next token is "+" or "*"      // sub_end.length() to test if it is recursive grammar      //      if (final_d.length() != 0 ) {	op_token2 = final_d.peek();	if (op_token2->operator_d[0].eq(L"+") ||	    op_token2->operator_d[0].eq(L"*" )) {	  if (op_token2->operator_d[0].eq(L"*")) {	    	    // setting optional_group_flag in the sub_start	    //	    for(int j = 0; j < sub_start.length(); j++) {	      sub_start(j).is_head_group_d = true;	    }	  }	  	  if (sub_end.length() != 0)	    is_loop = true;	  else {	    // skip (recursive grammar)+	    //	    is_loop = false;	  }	  final_d.remove(&dummy);	}      }            if(is_loop) {	for(int i = 0; i < sub_end.length(); i++) {	  GraphVertex<String>* end_vert = vertex_list_d[sub_end(i).vertex_index_d];	  for(int j = 0; j < sub_start.length(); j++) {	    GraphVertex<String>* start_vert = vertex_list_d[sub_start(j).vertex_index_d];	    boolean find_arc = findArcIndex(sub_end(i).vertex_index_d, sub_start(j).vertex_index_d);	    if(!find_arc) {	      	      Pair< Long, Long> pair;	      Long t_1(sub_end(i).vertex_index_d);	      Long t_2(sub_start(j).vertex_index_d);	      pair.assign(t_1, t_2);			      arc_index_d.concat(pair);	      	      // there exists weight problem for + or *	      //draw arc from parent to the child (next)	      //	      graph_d.insertArc(end_vert, start_vert, false, weight);	    }//end if(!find_arc)	  } // end for loop(int j = 0)	} //end for loop(int i = 0)      }      // determing if there exists optional_group token in the start_a      //      for(int j = 0; j < start_a.length(); j++) {	if(start_a(j).is_head_group_d) {	  	    is_optional = true;	    break;	}       }      boolean is_optional_substart = false;            // determing if there exists optional_group token in the sub_start      //      for(int j = 0; j < sub_start.length(); j++) {	if(sub_start(j).is_head_group_d) {	   is_optional_substart = true;	  if(!is_optional) {	    sub_start(j).is_head_group_d = false;	  }	}      }      if(is_optional == true && is_optional_substart == false) {	for(int j = 0; j < start_a.length(); j++) {	  if(start_a(j).is_head_group_d)	  	       start_a(j).is_head_group_d = false;	}      }            for(int j = 0; j < sub_start.length(); j++) {		// get corresponding vertex_index of group tokens	//	JSGFToken child_token = sub_start(j);	Long tmp_index = child_token.vertex_index_d;	// get weight	//	boolean epsilon = true;	float weight = 0.0;	if(!is_loop && next.weighted_terminal_d) {	  epsilon = false;	  weight = next.weight_d;	}	else if (child_token.weighted_terminal_d) {	  epsilon = false;	  weight = child_token.weight_d;	}		// add the vertex_index into start_a list if its parent is optional	//	if (is_optional) {	  start_a.concat(child_token);	}	GraphVertex<String>* child_vert = vertex_list_d[child_token.vertex_index_d];		for(int i = 0; i < end_a.length(); i++) {	  	  long end_index = end_a(i).vertex_index_d;	  GraphVertex<String>* parent_vert = vertex_list_d[end_index];	  boolean find_arc = findArcIndex(end_index, child_token.vertex_index_d);	  if(!find_arc) {	    	    Pair< Long, Long> pair;	    Long t_1(end_index);	    Long t_2(child_token.vertex_index_d);	    pair.assign(t_1, t_2);			    arc_index_d.concat(pair);	    	    //draw arc from parent to the child (next)	    //	    if (!epsilon) {	      graph_d.insertArc(parent_vert, child_vert, false, weight);	    }	    else {	      graph_d.insertArc(parent_vert, child_vert, true);	    }	  } // if(!find_arc)	} // end for loop(i=0)      } // end for loop(j=0)      is_optional = false;      if(sub_end.length() != 0) {	if (is_optional_substart) {	  for(int i = 0; i < sub_end.length(); i++) {	    end_a.concat(sub_end(i));	  }	}	else {	  end_a.clear(Integral::RELEASE);	  for(int i = 0; i < sub_end.length(); i++) {	    end_a.concat(sub_end(i));	  }		}      }      else {	end_a.clear(Integral::RELEASE);      }    } // end if(next.operator_d[0].eq(L"("))    // if the next token is [ leading a optional grouping unit    // recursively process the optional grouped rule expansion    //    else if (next.operator_d[0].eq(L"[")) {            Vector<JSGFToken> sub_start;      Vector<JSGFToken> sub_end;      boolean is_optional = false;      // get weight      //      boolean epsilon = true;      float weight = 0.0;      if (next.weighted_terminal_d) {	epsilon = false;	weight = next.weight_d;      }         drawUnit(sub_start, sub_end, false);      // set is_head_group_d = true for each token of sub_start       //      for(int j = 0; j < sub_start.length(); j++) {	sub_start(j).is_head_group_d = true;      }            JSGFToken* op_token2 = (JSGFToken*)NULL;      boolean is_loop = false;            // determining if next token is "+" or "*"       //      if (final_d.length() != 0 && sub_end.length() != 0) {	op_token2 = final_d.peek();	if (op_token2->operator_d[0].eq(L"+") ||	    op_token2->operator_d[0].eq(L"*" )) {	  final_d.remove(&dummy);	  is_loop = true;	}      }      if(is_loop) {		for(int i = 0; i < sub_end.length(); i++) {	  GraphVertex<String>* end_vert = vertex_list_d[sub_end(i).vertex_index_d];	  for(int j = 0; j < sub_start.length(); j++) {	    GraphVertex<String>* start_vert = vertex_list_d[sub_start(j).vertex_index_d];	    boolean find_arc = findArcIndex(sub_end(i).vertex_index_d, sub_start(j).vertex_index_d);	    if(!find_arc) {	      	      Pair< Long, Long> pair;	      Long t_1(sub_end(i).vertex_index_d);	      Long t_2(sub_start(j).vertex_index_d);	      pair.assign(t_1, t_2);	        	      arc_index_d.concat(pair);	      	      // there exists weight problem for + or *	      //draw arc from parent to the child (next)	      //	      graph_d.insertArc(end_vert, start_vert, false, weight);	    }// end  if(!find_arc) {	  }// end for loop (int j=0)	} //end for loop(int i = 0)      }            // determing if there exists optional_group token in the start_a      //      for(int j = 0; j < start_a.length(); j++) {	if(start_a(j).is_head_group_d) {	  	    is_optional = true;	    break;	}       }      //      boolean is_optional_substart = true;            // determing if there exists optional_group token in the sub_start      //      for(int j = 0; j < sub_start.length(); j++) {	if(sub_start(j).is_head_group_d) {	  if(!is_optional) {	    sub_start(j).is_head_group_d = false;	  }	}      }            for(int j = 0; j < sub_start.length(); j++) {		// get corresponding vertex_index of group tokens	//	JSGFToken child_token = sub_start(j);	Long tmp_index = child_token.vertex_index_d;	// get weight	//	boolean epsilon = true;	float weight = 0.0;	if(!is_loop && next.weighted_terminal_d) {	  epsilon = false;	  weight = next.weight_d;	}	else if (child_token.weighted_terminal_d) {	  epsilon = false;	  weight = child_token.weight_d;	}		// add the vertex_index into start_a list if its parent is optional	//	if (is_optional) {	  start_a.concat(child_token);	}	GraphVertex<String>* child_vert = vertex_list_d[child_token.vertex_index_d];	for(int i = 0; i < end_a.length(); i++) {	  	  long end_index = end_a(i).vertex_index_d;	  GraphVertex<String>* parent_vert = vertex_list_d[end_index];	  boolean find_arc = findArcIndex(end_index, child_token.vertex_index_d);	  if(!find_arc) {	      	    Pair< Long, Long> pair;	    Long t_1(end_index);	    Long t_2(child_token.vertex_index_d);	    pair.assign(t_1, t_2);	        	    arc_index_d.concat(pair);	    	    //draw arc from parent to the child (next)	    //	    if (!epsilon) {	      graph_d.insertArc(parent_vert, child_vert, false, weight);	    }	    else {	      graph_d.insertArc(parent_vert, child_vert, true);	    }	  }//end if(!find_arc) {	} // end for loop(i=0)      } // end for loop(j=0)      is_optional = false;      for(int i = 0; i < sub_end.length(); i++) {	  end_a.concat(sub_end(i));      }    } // end if(next.operator_d[0].eq(L"["))          // if the next is a recursive grammar    //     else if (next.operator_d[0].eq(L"@@")) {            Stack<String> replaced_rules;      // token queue for final processing in graph drawing section      //      Queue<JSGFToken> rule_final;        // replace all rule reference      //      String t;      t = next.rulename_d;            boolean is_processed = false;      // declare dummy arrays      //      Vector<JSGFToken> sub_start;      Vector<JSGFToken> sub_end;      for(long i = 0; i < recursive_grammar_d.length(); i++) {	if(t.eq(recursive_grammar_d(i).first())) {	  is_processed = true;	  sub_start.concat(recursive_grammar_d(i).second());	  sub_end.clear(Integral::RELEASE);	}	      }      if(!is_processed) {	replaced_rules.clear();	replaceRecursionRuleReference(t, replaced_rules, rule_final);		/////////////////////////////////////////////////////////////	Queue<JSGFToken> final = rule_final;	while (!final.isEmpty()) {	  JSGFToken tt;	  final.remove(&tt);	  //tt.printToken();	}	//////////////////////////////////////////////////////////////	// preprocess the token queue final_d by getting rid of weight tokens	// after setting the weight values to their modified object	// tag tokens are also skipped	//	Queue<JSGFToken> tmp_queue;		while (!rule_final.isEmpty()) {	  	  JSGFToken current, next;	  rule_final.remove(&current);	  	  // skip tag token	  //	  if (current.token_type_d == 6) {	    continue;	  }	  // get rid of weight token after assigning its value to appropriate object	  //	  else if (current.token_type_d == 8) {	    	    // get the next token and assign the weight to it	    //	    rule_final.remove(&next);	    next.setTerminalWeight(current);	    tmp_queue.add(&next);	  }	  // otherwise store the token	  //	  else {	    tmp_queue.add(&current);	  }	}  	// update the token queue rule_final	//	rule_final.assign(tmp_queue);      	////////////////////////////////////////////////////////////////	/////////////////// debug /////////////////////////////////////	final = rule_final;	while (!final.isEmpty()) {	  JSGFToken tt;	  final.remove(&tt);	  //	tt.printToken();	  if (tt.token_type_d == 5 || tt.token_type_d == 7) {	    String cc;	    cc.assign(tt.vertex_index_d);	    // cc.debug(L"-------------index");	  } 	  Float w(tt.weight_d);	  //	w.debug(L"--------------------weight----");	}	//////////////////////////////////////////////////////////////	///////////////////////////////////////////////////////////////  		boolean is_alter = false;		// call the recursive function to get start token and end token	// for the right recursive rule	//	searchStartEnd(sub_start, sub_end, is_alter, rule_final);	sub_end.clear(Integral::RELEASE);	Pair<String, Vector<JSGFToken> > pair;	Vector<JSGFToken> start_tokens;	start_tokens.concat(sub_start);	pair.assign(t, start_tokens);      	recursive_grammar_d.concat(pair);      }            // connect the sub_start with end_a      //''''''''''''''''''''''''      boolean is_optional = false;            // determing if there exists optional_group token in the start_a      //      for(int j = 0; j < start_a.length(); j++) {	if(start_a(j).is_head_group_d) {	  	  is_optional = true;	  break;	}       }      boolean is_optional_substart = false;            // determing if there exists optional_group token in the sub_start      //      for(int j = 0; j < sub_start.length(); j++) {	if(sub_start(j).is_head_group_d) {	  is_optional_substart = true;	  if(!is_optional) {	    sub_start(j).is_head_group_d = false;	  }	}      }      if(is_optional == true && is_optional_substart == false) {	for(int j = 0; j < start_a.length(); j++) {	  if(start_a(j).is_head_group_d) 	  	       start_a(j).is_head_group_d = false;	}      }            for(int j = 0; j < sub_start.length(); j++) {		// get corresponding vertex_index of group tokens	//	JSGFToken child_token = sub_start(j);	Long tmp_index = child_token.vertex_index_d;	// get weight	//	boolean epsilon = true;	float weight = 0.0;	if (next.weighted_terminal_d) {	  epsilon = false;	  weight = next.weight_d;	}	// add the vertex_index into start_a list if its parent is optional	//	if (is_optional) {	  start_a.concat(child_token);	}	GraphVertex<String>* child_vert = vertex_list_d[child_token.vertex_index_d];		for(int i = 0; i < end_a.length(); i++) {	  	  long end_index = end_a(i).vertex_index_d;	  GraphVertex<String>* parent_vert = vertex_list_d[end_index];	  boolean find_arc = findArcIndex(end_index, child_token.vertex_index_d);	  if(!find_arc) {	      	    Pair< Long, Long> pair;	    Long t_1(end_index);	    Long t_2(child_token.vertex_index_d);	    pair.assign(t_1, t_2);	        	    arc_index_d.concat(pair);	    

⌨️ 快捷键说明

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