Classes

class EST_Val{}

class EST_Val

The EST_Val class is a container class, used to store a single item which can be an int, float, string or other user-defined class. It is often used as the base item in the EST_Features class, to enable features to take on values of different types.

Constructor and Destructor functions

EST_Val;

EST_Val() {t=val_unset;} EST_Val(const EST_Val &val); EST_Val(const int i) {t=val_int; v.ival=i;} EST_Val(const float f) {t=val_float; v.fval=f;} EST_Val(const double d) {t=val_float; v.fval=d;} EST_Val(const EST_String &s) {t=val_string; sval = s;} EST_Val(const char *s) {t=val_string; sval = s;} EST_Val(val_type type, void *p, void (*f)(void *)); ~EST_Val(void);

Default constructor

Getting cast values

type()

const val_type type(void) const

returns the type that the val is currently holding

Int()

const int Int(void) const

returns the value, cast as an int

I()

const int I(void) const

returns the value, cast as an int

Float()

const float Float(void) const

returns the value, cast as an float

F()

const float F(void) const

returns the value, cast as an float

String()

const EST_String& String(void) const

returns the value, cast as an string

string()

const EST_String& string(void) const

returns the value, cast as an string

S()

const EST_String& S(void) const

returns the value, cast as an string

string_only()

const EST_String& string_only(void) const

returns the value, cast as an string

Setting values

operator=()

EST_Val& operator=(const int i)

Assignment of val to an int

operator=()

EST_Val& operator=(const float f)

Assignment of val to a float

operator=()

EST_Val& operator=(const double d)

Assignment of val to a double

operator=()

EST_Val& operator=(const EST_String &s)

Assignment of val to a string

operator=()

EST_Val& operator=(const char *s)

Assignment of val to a string literal

operator=()

EST_Val& operator=(const EST_Val &c)

Assignment of val to another val

Equivalence test

operator ==()

int operator ==(const EST_Val &a) const

Test whether val is equal to a

operator ==()

int operator ==(const EST_String &a) const

Test whether val is equal to the string a

operator ==()

int operator ==(const char *a) const

Test whether val is equal to the char * a

operator ==()

int operator ==(const int &i) const

Test whether val is equal to the int a

operator ==()

int operator ==(const float &f) const

Test whether val is equal to the float a

operator ==()

int operator ==(const double &d) const

Test whether val is equal to the double a

operator !=()

int operator !=(const EST_Val &a) const

Test whether val is not equal to the val a

operator !=()

int operator !=(const EST_String &a) const

Test whether val is not equal to the string a

operator !=()

int operator !=(const char *a) const

Test whether val is not equal to the char * a

operator !=()

int operator !=(const int &i) const

Test whether val is not equal to the int a

operator !=()

int operator !=(const float &f) const

Test whether val is not equal to the float a

operator !=()

int operator !=(const double &d) const

Test whether val is not equal to the double float a

class EST_Features{}

class EST_Features

A class for containing feature structures which can hold atomic values (int, float, string) or other feature structures

Access functions which return EST_Val.

Features can either be simple features, in which their name is the name of an plain attribute (e.g. "name"), or path features where their name is a dot separated path of concatenated attributes (e.g. "df.poa.alveolar").

val()

const EST_Val& val(const char *name) const

Look up directly without decomposing name as path (just simple feature)

val()

const EST_Val& val(const char *name, const EST_Val &def) const

Look up directly without decomposing name as path (just simple feature), returning def if not found

val_path()

const EST_Val& val_path(const EST_String &path) const

Look up feature name, which may be simple feature or path

val_path()

const EST_Val& val_path(const EST_String &path, const EST_Val &def) const

Look up feature name, which may be simple feature or path, returning def if not found

operator) ()

const EST_Val& operator) (const EST_String &path) const

Look up feature name, which may be simple feature or path

operator) ()

const EST_Val& operator) (const EST_String &path, const EST_Val &def) const

Look up feature name, which may be simple feature or path, returning def if not found

f()

const EST_Val& f(const EST_String &path)

Look up feature name, which may be simple feature or path

f()

const EST_Val& f(const EST_String &path, const EST_Val &def)

Look up feature name, which may be simple feature or path, returning def if not found

Access functions which return types.

