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

📄 andx_05.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 2 页
字号:
// file: $isip/class/asr/AnnotationIndex/anno_5.cc// version: $Id: andx_05.cc,v 1.2 2002/11/13 00:21:46 alphonso Exp $//// isip include files//#include "AnnotationIndex.h"// method: clear//// arguments://   Integral::CMODE cmode: (input) clear mode//// return: logical error status//// this method clears the content of the current object//boolean AnnotationIndex::clear(Integral::CMODE cmode_a) {  // declare local variables  //  boolean status = false;  status = ancrset_d.clear(cmode_a);  status &= ancr_by_id_d.clear(cmode_a);    status &= ancrset_by_offset_d.clear(cmode_a);  status &= anno_by_id_d.clear(cmode_a);  status &= anno_by_type_d.clear(cmode_a);  status &= start_by_offset_d.clear(cmode_a);  status &= end_by_offset_d.clear(cmode_a);  status &= incoming_d.clear(cmode_a);  status &= outgoing_d.clear(cmode_a);  status &= by_feature_d.clear(cmode_a);    // return the ;ogical status  //  return status;  }// method: eq//// arguments://   const AnnotationIndex& arg: (input) annotation Index//// return: logical error status//// method determines if the input and the current graphs are equal//boolean AnnotationIndex::eq(const AnnotationIndex& arg_a) const {  // determine if the member data are equal  //  if (!ancrset_d.eq(arg_a.ancrset_d)) {    return false;  }  if (!ancr_by_id_d.eq(arg_a.ancr_by_id_d)) {    return false;  }  if (!ancrset_by_offset_d.eq(arg_a.ancrset_by_offset_d)) {    return false;  }  if (!anno_by_id_d.eq(arg_a.anno_by_id_d)) {    return false;  }  if (!anno_by_type_d.eq(arg_a.anno_by_type_d)) {    return false;  }  if (!start_by_offset_d.eq(arg_a.start_by_offset_d)) {    return false;  }  if (!end_by_offset_d.eq(arg_a.end_by_offset_d)) {    return false;  }  if (!incoming_d.eq(arg_a.incoming_d)) {    return false;  }  if (!outgoing_d.eq(arg_a.outgoing_d)) {    return false;  }  if (!by_feature_d.eq(by_feature_d)) {    return false;  }    // return the logical status  //  return true;}// method: assign//// arguments://   const AnnotationIndex& arg: (input) annotation Index//// return: logical error status//// method assigns the input annotation Index to the current one//boolean AnnotationIndex::assign(const AnnotationIndex& arg_a) {  // declare local variables  //  boolean status = false;  // assign the member data  //  status = ancrset_d.assign(arg_a.ancrset_d);  status &= ancr_by_id_d.assign(arg_a.ancr_by_id_d);    status &= ancrset_by_offset_d.assign(arg_a.ancrset_by_offset_d);  status &= anno_by_id_d.assign(arg_a.anno_by_id_d);  status &= anno_by_type_d.assign(arg_a.anno_by_type_d);  status &= start_by_offset_d.assign(arg_a.start_by_offset_d);  status &= end_by_offset_d.assign(arg_a.end_by_offset_d);  status &= incoming_d.assign(arg_a.incoming_d);  status &= outgoing_d.assign(arg_a.outgoing_d);  status &= by_feature_d.assign(by_feature_d);    // return the logical status  //  return status;   }  // method: add//// arguments://   Annotation* anno: (input) annotation to be added//// return: logical error status//// method to add an annotation to the indexes//boolean AnnotationIndex::add(Annotation* anno_a) {  // declare local variables  //  Vector<String> keys;    HashKey<Anchor> hashkey;  HashTable<String, String> features;    DoubleLinkedList<Annotation> tmplist(DstrBase::USER);      tmplist.insert(anno_a);  // get the start and end anchors of the annotation  //  Anchor* start_anchor = anno_a->getStartAnchor();  Anchor* end_anchor = anno_a->getEndAnchor();  // hash the annotation via the identifier  //  anno_by_id_d.insert(anno_a->getId(), anno_a);  // hash the annotation via the type  //  if (anno_by_type_d.containsKey(anno_a->getType())) {    if (!anno_by_type_d.get(anno_a->getType())->contains(anno_a)) {      anno_by_type_d.get(anno_a->getType())->insert(anno_a);    }  }  else {    anno_by_type_d.insert(anno_a->getType(), &tmplist);  }  // hash the features for the annotation  //  features = anno_a->getFeatureMap();  features.keys(keys);  for (int i=0; i < keys.length(); i++) {    addFeature(anno_a, keys(i), *features.get(keys(i)));  }    // hash the annotation by the start offset if it is anchored  //  if (start_anchor->getAnchored()) {    if (start_by_offset_d.containsKey(start_anchor->getOffset())) {      if (!start_by_offset_d.get(start_anchor->getOffset())->contains(anno_a)) {	start_by_offset_d.get(start_anchor->getOffset())->insert(anno_a);      }    }    else {      start_by_offset_d.insert(start_anchor->getOffset(), &tmplist);    }  }  // hash the annotation by the end offset if it is anchored  //  if (end_anchor->getAnchored()) {    if (end_by_offset_d.containsKey(end_anchor->getOffset())) {      if (!end_by_offset_d.get(end_anchor->getOffset())->contains(anno_a)) {	end_by_offset_d.get(end_anchor->getOffset())->insert(anno_a);      }    }    else {      end_by_offset_d.insert(end_anchor->getOffset(), &tmplist);    }  }      // the annotation leaves the start anchor - add it to the outgoing list  //  hashkey.assign(start_anchor);  if (outgoing_d.containsKey(hashkey)) {    if (!outgoing_d.get(hashkey)->contains(anno_a)) {      outgoing_d.get(hashkey)->insert(anno_a);    }  }  else {    outgoing_d.insert(hashkey, &tmplist);  }    // the annotation enters the end anchor - add it to the incoming list  //  hashkey.assign(end_anchor);  if (incoming_d.containsKey(hashkey)) {    if (!incoming_d.get(hashkey)->contains(anno_a)) {      incoming_d.get(hashkey)->insert(anno_a);    }  }  else {    incoming_d.insert(hashkey, &tmplist);  }    // add the start anchor to the anchor set  //  addAnchor(start_anchor);    // add the end anchor to the anchor set  //    addAnchor(end_anchor);    // exit gracefully  //  return true;}// method: deleteAnnotation//// arguments://   Annotation* anno: (input) annotation to be deleted//// return: logical error status//// method to delete an annotation from the indexes//boolean AnnotationIndex::deleteAnnotation(Annotation* anno_a) {  // declare local variables  //  Vector<String> keys;  HashKey<Anchor> hashkey;  HashTable<String, String> features;    // get the start and end anchors of the annotation  //  Anchor* start_anchor = anno_a->getStartAnchor();  Anchor* end_anchor = anno_a->getEndAnchor();  // delete the annotation via the identifier  //  if (anno_by_id_d.containsKey(anno_a->getId())) {    anno_by_id_d.remove(anno_a->getId());  }    // delete the annotation via the type  //  if (anno_by_type_d.containsKey(anno_a->getType())) {    if (anno_by_type_d.get(anno_a->getType())->find(anno_a)) {      anno_by_type_d.get(anno_a->getType())->remove();    }    if (anno_by_type_d.get(anno_a->getType())->isEmpty()) {      anno_by_type_d.remove(anno_a->getType());    }  }  // delete the features for the annotation  //  features = anno_a->getFeatureMap();  features.keys(keys);  for (int i=0; i < keys.length(); i++) {    deleteFeature(anno_a, keys(i));  }    // delete the annotation by the start offset if it is anchored  //  if (start_anchor->getAnchored()) {    if (start_by_offset_d.containsKey(start_anchor->getOffset())) {      if (start_by_offset_d.get(start_anchor->getOffset())->find(anno_a)) {	start_by_offset_d.get(start_anchor->getOffset())->remove();      }      if (start_by_offset_d.get(start_anchor->getOffset())->isEmpty()) {	start_by_offset_d.remove(start_anchor->getOffset());      }    }  }  // delete the annotation by the end offset if it is anchored  //  if (end_anchor->getAnchored()) {    if (end_by_offset_d.containsKey(end_anchor->getOffset())) {      if (end_by_offset_d.get(end_anchor->getOffset())->find(anno_a)) {	end_by_offset_d.get(end_anchor->getOffset())->remove();      }      if (end_by_offset_d.get(end_anchor->getOffset())->isEmpty()) {	end_by_offset_d.remove(end_anchor->getOffset());      }    }  }  // the annotation leaves the start anchor - remove it to the outgoing list  //  hashkey.assign(start_anchor);  if (outgoing_d.containsKey(hashkey)) {    if (outgoing_d.get(hashkey)->find(anno_a)) {      outgoing_d.get(hashkey)->remove();    }    if (outgoing_d.get(hashkey)->isEmpty()) {      outgoing_d.remove(hashkey);    }  }  // the annotation enters the end anchor - remove it to the incoming list  //  hashkey.assign(end_anchor);  if (incoming_d.containsKey(hashkey)) {    if (incoming_d.get(hashkey)->find(anno_a)) {      incoming_d.get(hashkey)->remove();    }    if (incoming_d.get(hashkey)->isEmpty()) {      incoming_d.remove(hashkey);    }  }    // exit gracefully  //  return true;  }// method: existsFeature//// arguments://   const String& feature: (input) annotation feature//   const String& value: (input) annotation feature value//// return: logical error status//// method to check if a feature-value pair exists//boolean AnnotationIndex::existsFeature(const String& feature_a,				       const String& value_a) {  // declare local variables  //  String index;  // generate the hash index  //  index.assign(feature_a);  index.concat(value_a);    // determine if the key exists  //  return by_feature_d.containsKey(index);}  // method: addFeature//// arguments://   Annotation* anno: (input) annotation//   const String& feature: (input) annotation feature//   const String& value: (input) annotation feature value//// return: logical error status//// method to insert the feature-value pair into the feature map//boolean AnnotationIndex::addFeature(Annotation* anno_a,				    const String& feature_a,				    const String& value_a) {  // declare local variables  //  String index;  DoubleLinkedList<Annotation> tmplist(DstrBase::USER);  tmplist.insert(anno_a);    // generate the hash key  //  index.assign(feature_a);  index.concat(value_a);  // hash the annotation via the feature-value pair  //  if (by_feature_d.containsKey(index)) {    if (!by_feature_d.get(index)->contains(anno_a)) {      by_feature_d.get(index)->insert(anno_a);    }  }  else {    by_feature_d.insert(index, &tmplist);  }      // exit gracefully  //  return true;      }// method: deleteFeature//// arguments://   Annotation* anno: (input) annotation//   const String& feature: (input) annotation feature//// return: logical error status//// method that deletes the feature-value pair from the feature map//boolean AnnotationIndex::deleteFeature(Annotation* anno_a,				       const String& feature_a) {  // declare local variables  //  String value;  String index;    // remove the key value pait from the annotation  //  if (anno_a->existsFeature(feature_a)) {    // generate the hash index    //    value = anno_a->getFeature(feature_a);    index.assign(feature_a);

⌨️ 快捷键说明

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