📄 trans_02.cc
字号:
// file: $isip/class/mmedia/TranscriptionDatabase/trans_02.cc// version: $Id: trans_02.cc,v 1.9 2003/04/18 21:45:43 parihar Exp $//// isip include files//#include "TranscriptionDatabase.h"#include <Console.h>// method: diagnose//// arguments:// Integral::DEBUG level: (input) debug level for diagnostics//// return: a boolean value indicating status//boolean TranscriptionDatabase::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(); } TranscriptionDatabase trans_00; TranscriptionDatabase trans_01; TranscriptionDatabase trans_02; // test the get/set database name methods // String name_00(L"TIDIGITS"); String name_01(L"TIMIT"); trans_00.setDataBaseName(name_00); trans_01.setDataBaseName(name_00); if (trans_00.getDataBaseName().eq(name_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!trans_00.getDataBaseName().eq(name_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } // create the annotation graph // String gtype_00(L"ORTHOGRAPHIC"); String ident_00(L"id_00"); String ident_01(L"id_01"); String ident_02(L"id_02"); String ident_03(L"id_03"); String newid_00; String newid_01; String newid_02; Float offset_00(2.4); Float offset_01(4.9); Float offset_02(7.9); Float offset_03(4.0); Float offset_04(3.7); Float offset_05(0.9); Anchor* ancr_00 = (Anchor*)NULL; Anchor* ancr_01 = (Anchor*)NULL; String unit_00(L"seconds"); String feat_00(L"level"); String value_00(L"word"); String value_01(L"phoneme"); // insert the transcription // AnnotationGraph angr_00(name_00, gtype_00); String atype_00(L"one two three nine zero"); newid_00 = angr_00.createAnchor(name_00, offset_00, unit_00); newid_01 = angr_00.createAnchor(name_00, offset_01, unit_00); ancr_00 = angr_00.getAnchorById(newid_00); ancr_01 = angr_00.getAnchorById(newid_01); newid_00 = angr_00.createAnnotation(name_00, ancr_00, ancr_01, atype_00); if (!angr_00.setFeature(newid_00, feat_00, value_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } // insert the transcription // AnnotationGraph angr_01(name_00, gtype_00); String atype_01(L"one seven four oh"); newid_00 = angr_01.createAnchor(name_00, offset_02, unit_00); newid_01 = angr_01.createAnchor(name_00, offset_03, unit_00); ancr_00 = angr_01.getAnchorById(newid_00); ancr_01 = angr_01.getAnchorById(newid_01); newid_01 = angr_01.createAnnotation(name_00, ancr_00, ancr_01, atype_01); if (!angr_01.setFeature(newid_01, feat_00, value_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } // insert the transcription // AnnotationGraph angr_02(name_00, gtype_00); String atype_02(L"six seven two three four six"); newid_00 = angr_02.createAnchor(name_00, offset_04, unit_00); newid_01 = angr_02.createAnchor(name_00, offset_05, unit_00); ancr_00 = angr_02.getAnchorById(newid_00); ancr_01 = angr_02.getAnchorById(newid_01); newid_02 = angr_02.createAnnotation(name_00, ancr_00, ancr_01, atype_02); if (!angr_02.setFeature(newid_02, feat_00, value_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } // test the insert method // if (!trans_00.insertRecord(ident_00, angr_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!trans_01.insertRecord(ident_00, angr_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!trans_00.insertRecord(ident_01, angr_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!trans_01.insertRecord(ident_01, angr_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!trans_00.insertRecord(ident_02, angr_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!trans_01.insertRecord(ident_02, angr_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } Filename tmp_file00; Integral::makeTemp(tmp_file00); Filename tmp_file01; Integral::makeTemp(tmp_file01); Sof tmp_file_00; tmp_file_00.open(tmp_file00, File::WRITE_ONLY, File::TEXT); Sof tmp_file_01; tmp_file_01.open(tmp_file01, File::WRITE_ONLY, File::TEXT); trans_00.store(tmp_file_00, (long)0); trans_01.store(tmp_file_01, (long)1); tmp_file_00.close(); tmp_file_01.close(); // open the database // trans_00.open(tmp_file00); // trans_01.open(tmp_file01); trans_00.read(tmp_file_00, (long)0); // trans_01.read(tmp_file_01, (long)1); // test the get methods // AnnotationGraph angx_00; if (!trans_00.getRecord(ident_00, angx_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!angr_00.eq(angx_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } /* if (!trans_01.getRecord(ident_00, angx_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!angr_00.eq(angx_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } */ AnnotationGraph angx_01; if (!trans_00.getRecord(ident_01, angx_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!angr_01.eq(angx_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } /* if (!trans_01.getRecord(ident_01, angx_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!angr_01.eq(angx_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } */ AnnotationGraph angx_02; if (!trans_00.getRecord(ident_02, angx_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!angr_02.eq(angx_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } /* if (!trans_01.getRecord(ident_02, angx_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!angr_02.eq(angx_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } */ // test the get methods // DoubleLinkedList<Annotation> records_00; if (!trans_00.getRecord(ident_00, feat_00, value_00, records_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!records_00.getFirst()->getType().eq(atype_00)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } DoubleLinkedList<Annotation> records_01; if (!trans_00.getRecord(ident_01, feat_00, value_00, records_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!records_01.getFirst()->getType().eq(atype_01)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } DoubleLinkedList<Annotation> records_02; if (!trans_00.getRecord(ident_02, feat_00, value_00, records_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } if (!records_02.getFirst()->getType().eq(atype_02)) { return Error::handle(name(), L"diagnose", Error::TEST, __FILE__, __LINE__); } // close the database // trans_00.close(); // trans_01.open(); // clear allocated memory // angr_00.clear(); angr_01.clear(); angr_02.clear(); angx_00.clear(); angx_01.clear(); angx_02.clear();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -