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

📄 angr_02.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
📖 第 1 页 / 共 3 页
字号:
// file: $isip/class/mmedia/AnnotationGraph/angr_02.cc// version: $Id: angr_02.cc,v 1.4 2002/12/23 05:57:20 parihar Exp $//// isip include files//#include "AnnotationGraph.h"#include <Console.h>// method: diagnose//// arguments://  Integral::DEBUG level: (input) debug level for diagnostics//// return: a boolean value indicating status//boolean AnnotationGraph::diagnose(Integral::DEBUG level_a) {  //----------------------------------------------------------------------  //  // 0. preliminaries  //  //----------------------------------------------------------------------  // output the class name  //  if (level_a > Integral::NONE) {    SysString output(L"diagnosing class ");    output.concat(CLASS_NAME);    output.concat(L": ");    Console::put(output);    Console::increaseIndention();  }  // --------------------------------------------------------------------  //  // 1. required public methods  //  // --------------------------------------------------------------------  // set indentation  //    if (level_a > Integral::NONE) {    Console::put(L"testing required public methods...\n");    Console::increaseIndention();   }  // declare annotation graphs  //  String gname_00(L"SWB0");  String gtype_00(L"SWB0");  String gtype_01(L"SWB1");  String gtype_03(L"SWB2");  String gtype_04(L"SWB3");        AnnotationGraph angr_00(gname_00, gtype_00);    // test the id methods  //  if (!angr_00.getId().eq(gname_00)) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  // test the type methods  //  if (!angr_00.getType().eq(gtype_00)) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_00.setType(gtype_01);  if (!angr_00.getType().eq(gtype_01)) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  // test the create/delete anchor method  //  String gname_01(L"Timit");    Anchor* ancr_00;  Anchor* ancr_01;    String newid_00;  String newid_01;  String newid_02;      Float offset_00(2.4);  Float offset_01(4.9);  Float offset_02(8.9);    String unit_00(L"seconds");    AnnotationGraph angr_01(gname_01, gtype_01);  newid_00 = angr_01.createAnchor(gname_01, offset_00, unit_00);  ancr_00 = angr_01.getAnchorById(newid_00);  newid_01 = angr_01.createAnchor(gname_01, offset_01, unit_00);  ancr_01 = angr_01.getAnchorById(newid_01);    if (ancr_00 == (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (angr_01.getAnchorById(newid_00) != ancr_00) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnchor(ancr_00);  ancr_00 = angr_01.getAnchorById(newid_00);  if (ancr_00 != (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (ancr_01 == (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (angr_01.getAnchorById(newid_01) != ancr_01) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnchor(ancr_01);  ancr_01 = angr_01.getAnchorById(newid_01);  if (ancr_01 != (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    // large scale testing  //  int num_val = 100;  String lsnames_00[num_val];  Anchor*  lsanchors_00[num_val];  for (int i=0; i < num_val; i++) {    lsnames_00[i] = angr_01.createAnchor(gname_01, offset_00, unit_00);    lsanchors_00[i] = angr_01.getAnchorById(lsnames_00[i]);    if (lsanchors_00[i] == (Anchor*)NULL) {      return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);    }  }  for (int i=0; i < num_val; i++) {      Anchor* anchor = angr_01.getAnchorById(lsnames_00[i]);       if (anchor != lsanchors_00[i]) {      return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);    }  }  for (int i=0; i < num_val; i++) {    angr_01.deleteAnchor(lsanchors_00[i]);  }    // test the add/delete anchor methods  //  String ancrid_00(L"Anchor1");  String ancrid_01(L"Anchor2");  Anchor* ancr_02 = new Anchor(ancrid_00, offset_00, unit_00);  Anchor* ancr_03 = new Anchor(ancrid_01, offset_01, unit_00);    angr_01.addAnchor(ancr_02);  angr_01.addAnchor(ancr_03);    if (angr_01.getAnchorById(ancrid_00) != ancr_02) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    if (angr_01.getAnchorById(ancrid_01) != ancr_03) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnchor(ancr_02);  if (angr_01.getAnchorById(ancrid_00) != (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnchor(ancr_03);  if (angr_01.getAnchorById(ancrid_01) != (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    // large scale testing  //  String anchorid;  for (int i=0; i < num_val; i++) {    anchorid.assign(L"Anchor");    anchorid.concat((long)i);    lsanchors_00[i] = new Anchor(anchorid, offset_00, unit_00);    angr_01.addAnchor(lsanchors_00[i]);  }  for (int i=0; i < num_val; i++) {    anchorid.assign(L"Anchor");    anchorid.concat((long)i);        if (angr_01.getAnchorById(anchorid) != lsanchors_00[i]) {      return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);    }  }  for (int i=0; i < num_val; i++) {    angr_01.deleteAnchor(lsanchors_00[i]);  }    // test the create/delete annotation mothods  //  Annotation* anno_00;  Annotation* anno_01;    String atype_00(L"Word");  String atype_01(L"Transcription");   Anchor* ancr_04 = new Anchor(ancrid_00, offset_00, unit_00);  Anchor* ancr_05 = new Anchor(ancrid_01, offset_01, unit_00);    newid_00 = angr_01.createAnnotation(gname_01, ancr_04, ancr_05, atype_00);  newid_01 = angr_01.createAnnotation(gname_01, ancr_04, ancr_05, atype_01);  anno_00 = angr_01.getById(newid_00);  if (anno_00 == (Annotation*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (angr_01.getById(newid_00) != anno_00) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }      anno_01 = angr_01.getById(newid_01);    if (anno_01 == (Annotation*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (angr_01.getById(newid_01) != anno_01) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnnotation(anno_00);  if (angr_01.getById(newid_00) != (Annotation*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnnotation(anno_01);  if (angr_01.getById(newid_01) != (Annotation*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    // large scale testing  //  Annotation*  lsannotation_00[num_val];  for (int i=0; i < num_val; i++) {    lsnames_00[i] = angr_01.createAnnotation(gname_01, ancr_04, ancr_05, atype_00);    lsannotation_00[i] = angr_01.getById(lsnames_00[i]);  }  for (int i=0; i < num_val; i++) {    if (angr_01.getById(lsnames_00[i]) != lsannotation_00[i]) {      return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);    }      }  for (int i=0; i < num_val; i++) {    angr_01.deleteAnnotation(lsannotation_00[i]);      }  angr_01.deleteAnchor(ancr_04);  if (angr_01.getAnchorById(ancrid_00) != (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnchor(ancr_05);  if (angr_01.getAnchorById(ancrid_01) != (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    // test the add/delete annotation mothods  //  String annoid_00(L"Annotation1");  String annoid_01(L"Annotation2");  ancr_04 = new Anchor(ancrid_00, offset_00, unit_00);  ancr_05 = new Anchor(ancrid_01, offset_01, unit_00);  Annotation* anno_02 = new Annotation(annoid_00, ancr_04, ancr_05, atype_00);  Annotation* anno_03 = new Annotation(annoid_01, ancr_04, ancr_05, atype_01);    angr_01.add(anno_02);  angr_01.add(anno_03);  anno_00 = angr_01.getById(annoid_00);  if (anno_00 == (Annotation*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (angr_01.getById(annoid_00) != anno_00) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }      anno_01 = angr_01.getById(annoid_01);    if (anno_01 == (Annotation*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (angr_01.getById(annoid_01) != anno_01) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnnotation(anno_00);  if (angr_01.getById(annoid_00) != (Annotation*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnnotation(anno_01);  if (angr_01.getById(annoid_01) != (Annotation*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  // large scale testing  //  String annotationid;    for (int i=0; i < num_val; i++) {    annotationid.assign(L"Annotation");    annotationid.concat((long)i);    lsannotation_00[i] = new Annotation(annotationid, ancr_04, ancr_05, atype_00);    angr_01.add(lsannotation_00[i]);  }  for (int i=0; i < num_val; i++) {    annotationid.assign(L"Annotation");    annotationid.concat((long)i);        if (angr_01.getById(annotationid) != lsannotation_00[i]) {      return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);    }  }  for (int i=0; i < num_val; i++) {    angr_01.deleteAnnotation(lsannotation_00[i]);      }  angr_01.deleteAnchor(ancr_04);  if (angr_01.getAnchorById(ancrid_00) != (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  angr_01.deleteAnchor(ancr_05);  if (angr_01.getAnchorById(ancrid_01) != (Anchor*)NULL) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    // test the set/get offset methods  //  float offset;  String ancrid_02(L"Anchor3");  String ancrid_03(L"Anchor4");    Anchor* ancr_06 = new Anchor(ancrid_02, offset_00, unit_00);  angr_01.addAnchor(ancr_06);  Anchor* ancr_07 = new Anchor(ancrid_03, offset_00, unit_00);  angr_01.addAnchor(ancr_07);    offset = 0.23456;  angr_01.setAnchorOffset(ancr_06, offset);  if (angr_01.getAnchorOffset(ancr_06) != offset) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  offset = 4.3356;  angr_01.setAnchorOffset(ancr_07, offset);  if (angr_01.getAnchorOffset(ancr_07) != offset) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    if (!angr_01.unsetAnchorOffset(ancr_06)) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (!angr_01.unsetAnchorOffset(ancr_07)) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  offset = 0.0;  angr_01.setAnchorOffset(ancr_06, offset);  if (angr_01.getAnchorOffset(ancr_06) != offset) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  offset = 0.0;  angr_01.setAnchorOffset(ancr_07, offset);  if (angr_01.getAnchorOffset(ancr_07) != offset) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }    angr_01.deleteAnchor(ancr_06);  angr_01.deleteAnchor(ancr_07);  // set up the annotation graph  //  String gname_02(L"Treebank");  AnnotationGraph angr_02(gname_02, gtype_03);  String ancrid_04(L"Anchor5");  String ancrid_05(L"Anchor6");  String ancrid_06(L"Anchor7");    String atype_02(L"T/he");  String atype_03(L"T/she");  Annotation* anno_04;  Annotation* anno_04a;    Annotation* anno_05;  DoubleLinkedList<Anchor> anchor_list;    DoubleLinkedList<Annotation> anno_list;    Anchor* ancr_08 = new Anchor(ancrid_04, offset_00, unit_00);  Anchor* ancr_09 = new Anchor(ancrid_05, offset_01, unit_00);  Anchor* ancr_10 = new Anchor(ancrid_06, offset_02, unit_00);    newid_00 = angr_02.createAnnotation(gname_02, ancr_08, ancr_09, atype_02);  anno_04 = angr_02.getById(newid_00);  newid_01 = angr_02.createAnnotation(gname_02, ancr_09, ancr_10, atype_03);  anno_05 = angr_02.getById(newid_01);  // test the incoming and outgoing methods  //  if (!angr_02.getIncomingAnnotationSet(ancr_08, anno_list)) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (anno_list.length() != 0) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);  }  if (!angr_02.getOutgoingAnnotationSet(ancr_10, anno_list)) {    return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__);

⌨️ 快捷键说明

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