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

add wccl path setting to wccl-rules

parent b7e8f7b3
Branches
No related merge requests found
......@@ -27,7 +27,7 @@ class RuleRunner
{
public:
RuleRunner(const Corpus2::Tagset& tagset)
: tagset_(tagset), parser_(tagset_), progress_(false)
: tagset_(tagset), parser_(tagset_), progress_(false), search_path_(".")
, tag_rule_iterations_(0), total_match_rules_(0), total_tag_rules_(0)
{
}
......@@ -65,12 +65,17 @@ public:
return total_tag_rules_;
}
void set_search_path(const std::string& path) {
search_path_ = path;
}
private:
const Corpus2::Tagset& tagset_;
Wccl::Parser parser_;
std::vector<std::string> file_names_;
std::vector<boost::shared_ptr<Wccl::WcclFile> > parsed_files_;
bool progress_;
std::string search_path_;
int tag_rule_iterations_;
size_t total_match_rules_, total_tag_rules_;
};
......@@ -83,7 +88,7 @@ std::pair<int,int> RuleRunner::load_more_rules(const std::string& filename)
if (!is.good()) {
throw Wccl::FileNotFound(filename, "", __FUNCTION__);
}
parsed_file = parser_.parseWcclFile(is, ".");
parsed_file = parser_.parseWcclFile(is, search_path_);
if (parsed_file) {
boost::filesystem::path p(filename);
file_names_.push_back(p.stem());
......@@ -152,6 +157,7 @@ int main(int argc, char** argv)
std::string tagset_load = "kipi";
std::string input_format;
std::string output_format;
std::string search_path;
bool progress = false;
options opts;
opts.first = false;
......@@ -174,6 +180,8 @@ int main(int argc, char** argv)
"CCL rule files\n")
("files,f", value(&files),
"Files to load, looking at the extension to determine type\n")
("search-path,P", value(&search_path),
"WCCL resources (lexicons) search path")
("corpus-from-stdin,I", value(&corpus_stdin)->zero_tokens(),
"Read corpus from stdin (requires that no corpora filenames are passed)")
("input-format,i", value(&input_format)->default_value("xces"),
......@@ -235,6 +243,9 @@ int main(int argc, char** argv)
runner.set_tag_rule_iterations(vm["until-done-iterations"].as<int>());
}
runner.use_progress(progress);
if (!search_path.empty()) {
runner.set_search_path(search_path);
}
foreach (const std::string& file, ccl_files) {
std::pair<int,int> res = runner.load_more_rules(file);
if (res.first == 0 && res.second == 0) {
......
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