item_aux.cc (speech_tools-2.4-release) | : | item_aux.cc (speech_tools-2.5.0-release) | ||
---|---|---|---|---|
skipping to change at line 51 | skipping to change at line 51 | |||
#include <iostream> | #include <iostream> | |||
#include <fstream> | #include <fstream> | |||
#include "ling_class/EST_Item.h" | #include "ling_class/EST_Item.h" | |||
#include "ling_class/EST_Item_Content.h" | #include "ling_class/EST_Item_Content.h" | |||
#include "ling_class/EST_Relation.h" | #include "ling_class/EST_Relation.h" | |||
int in_list(const EST_Item *c,const EST_Item *l) | int in_list(const EST_Item *c,const EST_Item *l) | |||
{ | { | |||
const EST_Item *i; | const EST_Item *i; | |||
for (i=l; i != 0; i=i->next()) | for (i=l; i != 0; i=inext(i)) | |||
if (i == c) | if (i == c) | |||
return TRUE; | return TRUE; | |||
return FALSE; | return FALSE; | |||
} | } | |||
int in_tree(const EST_Item *c,const EST_Item *t) | int in_tree(const EST_Item *c,const EST_Item *t) | |||
{ | { | |||
EST_Item *i; | EST_Item *i; | |||
if (t == c) | if (t == c) | |||
skipping to change at line 77 | skipping to change at line 77 | |||
return TRUE; | return TRUE; | |||
return FALSE; | return FALSE; | |||
} | } | |||
} | } | |||
void remove_item_list(EST_Relation *rel, EST_Item *item) | void remove_item_list(EST_Relation *rel, EST_Item *item) | |||
{ | { | |||
if (item==NULL) | if (item==NULL) | |||
return; | return; | |||
EST_Item *p = item->prev(); | EST_Item *p = iprev(item); | |||
EST_Item *n = item->next(); | EST_Item *n = inext(item); | |||
rel->remove_item(item); | rel->remove_item(item); | |||
EST_Item::splice(p,n); | EST_Item::splice(p,n); | |||
} | } | |||
int merge_item(EST_Item *from, EST_Item *to) | int merge_item(EST_Item *from, EST_Item *to) | |||
{ | { | |||
// Make all references to from be references to to and merge | // Make all references to from be references to to and merge | |||
// from's features into to | // from's features into to | |||
skipping to change at line 143 | skipping to change at line 143 | |||
EST_Item *d,*r,*nr; | EST_Item *d,*r,*nr; | |||
if (in_tree(to,from)) | if (in_tree(to,from)) | |||
return FALSE; // can't do that | return FALSE; // can't do that | |||
to->set_contents(from->contents()); | to->set_contents(from->contents()); | |||
// Remove current daughters, but don't delete them | // Remove current daughters, but don't delete them | |||
// until after the copy in case from is within to's daughters | // until after the copy in case from is within to's daughters | |||
d = to->grab_daughters(); | d = to->grab_daughters(); | |||
if (rfrom == d) | if (rfrom == d) | |||
d = d->next(); | d = inext(d); | |||
if ((rfrom != 0) && (daughter1(rfrom))) | if ((rfrom != 0) && (daughter1(rfrom))) | |||
{ // copy the descendant structure | { // copy the descendant structure | |||
copy_node_tree(daughter1(rfrom),to->insert_below(daughter1(rfrom))); | copy_node_tree(daughter1(rfrom),to->insert_below(daughter1(rfrom))); | |||
delete rfrom; | delete rfrom; | |||
} | } | |||
for (r=d; r; r=nr) | for (r=d; r; r=nr) | |||
{ | { | |||
nr = r->next(); | nr = inext(r); | |||
delete r; | delete r; | |||
} | } | |||
return TRUE; | return TRUE; | |||
} | } | |||
int exchange_sub_trees(EST_Item *from,EST_Item *to) | int exchange_sub_trees(EST_Item *from,EST_Item *to) | |||
{ | { | |||
// Take contents of from and its daughters and replace | // Take contents of from and its daughters and replace | |||
// them with contents of to and its daughters (and the reverse) | // them with contents of to and its daughters (and the reverse) | |||
EST_Item *rfrom = from->as_relation(to->relation_name()); | EST_Item *rfrom = from->as_relation(to->relation_name()); | |||
skipping to change at line 222 | skipping to change at line 222 | |||
if ( t == f ) | if ( t == f ) | |||
return from; | return from; | |||
switch(f) { | switch(f) { | |||
case 1: | case 1: | |||
// from Segment | // from Segment | |||
switch(t) { | switch(t) { | |||
case 2: | case 2: | |||
// Syllable | // Syllable | |||
return(from->as_relation("SylStructure")->up()->as_relation("Syllable")); | return(iup(from->as_relation("SylStructure"))->as_relation("Syllable")); | |||
case 3: | case 3: | |||
// Word | // Word | |||
return(from->as_relation("SylStructure")->up()->up()->as_relation("Word")) ; | return(iup(iup(from->as_relation("SylStructure")))->as_relation("Word")) ; | |||
case 4: | case 4: | |||
// IntEvent | // IntEvent | |||
return(from->as_relation("SylStructure")->up()->as_relation("Intonation")- >down()->as_relation("IntEvent")); | return(idown(iup(from->as_relation("SylStructure"))->as_relation("Intona tion"))->as_relation("IntEvent")); | |||
} | } | |||
case 2: | case 2: | |||
// from Syllable | // from Syllable | |||
switch(t) { | switch(t) { | |||
case 1: | case 1: | |||
// Segment | // Segment | |||
return(from->as_relation("SylStructure")->down()->as_relation("Segment")); | return(idown(from->as_relation("SylStructure"))->as_relation("Segment")) ; | |||
case 3: | case 3: | |||
// Word | // Word | |||
return(from->as_relation("SylStructure")->up()->as_relation("Word")); | return(iup(from->as_relation("SylStructure"))->as_relation("Word")); | |||
// IntEvent | // IntEvent | |||
case 4: | case 4: | |||
return(from->as_relation("Intonation")->down()->as_relation("IntEvent")); | return(idown(from->as_relation("Intonation"))->as_relation("IntEvent")); | |||
} | } | |||
case 3: | case 3: | |||
// from Word | // from Word | |||
switch(t) { | switch(t) { | |||
case 1: | case 1: | |||
// Segment | // Segment | |||
return(from->as_relation("SylStructure")->down()->down()->as_relation("Seg ment")); | return(idown(idown(from->as_relation("SylStructure")))->as_relation("Seg ment")); | |||
case 2: | case 2: | |||
// Syllable | // Syllable | |||
return(from->as_relation("SylStructure")->down()->as_relation("Syllable")) ; | return(idown(from->as_relation("SylStructure"))->as_relation("Syllable") ); | |||
case 4: | case 4: | |||
return(from->as_relation("SylStructure")->down()->as_relation("Intonation" )->down()->as_relation("IntEvent")); | return(idown(idown(from->as_relation("SylStructure"))->as_relation("Into nation"))->as_relation("IntEvent")); | |||
} | } | |||
case 4: | case 4: | |||
// from IntEvent | // from IntEvent | |||
switch(t) { | switch(t) { | |||
case 1: | case 1: | |||
// Segment | // Segment | |||
return(from->as_relation("Intonation")->up()->as_relation("SylStructure")- >down()->as_relation("Segment")); | return(idown(iup(from->as_relation("Intonation"))->as_relation("SylStruc ture"))->as_relation("Segment")); | |||
case 2: | case 2: | |||
// Syllable | // Syllable | |||
return(from->as_relation("Intonation")->up()->as_relation("Syllable")); | return(iup(from->as_relation("Intonation"))->as_relation("Syllable")); | |||
case 3: | case 3: | |||
// Word | // Word | |||
return(from->as_relation("Intonation")->up()->as_relation("SylStructure")- >up()->as_relation("Word")); | return(iup(iup(from->as_relation("Intonation"))->as_relation("SylStructu re"))->as_relation("Word")); | |||
} | } | |||
} | } | |||
return NULL; | return NULL; | |||
} | } | |||
End of changes. 16 change blocks. | ||||
18 lines changed or deleted | 18 lines changed or added |