00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00027 #ifndef BOSS_NODE_H
00028 #define BOSS_NODE_H
00029
00030 using namespace std;
00031
00032 #include <string>
00033 #include <vector>
00034 #include "xercesc/dom/DOM.hpp"
00035 #include "tdsp/dsp_vector.h"
00036 #include "boss_utility/dom_userdata.h"
00037 #include "boss_utility/dom_tools.h"
00038 #include "boss_utility/boss_config.h"
00039
00048 class BOSS_Node {
00049
00050 friend ostream & operator << (ostream & out, const BOSS_Node & n);
00051
00052 public:
00053 enum Node_Type {
00054 UNKNOWN = 0,
00055 WORD = 1,
00056 MORPHEME = 2,
00057 SYLLABLE = 3,
00058 PHONE = 4,
00059 HALFPHONE = 5,
00060 INITIAL = 6,
00061 FINAL = 7
00062 };
00063
00064 protected:
00065 BOSS::Config & cl;
00066 const xercesc::DOMNode * unit_node;
00067 DOM_UserData * user_data;
00068 Node_Type type;
00069 unsigned pos;
00070 double cost;
00071 BOSS_Node *pred;
00072
00073
00074 unsigned Num;
00075 string tkey;
00076 string treal;
00077 string cleft;
00078 string cright;
00079 string pmode;
00080 int pint;
00081 unsigned first;
00082 unsigned last;
00083 unsigned stress;
00084 float lf0;
00085 float rf0;
00086 float avgf0;
00087 float rms;
00088 dsp::vector< float > lmel;
00089 dsp::vector< float > rmel;
00090 vector< float > makeVector(string tmp) const;
00091
00092 public:
00093 BOSS_Node(BOSS::Config & cl);
00094 BOSS_Node(const BOSS_Node & b);
00095 BOSS_Node(BOSS::Config & cl, const Node_Type & t);
00096 BOSS_Node(BOSS::Config & cl, const xercesc::DOMNode * node, const Node_Type & t, const unsigned & p);
00097 virtual ~BOSS_Node();
00098 BOSS_Node & operator = (const BOSS_Node & b);
00099 string getResult(const string & q) const { return user_data->getResult(pos, q); }
00100 DOM_UserData * getUserData() const { return user_data; }
00101 inline Node_Type getNodeType() const { return type; }
00102 inline bool BOSS_Node::realNode() const
00103 {
00104 switch(type) {
00105 case INITIAL:
00106 case FINAL:
00107 return false;
00108 break;
00109 default:
00110 return true;
00111 break;
00112 }
00113 return true;
00114 }
00115 bool virtualNode() const { return !realNode(); }
00116 inline double getCost() const { return cost; }
00117 inline void setCost(double c) { cost = c; }
00118 inline void setPredecessor(BOSS_Node * predecessor) { pred = predecessor; }
00119 inline BOSS_Node * getPredecessor() const { return pred; }
00120 inline unsigned getPosition() const { return pos; }
00121
00122 };
00123
00124
00128 typedef vector< BOSS_Node* > UNIT_Graph_Column;
00132 typedef vector< UNIT_Graph_Column > UNIT_Graph;
00133
00134 ostream & operator << (ostream & out, const BOSS_Node::Node_Type & t);
00135 ostream & operator << (ostream & out, const UNIT_Graph_Column & c);
00136 ostream & operator << (ostream & out, const UNIT_Graph & g);
00137
00139
00140 #endif
00141