These functions cast their EST_Val return value to a requested type, eithe float, int, string or features (A). In all cases the name can be a simple feature or a path, in which case their name is a dot separated string of concatenated attributes (e.g. "df.poa.alveolar").

F()

const float F(const EST_String &path) const

Look up feature name, which may be simple feature or path, and return as a float

F()

const float F(const EST_String &path, float def) const

Look up feature name, which may be simple feature or path, and return as a float, returning def if not found

I()

const int I(const EST_String &path) const

Look up feature name, which may be simple feature or path, and return as an int

I()

const int I(const EST_String &path, int def) const

Look up feature name, which may be simple feature or path, and return as an int, returning def if not found

S()

const EST_String S(const EST_String &path) const

Look up feature name, which may be simple feature or path, and return as a EST_String

S()

const EST_String S(const EST_String &path, const EST_String &def) const

Look up feature name, which may be simple feature or path, and return as a EST_String, returning def if not found

A()

EST_Features& A(const EST_String &path) const

Look up feature name, which may be simple feature or path, and return as a EST_Features

A()

EST_Features& A(const EST_String &path, EST_Features &def) const

Look up feature name, which may be simple feature or path, and return as a EST_Features, returning def if not found

Setting features

set()

void set(const EST_String &name, int ival)

Add a new feature or set an existing feature nameto value ival

set()

void set(const EST_String &name, float fval)

Add a new feature or set an existing feature nameto value fval

set()

void set(const EST_String &name, double dval)

Add a new feature or set an existing feature nameto value dval

set()

void set(const EST_String &name, const EST_String &sval)

Add a new feature or set an existing feature nameto value sval

set()

void set(const EST_String &name, const char *cval)

Add a new feature or set an existing feature nameto value cval

set_val()

void set_val(const EST_String &name, const EST_Val &sval)

Add a new feature or set an existing feature nameto value val. Name must be not be a path.

set_path()

void set_path(const EST_String &name, const EST_Val &sval)

Add a new feature or set an existing feature nameto value val, where nameis a path

set_function()

void set_function(const EST_String &name, const EST_String &f)

Add a new feature feature or set an existing feature name to value f, which is the named of a registered feature function

set()

void set(const EST_String &name, EST_Features &f)

Add a new feature or set an existing feature name to value f, which itself is a EST_Features. The information in f is copied into the features.

Utility functions

remove()

void remove(const EST_String &name)

remove the named feature

length()

int length() const

number of features in feature structure

present()

int present(const EST_String &name) const

return 1 if the feature is present

clear()

void clear()

Delete all features from object

operator = ()

EST_Features& operator = (const EST_Features& a)

Feature assignment

operator << ()

friend ostream& operator << (ostream &s, const EST_Features &f)

Print Features

Iteration

File I/O

load()

EST_read_status load(EST_TokenStream &ts)

load features from already opened EST_TokenStream

load_sexpr()

EST_read_status load_sexpr(EST_TokenStream &ts)

load features from sexpression, contained in already opened EST_TokenStream

save()

EST_write_status save(ostream &outf) const

save features in already opened ostream

save_sexpr()

EST_write_status save_sexpr(ostream &outf) const

save features as s-expression in already opened ostream

class EST_Item{}

class EST_Item

A class for containing individual linguistic objects such as words or phones.

These contain two types of infomation. This first is specific to the \Ref{EST_Relation} we are viewing this ling item from, the second part constists of a set of features. These features may be shared by instances of this ling item in different EST_Relation within the same EST_Utterances

The shared part of an EST_Item is represented by the class EST_Item_Content. It should not normally be accessed by the general users as reverse links from the contents to each of the EST_Items it is part of are held ensure the integrity of the structures. Changing these without maintain the appropriate links is unlikely to be stable.

Constructor Functions

EST_Item()

EST_Item()

Default constructor

EST_Item()

EST_Item(const EST_Item &item)

Copy constructure only makes reference to contents

EST_Item()

EST_Item(EST_Relation *rel)

Includes reference to relation

EST_Item()

EST_Item(EST_Relation *rel, EST_Item *si)

Most common form of construction

~EST_Item()

~EST_Item()

Deletes it and references to it in its contents

Feature access functions.

These functions are wrap-around functions to the basic access functions in the \Ref{EST_Features} class. In all these functioms, if the optional argument m} is set to 1, an error is thrown if the feature does not exist

