#include "lattice.h" #include "tdict.h" #include "agrammar.h" #include "bottom_up_parser.h" #include "hg.h" #include "hg_intersect.h" #include "../utils/ParamsArray.h" using namespace std; typedef aTextGrammar aGrammar; aGrammar * load_grammar(string & grammar_filename){ cerr<<"start_load_grammar "< vID; TD::ConvertSentence(str , &vID); Lattice lsentence; lsentence.resize(vID.size()); for (int i=0; i grammars(1, g); ExhaustiveBottomUpParser parser = ExhaustiveBottomUpParser(goal_sym, grammars); if (!parser.Parse(lsource, &hg)){ cerr<<"source sentence does not parse by the grammar!"<SetGoalNT(goal_sym); cout<<"before split nonterminal"<PrintAllRules(); /*split grammar*/ cout<<"split NTs\n"; cerr<<"first of all write all nonterminals"<printAllNonterminals(); agrammar->setMaxSplit(2); agrammar->splitNonterminal(4); cout<<"after split nonterminal"<PrintAllRules(); Hypergraph hg1; if (! parseSentencePair(goal_sym, src, tgt, g, hg1) ){ cerr<<"target sentence is not parsed by the grammar!\n"; return 1; } hg1.PrintGraphviz(); agrammar->splitNonterminal(15); cout<<"after split nonterminal"<PrintAllRules(); /*load training corpus*/ /*for each sentence pair in training corpus*/ // forest.PrintGraphviz(); /*calculate expected count*/ }