"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ling_class/EST_Relation.cc" between
speech_tools-2.4-release.tar.gz and speech_tools-2.5.0-release.tar.gz

About: The speech_tools - Edinburgh Speech Tools Library (used by the Festival Speech Synthesis System).

EST_Relation.cc  (speech_tools-2.4-release):EST_Relation.cc  (speech_tools-2.5.0-release)
skipping to change at line 91 skipping to change at line 91
EST_Item *to_root = append(&i); EST_Item *to_root = append(&i);
copy_node_tree_contents(r.root(),to_root); copy_node_tree_contents(r.root(),to_root);
} }
} }
EST_Item *EST_Relation::append(EST_Item *si) EST_Item *EST_Relation::append(EST_Item *si)
{ {
EST_Item *nn; EST_Item *nn;
if (this == 0) if (p_tail == 0)
{
EST_warning("EST_Relation: no relation to append to");
return 0;
}
else if (p_tail == 0)
{ {
nn = new EST_Item(this, si); nn = new EST_Item(this, si);
p_head = nn; p_head = nn;
} }
else else
nn = p_tail->insert_after(si); nn = p_tail->insert_after(si);
p_tail = nn; p_tail = nn;
// if (!si->f_present("id") && utt()) // if (!si->f_present("id") && utt())
// si->fset("id", utt()->next_id()); // si->fset("id", utt()->next_id());
skipping to change at line 125 skipping to change at line 120
EST_Item *EST_Relation::prepend() EST_Item *EST_Relation::prepend()
{ {
return prepend(0); return prepend(0);
} }
EST_Item *EST_Relation::prepend(EST_Item *si) EST_Item *EST_Relation::prepend(EST_Item *si)
{ {
EST_Item *nn; EST_Item *nn;
if (this == 0) if (p_head == 0)
{
EST_warning("EST_Relation: no relation to prepend to");
return 0;
}
else if (p_head == 0)
{ {
nn = new EST_Item(this,si); nn = new EST_Item(this,si);
p_tail = nn; p_tail = nn;
} }
else else
nn = p_head->insert_before(si); nn = p_head->insert_before(si);
p_head = nn; p_head = nn;
return nn; return nn;
} }
skipping to change at line 152 skipping to change at line 142
EST_Relation::~EST_Relation() EST_Relation::~EST_Relation()
{ {
clear(); clear();
} }
int EST_Relation::length() const int EST_Relation::length() const
{ {
EST_Item *node; EST_Item *node;
int i; int i;
if (this == 0) for (i=0,node=p_head; node; node=inext(node))
return 0;
for (i=0,node=p_head; node; node=node->next())
i++; i++;
return i; return i;
} }
void EST_Relation::evaluate_item_features() void EST_Relation::evaluate_item_features()
{ {
for (EST_Item *s = head(); s; s = s->next()) for (EST_Item *s = head(); s; s = inext(s))
s->evaluate_features(); s->evaluate_features();
} }
void EST_Relation::clear() void EST_Relation::clear()
{ {
EST_Item *nn,*nnn; EST_Item *nn,*nnn;
for (nn = p_head; nn != 0; nn = nnn) for (nn = p_head; nn != 0; nn = nnn)
{ {
nnn = nn->next(); nnn = inext(nn);
delete nn; delete nn;
} }
p_head = p_tail = 0; p_head = p_tail = 0;
} }
void EST_Relation::remove_item(EST_Item *node) void EST_Relation::remove_item(EST_Item *node)
{ {
if (p_head == node) if (p_head == node)
p_head = node->next(); p_head = inext(node);
if (p_tail == node) if (p_tail == node)
p_tail = node->prev(); p_tail = iprev(node);
delete node; delete node;
} }
void EST_Relation::remove_item_feature(const EST_String &name) void EST_Relation::remove_item_feature(const EST_String &name)
{ {
for (EST_Item *s = p_head; s; s = next_item(s)) for (EST_Item *s = p_head; s; s = next_item(s))
s->f_remove(name); s->f_remove(name);
} }
void copy_relation(const EST_Relation &from, EST_Relation &to) void copy_relation(const EST_Relation &from, EST_Relation &to)
skipping to change at line 270 skipping to change at line 258
{ {
if (node != 0) if (node != 0)
{ {
EST_Item *n = node; EST_Item *n = node;
int myname; int myname;
while (n) while (n)
{ {
myname = node_count++; myname = node_count++;
nodenames.add_item(n,myname); nodenames.add_item(n,myname);
n = n->next(); n = inext(n);
} }
n = node; n = node;
while (n) while (n)
{ {
// This will need to be expanded if the we make Relations // This will need to be expanded if the we make Relations
// have more complex structures // have more complex structures
save_items(n->down(),outf,cnames,nodenames,node_count); save_items(idown(n),outf,cnames,nodenames,node_count);
outf << nodenames.val(n) << " " << outf << nodenames.val(n) << " " <<
(n->contents() == 0 ? 0 : cnames.val(n->contents())) << " " << (n->contents() == 0 ? 0 : cnames.val(n->contents())) << " " <<
(n->up() == 0 ? 0 : nodenames.val(n->up())) << " " << (iup(n) == 0 ? 0 : nodenames.val(iup(n))) << " " <<
(n->down() == 0 ? 0 : nodenames.val(n->down())) << " " << (idown(n) == 0 ? 0 : nodenames.val(idown(n))) << " " <<
(n->next() == 0 ? 0 : nodenames.val(n->next())) << " " << (inext(n) == 0 ? 0 : nodenames.val(inext(n))) << " " <<
(n->prev() == 0 ? 0 : nodenames.val(n->prev())) << endl; (iprev(n) == 0 ? 0 : nodenames.val(iprev(n))) << endl;
n = n->next(); n = inext(n);
} }
} }
return write_ok; return write_ok;
} }
#if 0 #if 0
EST_read_status EST_Relation::load(EST_TokenStream &ts, EST_read_status EST_Relation::load(EST_TokenStream &ts,
const EST_THash<int,EST_Val> &contents) const EST_THash<int,EST_Val> &contents)
{ {
if (ts.get() != "Relation") if (ts.get() != "Relation")
skipping to change at line 442 skipping to change at line 430
#endif #endif
} }
ts.get(); // skip End_of_Relation ts.get(); // skip End_of_Relation
if (r == format_ok) if (r == format_ok)
{ {
if (node != 0) // at least one node if (node != 0) // at least one node
{ {
p_head = get_item_from_name(nodenames,1); p_head = get_item_from_name(nodenames,1);
p_tail = p_head->last(); p_tail = last(p_head);
if (!p_head->verify()) if (!p_head->verify())
{ {
cerr << "load_nodes: " << ts.pos_description() << cerr << "load_nodes: " << ts.pos_description() <<
" nodes do not form consistent graph" << endl; " nodes do not form consistent graph" << endl;
r = misc_read_error; r = misc_read_error;
} }
} }
} }
if (r != format_ok) if (r != format_ok)
skipping to change at line 537 skipping to change at line 525
} }
#endif #endif
} }
ts.get(); // skip End_of_Relation ts.get(); // skip End_of_Relation
if (r == format_ok) if (r == format_ok)
{ {
if (node != 0) // at least one node if (node != 0) // at least one node
p_head = get_item_from_name(nodenames,1); p_head = get_item_from_name(nodenames,1);
p_tail = p_head->last(); if (p_head)
if (!p_head->verify()) p_tail = last(p_head);
if (p_head && !p_head->verify())
{ {
cerr << "load_nodes: " << ts.pos_description() << cerr << "load_nodes: " << ts.pos_description() <<
" nodes do not form consistent graph" << endl; " nodes do not form consistent graph" << endl;
r = misc_read_error; r = misc_read_error;
} }
} }
if (r != format_ok) if (r != format_ok)
{ {
// failed to read this relation so clear the created nodes // failed to read this relation so clear the created nodes
skipping to change at line 655 skipping to change at line 644
ts.close(); ts.close();
return r; return r;
} }
int num_leaves(const EST_Item *h) int num_leaves(const EST_Item *h)
{ {
int count = 0; int count = 0;
EST_Item *n; EST_Item *n;
for (n = h->first_leaf(); n != 0; n=n->next_leaf()) for (n = first_leaf(h); n != 0; n=next_leaf(n))
count++; count++;
return count; return count;
} }
EST_Item *EST_Relation::first_leaf() const
{
return head()->first_leaf();
}
EST_Item *EST_Relation::last_leaf() const
{
return head()->last_leaf();
}
EST_Utterance *get_utt(EST_Item *s) EST_Utterance *get_utt(EST_Item *s)
{ {
// Occasionally you need to get the utterance from a stream_item // Occasionally you need to get the utterance from a stream_item
// This finds any relations in s and follows them to the utterance // This finds any relations in s and follows them to the utterance
// If there aren't any Relations the this streamitem isn't in an // If there aren't any Relations the this streamitem isn't in an
// utterances // utterances
if (s == 0) if (s == 0)
return 0; return 0;
if (s->relation()) if (s->relation())
skipping to change at line 695 skipping to change at line 674
EST_Relation &EST_Relation::operator=(const EST_Relation &s) EST_Relation &EST_Relation::operator=(const EST_Relation &s)
{ {
copy(s); copy(s);
return *this; return *this;
} }
ostream& operator << (ostream &s, const EST_Relation &a) ostream& operator << (ostream &s, const EST_Relation &a)
{ {
s << a.f << endl; s << a.f << endl;
for (EST_Item *p = a.head(); p; p = p->next()) for (EST_Item *p = a.head(); p; p = inext(p))
s << *p << endl; s << *p << endl;
return s; return s;
} }
 End of changes. 15 change blocks. 
41 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)