F()

const float F(const EST_String &name) const

return the value of the feature name cast as a float

F()

const float F(const EST_String &name, float def) const

return the value of the feature name cast as a float, returning def if not found

S()

const EST_String S(const EST_String &name) const

return the value of the feature name cast as a EST_String

S()

const EST_String S(const EST_String &name, const EST_String &def) const

return the value of the feature name cast as a EST_String, returning def if not found

I()

const int I(const EST_String &name) const

return the value of the feature name cast as a int

I()

const int I(const EST_String &name, int def) const

return the value of the feature name cast as a int returning def if not found

A()

EST_Features& A(const EST_String &name) const

return the value of the feature name cast as a EST_Features

A()

EST_Features& A(const EST_String &name, EST_Features &def) const

return the value of the feature name cast as a EST_Features, returning def if not found

Feature setting functions.

A separate function is provided for each permissable value type

set()

void set(const EST_String &name, int ival)

set feature name to val

set()

void set(const EST_String &name, float fval)

set feature name to val

set()

void set(const EST_String &name, double fval)

set feature name to val

set()

void set(const EST_String &name, const EST_String &sval)

set feature name to val

set()

void set(const EST_String &name, const char *cval)

set feature name to val

set_function()

void set_function(const EST_String &name, const EST_String &funcname)

set feature name to val, a function registered in the feature function list

set()

void set(const EST_String &name, EST_Features &f)

set feature name to f, a set of features, which is copied into the object

set_val()

void set_val(const EST_String &name, const EST_Val &sval)

set feature name to f, whose type is EST_Val

Utility feature functions

f_remove()

void f_remove(const EST_String &name)

remove feature name

evaluate_features()

void evaluate_features()

find all the attributes whose values are functions, and replace them with their evaluation

f_present()

int f_present(const EST_String &name) const

TRUE if feature is present, FALSE otherwise

Cross relational access

as_relation()

EST_Item* as_relation(const char *relname) const

View item from another relation (const char *) method

in_relation()

int in_relation(const EST_String &relname) const

TRUE if this item is in named relation

relations()

EST_TKVL <EST_String, EST_Val> & relations()

Access to the relation links

relation_name()

const EST_String& relation_name() const

The relation name of this particular item

relation()

EST_Relation* relation(void) const

The relation of this particular item

same_item()

int same_item(const EST_Item *li) const

True if li is the same item ignoring its relation viewpoint

class EST_Relation{}

class EST_Relation

Relations are a container class for EST_Items. Three types of relation structure are supported:

Linear lists
Trees
Multi-linear structuresas used in autosegmental phonology etc

Constructors and Destructors

EST_Relation()

EST_Relation()

default constructor

EST_Relation()

EST_Relation(const EST_String &name)

Constructor which sets name of relation

EST_Relation()

EST_Relation(const EST_Relation &r)

Constructor which copies relation r

~EST_Relation()

~EST_Relation()

default destructor

Relation features

f;

EST_Features f

Features which belong to the relation rather than its items

evaluate_features()

void evaluate_features()

Evaluate the relation's feature functions

evaluate_item_features()

void evaluate_item_features()

Evaluate the feature functions of all the items in the relation

Utility functions

clear()

void clear()

Clear the relation of items

utt()

EST_Utterance* utt(void)

Return the EST_Utterance to which this relation belongs

set_utt()

void set_utt(EST_Utterance *u)

Set the EST_Utterance to which this relation belongs

name()

const EST_String& name() const

Return the name of the relation

length()

int length() const

number of items in this relation

empty()

int empty() const

return true if relation does not contain any items

remove_item()

void remove_item(EST_Item *item)

remove EST_Item item from relation

remove_item_feature()

void remove_item_feature(const EST_String &name)

remove all occurances of feature name from relation's items

operator=()

EST_Relation& operator=(const EST_Relation &s)

Relation assignment. Copies relation into new relation but the items are the same and become shared.

operator << ()

friend ostream& operator << (ostream &s, const EST_Relation &u)

Print relation

Constructors and Destructors

load()

EST_read_status load(const EST_String &filename, const EST_String &type="esps")

Load relation from file

load()

EST_read_status load(EST_TokenStream &ts, EST_THash<int, EST_Val> &contents)

Load relation from already open tokenstream

