1 /*************************************************************************/ 2 /* */ 3 /* Centre for Speech Technology Research */ 4 /* (University of Edinburgh, UK) and */ 5 /* Korin Richmond */ 6 /* Copyright (c) 2003 */ 7 /* All Rights Reserved. */ 8 /* */ 9 /* Permission is hereby granted, free of charge, to use and distribute */ 10 /* this software and its documentation without restriction, including */ 11 /* without limitation the rights to use, copy, modify, merge, publish, */ 12 /* distribute, sublicense, and/or sell copies of this work, and to */ 13 /* permit persons to whom this work is furnished to do so, subject to */ 14 /* the following conditions: */ 15 /* */ 16 /* 1. The code must retain the above copyright notice, this list of */ 17 /* conditions and the following disclaimer. */ 18 /* 2. Any modifications must be clearly marked as such. */ 19 /* 3. Original authors' names are not deleted. */ 20 /* 4. The authors' names are not used to endorse or promote products */ 21 /* derived from this software without specific prior written */ 22 /* permission. */ 23 /* */ 24 /* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */ 25 /* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */ 26 /* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT */ 27 /* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */ 28 /* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */ 29 /* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */ 30 /* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */ 31 /* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */ 32 /* THIS SOFTWARE. */ 33 /* */ 34 /*************************************************************************/ 35 /* Author : Korin Richmond */ 36 /* Date : 14 Apr 2003 */ 37 /* --------------------------------------------------------------------- */ 38 /* */ 39 /* Swig interface for EST_Utterance class */ 40 /* */ 41 /*************************************************************************/ 42 43 %module EST_Utterance 44 %{ 45 #include "ling_class/EST_Utterance.h" 46 %} 47 48 %include "EST_typemaps.i" 49 %include "EST_error.i" 50 51 %import "EST_Item.i" 52 %import "EST_Relation.i" 53 54 // List of functions which can throw errors when called (which need to be 55 // caught or the interpreter will bomb out) 56 %exception EST_Utterance::relation CATCH_EST_ERROR; 57 %exception EST_Utterance::load CATCH_EST_ERROR; 58 %exception EST_Utterance::id CATCH_EST_ERROR; 59 %exception utterance_merge CATCH_EST_ERROR; 60 61 class EST_Utterance{ 62 private: 63 int highest_id; 64 public: 65 66 // constructors 67 EST_Utterance(); EST_Utterance(const EST_Utterance & u)68 EST_Utterance(const EST_Utterance &u) { copy(u); } ~EST_Utterance()69 ~EST_Utterance() {clear(); } 70 71 // initialise utterance 72 void init(); 73 74 // remove everything in utterance 75 void clear(); 76 77 // clear the contents of the relations only 78 void clear_relations(); 79 80 // set the next id to be "n" 81 void set_highest_id( int n ); 82 83 // return the id of the next item 84 int next_id(); 85 86 // load an utterance from file 87 void load( const EST_String &filename ); 88 89 // save an utterance to file 90 void save( const EST_String &filename, const EST_String &type="est_ascii" ) const; 91 92 // Evaluate all feature functions 93 void evaluate_all_features(); 94 95 // number of relations in this utterance num_relations()96 int num_relations() const { return relations.length(); } 97 98 // is the relation present? 99 bool relation_present( const EST_String name ) const; 100 101 // get relation 102 EST_Relation *relation( const char *name, int err_on_not_found=1 ); 103 104 // return EST_Item whose id is "n" 105 EST_Item *id( const EST_String &n ); 106 107 // create a new relation 108 EST_Relation *create_relation( const EST_String &relname ); 109 110 // remove relation 111 void remove_relation( const EST_String &relname ); 112 113 void sub_utterance( EST_Item *i ); 114 }; 115 116 int utterance_merge( EST_Utterance &utt, 117 EST_Utterance &sub_utt, 118 EST_Item *utt_root, 119 EST_Item *sub_root ); 120 121 int utterance_merge( EST_Utterance &utt, 122 EST_Utterance &extra, 123 EST_String feature ); 124 125 void sub_utterance( EST_Utterance &sub, EST_Item *i ); 126 127 EST_Utterance *get_utt( EST_Item *s ); 128