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

📄 jp_09.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
	    //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;      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 is vertical bar | for alternatives    //    else if (next.operator_d[0].eq(L"|")) {      boolean is_optional = false;            Vector<JSGFToken> sub_start;      Vector<JSGFToken> sub_end;      // set optional = false      //      if (is_optional) {	is_optional = false;      }            // get weights for group tokens      //........................      drawUnit(sub_start, sub_end, true);      for(int j = 0; j < sub_start.length(); j++) {		// get corresponding vertex_index of group tokens	//	JSGFToken child_token = sub_start(j);		start_a.concat(child_token);	      } // end for loop(j=0)      for(int i = 0; i < sub_end.length(); i++) {	end_a.concat(sub_end(i));      }    } // endif (next.operator_d[0].eq(L"|"))  } // end of the while loop  // exit gracefully  //  return true;}// method: searchStartEnd//// arguments: Vector<JSGFToken>& start_a: (input/output) start token of//                                        the rule //            Vector<JSGFToken>& end_a: (input/output) end token of//                                        the rule//            boolean is_alter: (input) boolean value for determing if the//                              token or group  is alternative//            Queue<JSGFToken>& rule_final_a: (input) storing all tokens for//                                            the grammar// return: a boolean value indicating status//// This method get the start_tokens and end_tokens //boolean JSGFParser::searchStartEnd(Vector<JSGFToken>& start_a, Vector<JSGFToken>& end_a, boolean is_alter, Queue<JSGFToken>& rule_final_a) {     // declare variables  //  JSGFToken current, next, dummy;  JSGFToken* op_token = (JSGFToken*)NULL;  Long curr_vert_index;  boolean is_loop = false;    // get the first token as the current  //  rule_final_a.remove(&current);  // if the current token is ( leading a grouping unit  // recursively process the grouped rule expansion  //  if (current.operator_d[0].eq(L"(")) {    searchStartEnd(start_a, end_a, false, rule_final_a);    // determining if next token is "+" or "*"     //    if (rule_final_a.length() != 0) {      op_token = rule_final_a.peek();      if (op_token->operator_d[0].eq(L"+") ||	  op_token->operator_d[0].eq(L"*" )) {	rule_final_a.remove(&dummy);	is_loop = true;	// set flag (is_head_group_d = true) for each token in the start_a	// 	if (op_token->operator_d[0].eq(L"*" )) {	  for(int i = 0; i < start_a.length(); i++) {	    start_a(i).is_head_group_d = true;	  }	} // end if(op_token->operator_d[0].eq(L"*"))      }     }      } //end if  (current.operator_d[0].eq(L"(")) {    // if the current token is [ leading a optional grouping unit  // recursively process the optional grouped rule expansion  //  if (current.operator_d[0].eq(L"[")) {    searchStartEnd(start_a, end_a, false, rule_final_a);    boolean is_loop = false;        // determining if next token is "+" or "*"     //    if (rule_final_a.length() != 0) {      op_token = rule_final_a.peek();      if (op_token->operator_d[0].eq(L"+") ||	  op_token->operator_d[0].eq(L"*" )) {	rule_final_a.remove(&dummy);	is_loop = true;      }    }    // set flag (is_head_group_d = true) for each token in the start_a    //        for(int i = 0; i < start_a.length(); i++) {      start_a(i).is_head_group_d = true;    }      } // end  if (current.operator_d[0].eq(L"[")) {  // if the next is a recursive grammar  //     if (current.operator_d[0].eq(L"@@")) {    // do nothing    //  }     // if it is terminal or quoted token, create a vertex and add to the array  //  if (current.token_type_d == 5 || current.token_type_d == 7) {    // store corresponding vertex index of the token into the start list    //    curr_vert_index = current.vertex_index_d;    start_a.concat(current);        // determining if next token is "+" or "*"     //    if (rule_final_a.length() != 0) {      op_token = rule_final_a.peek();      if (op_token->operator_d[0].eq(L"+") ||	  op_token->operator_d[0].eq(L"*" )) {	rule_final_a.remove(&dummy);	current.is_head_group_d = true;      }    }      }// end if (current.token_type_d == 5 || current.token_type_d == 7)      // loop through all tokens until meeting a grouping unit or the end  //  while (true) {    JSGFToken*  op_token1;    Long next_vert_index;    if(rule_final_a.length() == 0)      break;    if (is_alter) {            // determining if next token is "]" or ")" or ";"       //      op_token1 = rule_final_a.peek();      if (op_token1->operator_d[0].eq(L"]") ||	  op_token1->operator_d[0].eq(L")")) {	break;      }    }    // get the next token    //    rule_final_a.remove(&next);    if (next.operator_d[0].eq(L"]") ||	next.operator_d[0].eq(L")")) {      break;    }            // if the next token is a terminal or quoted token for sequence    //    if (next.token_type_d == 5 || next.token_type_d == 7) {      // initialize is_optional = false;      //      boolean is_optional = false;            // get weight      //      boolean epsilon = true;      float weight;      if (next.weighted_terminal_d) {	epsilon = false;	weight = next.weight_d;      }      JSGFToken* op_token2 = (JSGFToken*)NULL;            // determining if next token is "+" or "*"       //      if (rule_final_a.length() != 0) {	op_token2 = rule_final_a.peek();	if (op_token2->operator_d[0].eq(L"+") ||	    op_token2->operator_d[0].eq(L"*" )) {	  rule_final_a.remove(&dummy);  	}		// 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;	    if (!op_token2->operator_d[0].eq(L"*")) {	      start_a(j).is_head_group_d = false;	    }	  } 	}// end for loop (int j =0)	      }      else {		// 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;	    start_a(j).is_head_group_d = false;	  } 	}// end for loop (int j =0)      }      // add the vertex_index into start_a list if its parent is optional      //      if (is_optional) {	start_a.concat(next);	is_optional = false;      }            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 weights for group tokens      //........................            searchStartEnd(sub_start, sub_end, false, rule_final_a);            JSGFToken* op_token2 = (JSGFToken*)NULL;      boolean is_optional = false;	      // determining if next token is "+" or "*"       //      if (rule_final_a.length() != 0) {	op_token2 = rule_final_a.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;	    }	  } //end   if (op_token2->operator_d[0].eq(L"*")) {	  rule_final_a.remove(&dummy);	}      }                  // 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);		// add the vertex_index into start_a list if its parent is optional	//	if (is_optional) {	  start_a.concat(child_token);	}	      } // 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;      // get weights for group tokens      //......      //            searchStartEnd(sub_start, sub_end, false, rule_final_a);      // 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;            // determining if next token is "+" or "*"       //      if (rule_final_a.length() != 0 && sub_end.length() != 0) {	op_token2 = rule_final_a.peek();	if (op_token2->operator_d[0].eq(L"+") ||	    op_token2->operator_d[0].eq(L"*" )) {	  rule_final_a.remove(&dummy);	}      }      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;	  }	}      }            for(int j = 0; j < sub_start.length(); j++) {		// get corresponding vertex_index of group tokens	//	JSGFToken child_token = sub_end(j);		// add the vertex_index into start_a list if its parent is optional	//	if (is_optional) {	  start_a.concat(child_token);		}      } // 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"@@")) {      // do nothing      //    }        // if the next is vertical bar | for alternatives    //    else if (next.operator_d[0].eq(L"|")) {            Vector<JSGFToken> sub_start;      Vector<JSGFToken> sub_end;      boolean is_optional = false;            // set optional = false      //      if (is_optional) {	is_optional = false;      }            // get weights for group tokens      //........................      searchStartEnd(sub_start, sub_end, true, rule_final_a);      for(int j = 0; j < sub_start.length(); j++) {		// get corresponding vertex_index of group tokens	//	JSGFToken child_token = sub_start(j);		start_a.concat(child_token);	      } // end for loop(j=0)      for(int i = 0; i < sub_end.length(); i++) {	end_a.concat(sub_end(i));      }    } // endif (next.operator_d[0].eq(L"|"))  } // end of the while loop    // exit gracefully  //  return true;}// method: findArcIndex//// arguments:long first_index_a: (input) parent of arc//           long second_index_a: (input) child of arc//// return: a boolean value indicating status//// This method examine if the graph arc has been connected //boolean JSGFParser::boolean JSGFParser::findArcIndex(long first_index_a, long second_index_a) {  for ( long i=0; i < arc_index_d.length(); i++) {        Long t_1(first_index_a);    Long t_2(second_index_a);    if(t_1.eq(arc_index_d(i).first()) && t_2.eq(arc_index_d(i).second()))      return true;  }  // exit gracefully  //  return false;  }

⌨️ 快捷键说明

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