diff --git a/wcclparser/main.cpp b/wcclparser/main.cpp index 3d2d78632bbb9c3ce847ee9ba815e9bfd9ed1166..2ef8976a2e02cb7e22454de13d61b6888cc3791c 100644 --- a/wcclparser/main.cpp +++ b/wcclparser/main.cpp @@ -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),