save()

EST_write_status save(const EST_String &filename, bool evaluate_ff = false) const

Save relation to file

save()

EST_write_status save(const EST_String &filename, const EST_String &type, bool evaluate_ff = false) const

Save relation to file, evaluating all feature functions before hand

save()

EST_write_status save(ostream &outf, EST_TKVL<void *, int> contents) const

Save relation from already open ostream

Iteration and access

head()

EST_Item* head() const

Return the head (first) item of the relation

root()

EST_Item* root() const

Return the root item of the relation

tail()

EST_Item* tail() const

Return the tail (last) item of the relation

append()

EST_Item* append(EST_Item *si)

append item si to relation, return si as new item in relation

append()

EST_Item* append()

make a new item and append it to the relation

prepend()

EST_Item* prepend(EST_Item *si)

prepend item si to relation, return si as new item in relation

prepend()

EST_Item* prepend()

make a new item and prepend it to the relation

class EST_Utterance{}

class EST_Utterance

A class that contains EST_Items and EST_Relations between them. Used for holding interrelated linguistic structures.

Constructor and initialisation Functions

EST_Utterance()

EST_Utterance()

default constructor

Utility Functions

init()

void init()

initialise utterance

clear()

void clear()

remove everything in utterance

clear_relations()

void clear_relations()

clear the contents of the relations only

set_highest_id()

void set_highest_id(int n)

set the next id to be n

next_id()

int next_id()

return the id of the next item

operator=()

EST_Utterance& operator=(const EST_Utterance &s)

Copy utterance

operator << ()

friend ostream& operator << (ostream &s, const EST_Utterance &u)

Print utterance

operator) ()

EST_Relation* operator) (const EST_String &name)

Return pointer to named relation

File i/o

load()

EST_read_status load(const EST_String &filename)

load an utterance from an ascii file

load()

EST_read_status load(EST_TokenStream &ts)

load an utterance from a already opened token stream

save()

EST_write_status save(const EST_String &filename, const EST_String &type="est_ascii") const

save an utterance to an ascii file

save()

EST_write_status save(ostream &outf, const EST_String &type) const

save an utterance to an ostream

Utterance access

f;

EST_Features f

Utterance level features

evaluate_all_features()

void evaluate_all_features()

Evaluarte all feature functions in utterance

relations;

EST_Features relations

The list of named relations

num_relations()

int num_relations() const

number of relations in this utterance

relation_present()

bool relation_present(const EST_String name) const

returns true if utterance contains named relations. {\bf name} can be either a single string or a bracketed list of strings e.g. "(Word Phone Syl)".

relation_present()

bool relation_present(EST_StrList &names) const

returns true if utterance contains all the relations named in the list {\bf name}

relation()

EST_Relation* relation(const char *name, int err_on_not_found=1)

get relation by name

id()

EST_Item* id(const EST_String &n)

return EST_Item whose id is n.

create_relation()

EST_Relation* create_relation(const EST_String &relname)

create a new relation called n.

remove_relation()

void remove_relation(const EST_String &relname)

remove the relation called n.

Functions for building and traversing tree relations

This is a sub-library of functions for creating, traversing and accessing relations which are trees.

Tree traversal functions

parent()

inline EST_Item* parent(const EST_Item *n)

return parent of n

daughter1()

inline EST_Item* daughter1(const EST_Item *n)

return first daughter of n

daughter2()

inline EST_Item* daughter2(const EST_Item *n)

return second daughter of n

daughtern()

EST_Item* daughtern(const EST_Item *n, int nth)

return nth daughter of n

daughtern()

inline EST_Item* daughtern(const EST_Item *n)

return last daughter of n

next_sibling()

inline EST_Item* next_sibling(const EST_Item *n)

return next sibling (sister) of n

prev_sibling()

inline EST_Item* prev_sibling(const EST_Item *n)

return previous sibling (sister) of n

root()

inline EST_Item* root(const EST_Item *n)

return root node of treeprevious sibling (sister) of n

parent()

inline EST_Item* parent(const EST_Item *n, const char *relname)

return parent of n as seen from relation relname

daughter1()

inline EST_Item* daughter1(const EST_Item *n, const char *relname)

return first daughter of n as seen from relation relname

daughter2()

inline EST_Item* daughter2(const EST_Item *n, const char *relname)

