diff --git a/maca_graph_parser/simple_parser.cc b/maca_graph_parser/simple_parser.cc index bee5c69c99d9005646a0d222a3c1d505127740ea..f2821c5c498fbbce5e300f0a5f0a0a623e11aa93 100644 --- a/maca_graph_parser/simple_parser.cc +++ b/maca_graph_parser/simple_parser.cc @@ -95,6 +95,7 @@ macaon::Parser::Parser( int argc = sizeof(argv) / sizeof(char*); ctx = maca_graph_parser_LoadCTX(argc, (char**) argv); + ctx->verbose_flag = verbose_flag; int i; int sent_num; diff --git a/maca_graph_parser/test_simple_parser.cc b/maca_graph_parser/test_simple_parser.cc index 88363b920f57fe5a1924621d5e8341259e6c99aa..1f070c00c6ca84882e3ae4364264253a02e35b9d 100644 --- a/maca_graph_parser/test_simple_parser.cc +++ b/maca_graph_parser/test_simple_parser.cc @@ -1,49 +1,44 @@ -#include<iostream> -#include"simple_parser.h" +#include <iostream> +#include <string> +#include <vector> +#include <sstream> + +#include "simple_parser.h" using namespace macaon; int main(int argc, char** argv) { - // Parser mp("en", 3, "/home/alexis/test_maca_graph_parser/en/ptb.mod", "/home/alexis/test_maca_graph_parser/en/ptb.alpha", 1); if(argc < 4) { - std::cerr << "usage: " << argv[0] << " <model.bin> <model.alpha> <model.dep_count>\n"; + std::cerr << "usage: " << argv[0] << " <cfg> <model.bin> <model.alpha> <model.dep_count>\n"; + std::cerr << "expects: one word, one lemma, one tag, per line, empty line between sentences\n"; return 1; } - Parser mp("en", 3, argv[1], argv[2], argv[3], 1); - - for(int iteration = 0; iteration < 10; iteration++) { - std::vector<std::string> words; - std::vector<std::string> lemmas; - std::vector<std::string> tags; - - words.push_back("the"); - words.push_back("boy"); - words.push_back("hits"); - words.push_back("the"); - words.push_back("ball"); - words.push_back("."); - - lemmas.push_back("the"); - lemmas.push_back("boy"); - lemmas.push_back("hit"); - lemmas.push_back("the"); - lemmas.push_back("ball"); - lemmas.push_back("."); - - tags.push_back("DT"); - tags.push_back("NN"); - tags.push_back("VBZ"); - tags.push_back("DT"); - tags.push_back("NN"); - tags.push_back("."); + Parser mp(argv[1], 0, argv[2], argv[3], argv[4], 1); - std::vector<ParsedWord> output; + std::vector<std::string> words; + std::vector<std::string> lemmas; + std::vector<std::string> tags; - mp.ProcessSentence(words, tags, lemmas, output); - //mp.ProcessSentence(words, tags, output); - for(size_t i = 0; i < output.size(); i++){ - // std::cout << i << " " << output[i].word << " " << output[i].lemma << " " << output[i].posTag << " " << output[i].dependencyParent << " " << output[i].dependencyLabel << "\n"; - std::cout << i << " " << output[i].word << " " << output[i].posTag << " " << output[i].dependencyParent << " " << output[i].dependencyLabel << "\n"; + std::string line; + while(std::getline(std::cin, line)) { + std::cout << "|" << line << "|\n"; + if(line == "") { + std::vector<ParsedWord> output; + mp.ProcessSentence(words, tags, lemmas, output); + std::cout << "size: " << output.size() << "\n"; + for(size_t i = 0; i < output.size(); i++){ + std::cout << i << " " << output[i].word << " " << output[i].posTag << " " << output[i].dependencyParent << " " << output[i].dependencyLabel << "\n"; + } + std::cout << "\n"; + words.clear(); + tags.clear(); + lemmas.clear(); } + std::stringstream reader(line); + std::string word, lemma, tag; + reader >> word >> lemma >> tag; + words.push_back(word); + lemmas.push_back(lemma); + tags.push_back(tag); } }