From b1e4d384bf0b3559516a9c808f16652cb26d24d6 Mon Sep 17 00:00:00 2001 From: ilor <ilor@vger.(none)> Date: Mon, 9 May 2011 13:33:02 +0200 Subject: [PATCH] add wccl path setting to wccl-rules --- wccl-apps/wccl-rules.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/wccl-apps/wccl-rules.cpp b/wccl-apps/wccl-rules.cpp index 0df2f9e..4d43404 100644 --- a/wccl-apps/wccl-rules.cpp +++ b/wccl-apps/wccl-rules.cpp @@ -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) { -- GitLab