From 2434a2a2b5402008fbbb44880f1e8c1e93177c3f Mon Sep 17 00:00:00 2001
From: ilor <ilor@vger.(none)>
Date: Mon, 9 May 2011 14:07:57 +0200
Subject: [PATCH] wccl-rules: fix silly typo and handle missing sections again

---
 wccl-apps/wccl-rules.cpp | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/wccl-apps/wccl-rules.cpp b/wccl-apps/wccl-rules.cpp
index e7e18c9..63d33c4 100644
--- a/wccl-apps/wccl-rules.cpp
+++ b/wccl-apps/wccl-rules.cpp
@@ -50,7 +50,7 @@ public:
 		boost::shared_ptr<Corpus2::TokenWriter> writer);
 
 	bool empty() const {
-		return size() > 0;
+		return size() == 0;
 	}
 
 	size_t size() const {
@@ -128,14 +128,18 @@ void RuleRunner::apply_rules(boost::shared_ptr<Corpus2::TokenReader> reader,
 			}
 
 			foreach (boost::shared_ptr<Wccl::WcclFile>& f, parsed_files_) {
-				if (tag_rule_iterations_ == 0) {
-					f->get_tag_rules_ptr()->execute_once(as);
-				} else if (tag_rule_iterations_ < 0) {
-					f->get_tag_rules_ptr()->execute_until_done(as);
-				} else  {
-					f->get_tag_rules_ptr()->execute_until_done(as, tag_rule_iterations_);
+				if (f->has_tag_rules()) {
+					if (tag_rule_iterations_ == 0) {
+						f->get_tag_rules_ptr()->execute_once(as);
+					} else if (tag_rule_iterations_ < 0) {
+						f->get_tag_rules_ptr()->execute_until_done(as);
+					} else  {
+						f->get_tag_rules_ptr()->execute_until_done(as, tag_rule_iterations_);
+					}
+				}
+				if (f->has_match_rules()) {
+					f->get_match_rules_ptr()->apply_all(as);
 				}
-				f->get_match_rules_ptr()->apply_all(as);
 			}
 
 			timer.count_sentence(*as);
@@ -280,7 +284,7 @@ int main(int argc, char** argv)
 			}
 		}
 	} catch (PwrNlp::PwrNlpError& e) {
-		std::cerr << e.info() << std::endl;
+		std::cerr << e.scope() << "error: " << e.info() << std::endl;
 		return 2;
 	}
 
-- 
GitLab