return second daughter of n as seen from relation relname

daughtern()

inline EST_Item* daughtern(const EST_Item *n, const char *relname)

return last daughter of n as seen from relation relname

next_sibling()

inline EST_Item* next_sibling(const EST_Item *n, const char *relname)

return next sibling (sister) of n as seen from relation relname

prev_sibling()

inline EST_Item* prev_sibling(const EST_Item *n, const char *relname)

return previous sibling (sistem) of n as seen from relation relname

root()

inline EST_Item* root(const EST_Item *n, const char *relname)

return root of tree of n as seen from relation relname

first_leaf()

inline EST_Item* first_leaf(const EST_Item *n)

return the first leaf (terminal node) which is dominated by n. Note that this is different from daughter1 etc as this descends the tree to find the lefttmost terminal node (it is like the transitive closure of daughter1).

last_leaf()

inline EST_Item* last_leaf(const EST_Item *n)

return the last leaf (terminal node) which is dominated by n. Note that this is different from daughter1 etc as this descends the tree to find the right terminal node (it is like the transitive closure of daughtern).

next_leaf()

inline EST_Item* next_leaf(const EST_Item *n)

Return next leaf in tree given n. If n is a terminal node, next_leaf() will return the next leaf in the tree. If n is not terminal, this will return the leftmost terminal node dominated by n. This will return 0 only when the last leaf in the relation has been passed.

num_leaves()

int num_leaves(const EST_Item *n)

Return number of leaves (terminal nodes) under n

in_tree()

int in_tree(const EST_Item *c, const EST_Item *t)

Given a node t, return true if c is under it in a tree

Tree building functions

append_daughter()

EST_Item* append_daughter(EST_Item *n, EST_Item *p=0)

Add a daughter to node n, after any existing daughters, and return the next daughter. If p is 0, make a new node for the daughter, otherwise add p to this relation as n's daughter.

append_daughter()

EST_Item* append_daughter(EST_Item *n, const char *relname, EST_Item *p=0)

Add a daughter to node n as seen from relation relname, after any existing daughters, and return the next daughter. If p is 0, make a new node for the daughter, otherwise add p to this relation as n's daughter.

prepend_daughter()

EST_Item* prepend_daughter(EST_Item *n, EST_Item *p=0)

Add a daughter to node n, before any existing daughters, and return the next daughter. If p is 0, make a new node for the daughter, otherwise add p to this relation as n's daughter.

prepend_daughter()

EST_Item* prepend_daughter(EST_Item *n, const char *relname, EST_Item *p=0)

Add a daughter to node n as seen from relation relname, before any existing daughters, and return the next daughter. If p is 0, make a new node for the daughter, otherwise add p to this relation as n's daughter.

Functions for building and traversing list relations

List traversal functions

next()

inline EST_Item* next(const EST_Item *n)

return next item of n

prev()

inline EST_Item* prev(const EST_Item *n)

return previous item of n

last()

inline EST_Item* last(const EST_Item *n)

return last item in n's relation

first()

inline EST_Item* first(const EST_Item *n)

return first item in n's relation

next()

inline EST_Item* next(const EST_Item *n, const char *relname)

return next item of n as seen from relation relname

prev()

inline EST_Item* prev(const EST_Item *n, const char *relname)

return previous item of n as seen from relation relname

first()

inline EST_Item* first(const EST_Item *n, const char *relname)

return first item of n as seen from relation relname

last()

inline EST_Item* last(const EST_Item *n, const char *relname)

return last item of n as seen from relation relname

in_list()

int in_list(const EST_Item *c, const EST_Item *l)

Given a node l, return true if c after it in a list relation

add_after()

EST_Item* add_after(const EST_Item *n, EST_Item *p=0)

Add a item after node n, and return the new item. If n is the first item in the list, the new item becomes the head of the list, otherwise it is inserted between n and it's previous current item. If p is 0, make a new node for the new item, otherwise add p to this relation as the next item in n's relation.

add_before()

EST_Item* add_before(const EST_Item *n, EST_Item *p=0)

Add a item before node n, and return the new item. If n is the first item in the list, the new item becomes the head of the list, otherwise it is inserted between n and it's previous current item. If p is 0, make a new node for the new item, otherwise add p to this relation as the previous item in n's relation.