Example #1
0
/* implementation */
void Main::testStuff1() {
  myGrammar = new Grammar("treebank.dat", true);
  myGrammar->init();

 // myGrammar->save();
  //myGrammar->load();
//  vector<Grammar::stringAndDouble> RHSs = myGrammar->getRHS("NP");
//  for (int i = 0; i < RHSs.size(); i++) {
//    cout << RHSs[i].first << " " << RHSs[i].second << endl;
//  }  cout << endl;
//
//  myGrammar->fillR2lTable();
//
 
//myGrammar->printL2rTable();
// myGrammar->printUnknownProbTable();

// cout <<"r 2 l: " << endl;
 //myGrammar->printR2lTable();
//  vector<Grammar::stringAndDouble> LHSs;
//  myGrammar->getLHSs("meal",LHSs);
//  for (int i = 0; i < LHSs.size(); i++) {
//    cout << LHSs[i].first << " " << LHSs[i].second << endl;
//  }  cout << endl;

  sentenceParser = new SentenceParser(myGrammar);

 //sentenceParser->parseLine("Ms. Haag plays Elianti . ");
  //sentenceParser->parseLine("Hurr durr derp . ");
 sentenceParser->parseLine("He believes in what he plays , and he plays superbly . ");
 //sentenceParser->parseLine("No , it was n't Black Monday . ");
  //sentenceParser->parseLine("I saw the man with the telescope . ");
 // sentenceParser->parseLine("Exchange officials emphasized that the Big Board is trading . ");

  //sentenceParser->writeTOPs("toptest.dat");

 //sentenceParser->printCYKTable();
  tree<string> thisTree;
 // cout << "Tree size: " << thisTree.size() << endl;
  sentenceParser->getDerivationTree(thisTree);
  cout << "Tree size: " << thisTree.size() << endl;
  TreeManager::printTree(thisTree);
  TreeManager::debinarize(thisTree);
  TreeManager::removeSpecialUnaryRules(thisTree);
  TreeManager::printTree(thisTree);
  cout << TreeManager::getTreeString(thisTree);

}
Example #2
0
/* implementation */
void Main::testStuff1() {
  myGrammar = new Grammar("treebank.dat");
  myGrammar->init();

 // myGrammar->save();
  //myGrammar->load();
//  vector<Grammar::stringAndDouble> RHSs = myGrammar->getRHS("NP");
//  for (int i = 0; i < RHSs.size(); i++) {
//    cout << RHSs[i].first << " " << RHSs[i].second << endl;
//  }  cout << endl;
//
//  myGrammar->fillR2lTable();
//
//  vector<Grammar::stringAndDouble> LHSs = myGrammar->getLHS("VP NNP");
//  for (int i = 0; i < LHSs.size(); i++) {
//    cout << LHSs[i].first << " " << LHSs[i].second << endl;
//  }  cout << endl;

 //myGrammar->printL2rTable();
// cout <<"r 2 l: " << endl;
// myGrammar->printR2lTable();
//  vector<Grammar::stringAndDouble> LHSs = myGrammar->getRHSs("NP");
//  for (int i = 0; i < LHSs.size(); i++) {
//    cout << LHSs[i].first << " " << LHSs[i].second << endl;
//  }  cout << endl;

  parser = new CYKParser(myGrammar);
 parser->parseLine("Ms. Haag plays Elianti . ");
 // parser->parseLine("He plays , and he plays superbly . ");
  // will consume too much memory (std::bad_alloc error):
  //parser->parseLine("On the exchange floor , `` as soon as UAL stopped trading , we braced for a panic , '' said one top floor trader . ");
  parser->printCYKTable();

  
 
}
Example #3
0
void Main::assignment2 () {
  myGrammar = new Grammar("treebank.dat");
  myGrammar->init();
  sentenceParser = new SentenceParser(myGrammar);
  topsTestSentences();
}