#ifndef _DERIVREADER_H_ #define _DERIVREADER_H_ #include #include #include #include #include "grammar.h" #include "tToken.h" template class DerivReader { Grammar _g; Data &_d; boost::regex rootnode; boost::regex endnode; boost::regex startnode; boost::regex intnode; boost::regex leafnode; boost::regex tokenre; // called on internal node when the node values are read // arguments are node name, node ancestors, edge number, score, start, end void (*_start_int_node_funct)(Grammar &, std::string, std::vector &, int, double, int, int, Data &); // called on internal node once all subtrees are parsed // arguments are names of direct child(ren), node ancestors void (*_end_int_node_funct)(Grammar &, std::vector &, std::vector &, Data &); // called when a leaf node is parsed // arguments are surface string, node ancestors void (*_leaf_funct)(Grammar &, tToken, std::vector &, Data &); // recursive functions for reading the tree std::string readNode(std::string const &, std::vector &); std::string readTokenFS(std::string &, std::map &); void readFS(std::string &tok, std::string featstr, std::map &tokfeatures, std::map &reentrancies); std::string readFeat(std::string &tok); std::pair readVal(std::string &tok); std::string parseSymbol(std::string &tok); std::string parseString(std::string &tok); void removeWhitespace(std::string &rest); public: // constructer requires function pointers DerivReader(Grammar const &g, Data &d, void (*start_int_node)(Grammar &, std::string, std::vector &, int, double, int, int, Data &)=NULL, void (*end_int_node)(Grammar &, std::vector &, std::vector &, Data &)=NULL, void (*leaf)(Grammar &, tToken, std::vector &, Data &)=NULL); ~DerivReader(); void readDeriv(std::string); }; #endif