Skip to content
Snippets Groups Projects
Commit 4a616ed2 authored by ilor's avatar ilor
Browse files

Add query file loading to wcclparser

parent f96ec109
No related merge requests found
......@@ -153,6 +153,7 @@ int main(int argc, char** argv)
std::string tagset_load = "kipi";
std::string query = "";
std::string sentence_load = "";
std::string query_load = "";
std::string position = "0";
bool quiet = false;
using boost::program_options::value;
......@@ -165,6 +166,8 @@ int main(int argc, char** argv)
"Sentence to load (XCES)\n")
("position,p", value(&position),
"Position in the sentence to use, 'all' iterates through the sentence\n")
("query-file,f", value(&query_load),
"Run query from file (disables interactive mode)\n")
("query,Q", value(&query),
"Query to run (disables interactive mode)\n")
("quiet,q", value(&quiet)->zero_tokens(),
......@@ -213,6 +216,16 @@ int main(int argc, char** argv)
if (!query.empty()) {
process_line(query, parser, sc, position == "all");
return 0;
} else if (!query_load.empty()) {
std::ifstream qf(query_load.c_str());
if (qf.good()) {
std::stringstream ss;
ss << qf.rdbuf();
process_line(ss.str(), parser, sc, position == "all");
return 0;
} else {
throw Wccl::FileNotFound(sentence_load, "", "Query file");
}
}
boost::function<bool (const std::string&)> f;
f = boost::bind(&process_line, _1, boost::ref(parser), boost::ref(sc),
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment