Skip to content
Snippets Groups Projects
Commit f1efa81a authored by Benoit Favre's avatar Benoit Favre
Browse files

make simple parser test more generic

parent 64eb310f
No related branches found
No related tags found
1 merge request!2add first version of exernal-dependency-free graph parser
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
......@@ -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;
......
#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);
Parser mp(argv[1], 0, argv[2], argv[3], argv[4], 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(".");
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);
//mp.ProcessSentence(words, tags, output);
std::cout << "size: " << output.size() << "\n";
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::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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment