diff --git a/libwccl/ops/match/actions/markmatch.cpp b/libwccl/ops/match/actions/markmatch.cpp index e80515179823c1f1e7633b9a54020c6d146ad3af..2a113abf7de17c32a95ea3227d54e1de5d867775 100644 --- a/libwccl/ops/match/actions/markmatch.cpp +++ b/libwccl/ops/match/actions/markmatch.cpp @@ -5,6 +5,7 @@ namespace Wccl { +namespace Matching { void MarkMatch::execute(const ActionExecContext& context) const { @@ -81,4 +82,5 @@ std::ostream& MarkMatch::write_to(std::ostream& os) const return os; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/actions/markmatch.h b/libwccl/ops/match/actions/markmatch.h index 9a2a8c0e23e23face694fa820032235f7b3fb112..514ec19e8c05358068a906a5b247424567d7994a 100644 --- a/libwccl/ops/match/actions/markmatch.h +++ b/libwccl/ops/match/actions/markmatch.h @@ -5,6 +5,7 @@ #include <libwccl/ops/function.h> namespace Wccl { +namespace Matching { class MarkMatch : public MatchAction { @@ -82,6 +83,7 @@ private: const std::string chan_name_; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_ACTIONS_MARKMATCH_H diff --git a/libwccl/ops/match/actions/unmarkmatch.cpp b/libwccl/ops/match/actions/unmarkmatch.cpp index 3f0a8efe704c8e69aa42b1cee9ab95fed4c86ac8..7e7926e58d2f90f32f4c310b71e6a63020cec0ab 100644 --- a/libwccl/ops/match/actions/unmarkmatch.cpp +++ b/libwccl/ops/match/actions/unmarkmatch.cpp @@ -5,6 +5,7 @@ #include <sstream> namespace Wccl { +namespace Matching { void UnmarkMatch::execute(const ActionExecContext& context) const { @@ -50,4 +51,5 @@ std::ostream& UnmarkMatch::write_to(std::ostream& os) const return os << name() << "(" << *match_ << ", \"" << chan_name_ << "\")"; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/actions/unmarkmatch.h b/libwccl/ops/match/actions/unmarkmatch.h index 1f1071a82b5a499c7e9b230be1869768362d78f0..9d074fb2277850dd2e198cd6305bf35273ae6d9f 100644 --- a/libwccl/ops/match/actions/unmarkmatch.h +++ b/libwccl/ops/match/actions/unmarkmatch.h @@ -5,6 +5,7 @@ #include <libwccl/ops/function.h> namespace Wccl { +namespace Matching { /** * Action to unmark (delete) an annotation passing through a first @@ -53,6 +54,7 @@ private: const std::string chan_name_; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_ACTIONS_UNMARKMATCH_H diff --git a/libwccl/ops/match/applyoperator.cpp b/libwccl/ops/match/applyoperator.cpp index edcefc02e3f33e55cd9311b53343d644fc24263b..2d4ad494df18431b9db6ff8d1e0e8401e999e29a 100644 --- a/libwccl/ops/match/applyoperator.cpp +++ b/libwccl/ops/match/applyoperator.cpp @@ -5,6 +5,7 @@ #include <libpwrutils/foreach.h> namespace Wccl { +namespace Matching { ApplyOperator::ApplyOperator( const VariableAccessor<Match>& matches, @@ -103,4 +104,5 @@ std::ostream& ApplyOperator::write_to(std::ostream &ostream) const return ostream; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/applyoperator.h b/libwccl/ops/match/applyoperator.h index f685c72a023f49d278afc73b2ff2c518cf3ca944..014ecc31296ec33707eba3315511331a9aaad62a 100644 --- a/libwccl/ops/match/applyoperator.h +++ b/libwccl/ops/match/applyoperator.h @@ -4,6 +4,7 @@ #include <libwccl/ops/functions/bool/predicates/logicalpredicate.h> namespace Wccl { +namespace Matching { class ConjConditions; class MatchAction; @@ -62,6 +63,7 @@ private: const boost::shared_ptr<const std::vector<boost::shared_ptr<Function<Bool> > > > apply_conditions_; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_APPLYOPERATOR_H diff --git a/libwccl/ops/match/conditions/conjconditions.cpp b/libwccl/ops/match/conditions/conjconditions.cpp index 11b1c1481aa50e170c26735c2645e81cf2f6794c..c144716d738992072d92a5bd43b642176bd23d73 100644 --- a/libwccl/ops/match/conditions/conjconditions.cpp +++ b/libwccl/ops/match/conditions/conjconditions.cpp @@ -4,6 +4,7 @@ #include <sstream> namespace Wccl { +namespace Matching { ConjConditions::ConjConditions(const std::vector< boost::shared_ptr<const MatchCondition> >& conditions) : _conditions(conditions) @@ -55,4 +56,5 @@ std::ostream& ConjConditions::write_to(std::ostream &ostream) const return ostream; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/conjconditions.h b/libwccl/ops/match/conditions/conjconditions.h index d2df5c45d7e245992dce2a6d1b3c8d70597f2b3a..ef5104b0ee9bbbf10a4d7f3f62e9a114143c5247 100644 --- a/libwccl/ops/match/conditions/conjconditions.h +++ b/libwccl/ops/match/conditions/conjconditions.h @@ -4,6 +4,7 @@ #include <libwccl/ops/match/matchcondition.h> namespace Wccl { +namespace Matching { /** * Class that wraps a vector of match conditions to act as @@ -44,6 +45,7 @@ private: const std::vector<boost::shared_ptr<const MatchCondition> > _conditions; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_CONDITIONS_CONJCONDITIONS_H diff --git a/libwccl/ops/match/conditions/isannotatedas.cpp b/libwccl/ops/match/conditions/isannotatedas.cpp index 7d568acfad2a3df8085458f5a76b19b82423002d..433df1e78a1edfb2e8f9cfe5cfb825f1c9ee3afb 100644 --- a/libwccl/ops/match/conditions/isannotatedas.cpp +++ b/libwccl/ops/match/conditions/isannotatedas.cpp @@ -2,6 +2,7 @@ #include <sstream> namespace Wccl { +namespace Matching { MatchResult IsAnnotatedAs::apply(const ActionExecContext& context) const { @@ -55,4 +56,5 @@ std::ostream& IsAnnotatedAs::write_to(std::ostream& os) const return os << name() << "(\"" << chan_name_ << "\")"; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/isannotatedas.h b/libwccl/ops/match/conditions/isannotatedas.h index f2dcfbbb0cf57c4365836f7ed6446512fe1a45a7..e40fbd0332b7834cb00138ed57a9979f66da557f 100644 --- a/libwccl/ops/match/conditions/isannotatedas.h +++ b/libwccl/ops/match/conditions/isannotatedas.h @@ -5,6 +5,7 @@ #include <libwccl/ops/function.h> namespace Wccl { +namespace Matching { /** * is() match condition - matches an annotation @@ -46,6 +47,7 @@ private: const std::string chan_name_; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_CONDITIONS_ISANNOTATEDAS_H diff --git a/libwccl/ops/match/conditions/longest.cpp b/libwccl/ops/match/conditions/longest.cpp index 82a3653d12cf43216d76ce2561cd98cf239adf90..e1a5405cc57d8a779fe728829d5156a9acf9f296 100644 --- a/libwccl/ops/match/conditions/longest.cpp +++ b/libwccl/ops/match/conditions/longest.cpp @@ -4,6 +4,7 @@ #include <libpwrutils/foreach.h> namespace Wccl { +namespace Matching { Longest::Longest(const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > >& variants) : _variants(variants) @@ -58,4 +59,5 @@ std::ostream& Longest::write_to(std::ostream& ostream) const return ostream << ")"; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/longest.h b/libwccl/ops/match/conditions/longest.h index 008b50767b811b3f7d0ef1a205755afd68fccdae..070738fd0bd1e0eccb4670ff16f5f84abf4d0bee 100644 --- a/libwccl/ops/match/conditions/longest.h +++ b/libwccl/ops/match/conditions/longest.h @@ -4,6 +4,7 @@ #include <libwccl/ops/match/conditions/conjconditions.h> namespace Wccl { +namespace Matching { /** * Class for "longest" condition of match @@ -47,6 +48,7 @@ protected: private: const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > _variants; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_CONDITIONS_LONGEST_H diff --git a/libwccl/ops/match/conditions/matchtext.cpp b/libwccl/ops/match/conditions/matchtext.cpp index 2d01ee515ee3c2a4c66b1eecda9792b54f0b516e..6bad9979aed54c752eac26cde8dae9a5c551e641 100644 --- a/libwccl/ops/match/conditions/matchtext.cpp +++ b/libwccl/ops/match/conditions/matchtext.cpp @@ -4,6 +4,7 @@ namespace Wccl { +namespace Matching { MatchResult MatchText::apply(const ActionExecContext& context) const { @@ -46,4 +47,5 @@ std::ostream& MatchText::write_to(std::ostream& os) const return os << name() << "(\"" << PwrNlp::to_utf8(text_) << "\")"; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/matchtext.h b/libwccl/ops/match/conditions/matchtext.h index f56554000737c36d0dfb57f292d12cbebfb44693..6a6805ae9af2c6c6cbaa6b3ba231328f930b9ce0 100644 --- a/libwccl/ops/match/conditions/matchtext.h +++ b/libwccl/ops/match/conditions/matchtext.h @@ -6,6 +6,7 @@ #include <unicode/unistr.h> namespace Wccl { +namespace Matching { /** * text() match condition - matches a text */ @@ -46,6 +47,7 @@ private: const UnicodeString text_; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_CONDITIONS_MATCHTEXT_H diff --git a/libwccl/ops/match/conditions/oneof.cpp b/libwccl/ops/match/conditions/oneof.cpp index 068b04af3df261586d6bf6b0c0e8cfeaeb586b78..6871e84380650778c428efb5e30b12508b5fbc0a 100644 --- a/libwccl/ops/match/conditions/oneof.cpp +++ b/libwccl/ops/match/conditions/oneof.cpp @@ -4,6 +4,7 @@ #include <libpwrutils/foreach.h> namespace Wccl { +namespace Matching { OneOf::OneOf(const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > >& variants) : _variants(variants) @@ -51,4 +52,5 @@ std::ostream& OneOf::write_to(std::ostream& ostream) const return ostream << ")"; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/oneof.h b/libwccl/ops/match/conditions/oneof.h index a0d649a9d2d98c400569cd74abba4d98fa80d726..da6fc51d329038662e2426db4374e88c82b0e35c 100644 --- a/libwccl/ops/match/conditions/oneof.h +++ b/libwccl/ops/match/conditions/oneof.h @@ -4,6 +4,7 @@ #include <libwccl/ops/match/conditions/conjconditions.h> namespace Wccl { +namespace Matching { /** * Class for "oneof" condition of match @@ -46,6 +47,7 @@ protected: private: const boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > _variants; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_CONDITIONS_ONEOF_H diff --git a/libwccl/ops/match/conditions/optionalmatch.cpp b/libwccl/ops/match/conditions/optionalmatch.cpp index 03116898c8236a6b9ff851e3dfcb82916c0fb816..235fcc1595088512a13291c61f2fda1eb9ee1934 100644 --- a/libwccl/ops/match/conditions/optionalmatch.cpp +++ b/libwccl/ops/match/conditions/optionalmatch.cpp @@ -3,6 +3,7 @@ #include <sstream> namespace Wccl { +namespace Matching { OptionalMatch::OptionalMatch(const boost::shared_ptr<ConjConditions>& conditions) : _conditions(conditions) @@ -33,4 +34,5 @@ std::ostream& OptionalMatch::write_to(std::ostream& ostream) const return ostream << name() << *_conditions; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/optionalmatch.h b/libwccl/ops/match/conditions/optionalmatch.h index 97dfb07622a094bf03b40554d8789866ecc1b9df..beba430a947b4f803c135a6550209ba7da972846 100644 --- a/libwccl/ops/match/conditions/optionalmatch.h +++ b/libwccl/ops/match/conditions/optionalmatch.h @@ -4,6 +4,7 @@ #include <libwccl/ops/match/conditions/conjconditions.h> namespace Wccl { +namespace Matching { /** * Class for "optional" condition of match @@ -47,6 +48,7 @@ protected: private: const boost::shared_ptr<ConjConditions> _conditions; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_CONDITIONS_OPTIONALMATCH_H diff --git a/libwccl/ops/match/conditions/repeatedmatch.cpp b/libwccl/ops/match/conditions/repeatedmatch.cpp index f2fad5b6cc0653ac0df842f96c821c3f0a37d138..f5d71cb2db59a3b5a8ff1fd6601bc8a4d3382256 100644 --- a/libwccl/ops/match/conditions/repeatedmatch.cpp +++ b/libwccl/ops/match/conditions/repeatedmatch.cpp @@ -3,6 +3,7 @@ #include <sstream> namespace Wccl { +namespace Matching { RepeatedMatch::RepeatedMatch(const boost::shared_ptr<ConjConditions>& conditions) : _conditions(conditions) @@ -40,4 +41,5 @@ std::ostream& RepeatedMatch::write_to(std::ostream& ostream) const return ostream << name() << *_conditions; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/repeatedmatch.h b/libwccl/ops/match/conditions/repeatedmatch.h index 1d8764e151994848fb8cba744df390924e1e56bf..618945d38e04ec6a2acd8d7497f65be30027475a 100644 --- a/libwccl/ops/match/conditions/repeatedmatch.h +++ b/libwccl/ops/match/conditions/repeatedmatch.h @@ -4,6 +4,7 @@ #include <libwccl/ops/match/conditions/conjconditions.h> namespace Wccl { +namespace Matching { /** * Class for "repeat" condition of match @@ -49,6 +50,7 @@ private: const boost::shared_ptr<ConjConditions> _conditions; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_CONDITIONS_REPEATEDMATCH_H diff --git a/libwccl/ops/match/conditions/tokencondition.cpp b/libwccl/ops/match/conditions/tokencondition.cpp index 533a2ab7b5a031ce45c1c44be9e41a7539aa6392..06efcdf1c6047d2e770395317f97cf0075341ddd 100644 --- a/libwccl/ops/match/conditions/tokencondition.cpp +++ b/libwccl/ops/match/conditions/tokencondition.cpp @@ -2,6 +2,7 @@ #include <libwccl/values/tokenmatch.h> namespace Wccl { +namespace Matching { TokenCondition::TokenCondition(const boost::shared_ptr<Function<Bool> >& predicate) : _predicate(predicate) @@ -39,4 +40,5 @@ std::ostream& TokenCondition::write_to(std::ostream& os) const return os << *_predicate; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/match/conditions/tokencondition.h b/libwccl/ops/match/conditions/tokencondition.h index cc86a277ee6ae7552f601596bc149b6ab31edfaa..53d04324310a35dae53f039aa5db987f3795e2fc 100644 --- a/libwccl/ops/match/conditions/tokencondition.h +++ b/libwccl/ops/match/conditions/tokencondition.h @@ -5,6 +5,7 @@ #include <libwccl/ops/function.h> namespace Wccl { +namespace Matching { /** * Class for conditions of MatchOperator that operate on tokens, @@ -42,6 +43,7 @@ private: const boost::shared_ptr< const Function<Bool> > _predicate; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_CONDITIONS_TOKENCODITION_H diff --git a/libwccl/ops/match/matchaction.h b/libwccl/ops/match/matchaction.h index 115e5b17d43dab54a5159b49533f7284519062ee..527747ea787a06ab2b09ace9694568a8cf07e82d 100644 --- a/libwccl/ops/match/matchaction.h +++ b/libwccl/ops/match/matchaction.h @@ -5,6 +5,7 @@ #include <libwccl/ops/actionexeccontext.h> namespace Wccl { +namespace Matching { /** * Abstract base class for actions in WCCL match rules @@ -22,6 +23,7 @@ public: virtual void execute(const ActionExecContext& context) const = 0; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_MATCHACTION_H diff --git a/libwccl/ops/match/matchcondition.h b/libwccl/ops/match/matchcondition.h index 3b485065861242a2b5e2481e14e5ab7169641054..12dde83b7f2f6aeee8ab8d1fa6915eaaf785ce4b 100644 --- a/libwccl/ops/match/matchcondition.h +++ b/libwccl/ops/match/matchcondition.h @@ -6,6 +6,7 @@ #include <libwccl/ops/match/matchresult.h> namespace Wccl { +namespace Matching { /** * Abstract base class for conditions of MatchOperator @@ -25,6 +26,7 @@ public: virtual MatchResult apply(const ActionExecContext& context) const = 0; }; +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_MATCHCONDITION_H diff --git a/libwccl/ops/match/matchresult.h b/libwccl/ops/match/matchresult.h index a8b0745cca3a7ec88265f6e4d659a7c33cf10991..c4e2a05f0b24a0bf6bb4eaf307f3ab3c956f5fcc 100644 --- a/libwccl/ops/match/matchresult.h +++ b/libwccl/ops/match/matchresult.h @@ -5,6 +5,7 @@ #include <libwccl/values/match.h> namespace Wccl { +namespace Matching { /** * Class that represents a result of MatchCondition @@ -73,6 +74,7 @@ boost::shared_ptr<Match> MatchResult::get_match() const { return _match; } +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCH_MATCHRESULT_H diff --git a/libwccl/ops/matchrule.cpp b/libwccl/ops/matchrule.cpp index cb4b8b3ad0e605a1197b5b17191b1083cca784ea..fc89922476f7e95ccc71e7a4b19455992b641d48 100644 --- a/libwccl/ops/matchrule.cpp +++ b/libwccl/ops/matchrule.cpp @@ -5,6 +5,7 @@ #include <sstream> namespace Wccl { +namespace Matching { void MatchRule::apply(const boost::shared_ptr<Corpus2::AnnotatedSentence>& s) { @@ -34,4 +35,5 @@ std::ostream& MatchRule::write_to(std::ostream& os) const return os << *apply_; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/matchrule.h b/libwccl/ops/matchrule.h index 290590ee66be1b67567eb0c8775df220df733c44..f029d67bb3efce76a8049f0593fb752ddfbf1592 100644 --- a/libwccl/ops/matchrule.h +++ b/libwccl/ops/matchrule.h @@ -5,9 +5,10 @@ #include <libcorpus2/ann/annotatedsentence.h> namespace Wccl { +class SentenceContext; +namespace Matching { class ApplyOperator; -class SentenceContext; class MatchRule : public ParsedExpression { @@ -201,6 +202,7 @@ boost::shared_ptr<MatchRule> MatchRule::clone_clean_ptr() const { return copy; } +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCHRULE_H diff --git a/libwccl/ops/matchrulesequence.cpp b/libwccl/ops/matchrulesequence.cpp index eec6e42296fddd9770d6e810a4f1e68ee4e2089c..45f310150515f6068df5818d5ce53eece7ae196e 100644 --- a/libwccl/ops/matchrulesequence.cpp +++ b/libwccl/ops/matchrulesequence.cpp @@ -2,6 +2,7 @@ #include <libpwrutils/foreach.h> namespace Wccl { +namespace Matching { void MatchRuleSequence::apply_all(const boost::shared_ptr<Corpus2::AnnotatedSentence>& sentence) { @@ -42,5 +43,6 @@ std::ostream& MatchRuleSequence::write_to(std::ostream &os) const return os; } +} /* end ns Matching */ } /* end ns Wccl */ diff --git a/libwccl/ops/matchrulesequence.h b/libwccl/ops/matchrulesequence.h index db908a16ba1758bbb8fe75bcafccc563adfe5c0f..1b94aa0cd8c66cc9f3727019a0e13371f50f8171 100644 --- a/libwccl/ops/matchrulesequence.h +++ b/libwccl/ops/matchrulesequence.h @@ -4,6 +4,7 @@ #include <libwccl/ops/matchrule.h> namespace Wccl { +namespace Matching { /** * Represents a sequence of parsed WCCL Match rules. It's a conveniency wrapper around @@ -78,5 +79,6 @@ void MatchRuleSequence::operator()(const boost::shared_ptr<Corpus2::AnnotatedSen apply_all(sentence); } +} /* end ns Matching */ } /* end ns Wccl */ #endif // LIBWCCL_OPS_MATCHRULESEQUENCE_H diff --git a/libwccl/parser/Parser.cpp b/libwccl/parser/Parser.cpp index 8086cb2f6e88e36e023954f2fb18b93d4b03d743..75b694b94057a6956f5df95d3f423fef17fa0041 100644 --- a/libwccl/parser/Parser.cpp +++ b/libwccl/parser/Parser.cpp @@ -514,7 +514,7 @@ boost::shared_ptr<TagRule> Parser::parseSingleRule( * @arg istr input stream with writed rule * @return the parsed rule via a shared pointer */ -boost::shared_ptr<MatchRule> Parser::parseMatchRule( +boost::shared_ptr<Matching::MatchRule> Parser::parseMatchRule( const std::string& str) const { std::stringstream ss (std::stringstream::in | std::stringstream::out); @@ -533,11 +533,11 @@ boost::shared_ptr<MatchRule> Parser::parseMatchRule( * @arg istr input stream with writed rule * @return the parsed rule via a shared pointer */ -boost::shared_ptr<MatchRule> Parser::parseMatchRule(std::istream& istr) const +boost::shared_ptr<Matching::MatchRule> Parser::parseMatchRule(std::istream& istr) const { ANTLRLexer lexer(istr); ANTLRParser parser(lexer); - boost::shared_ptr<MatchRule> res; + boost::shared_ptr<Matching::MatchRule> res; try { res = parser.parse_match_rule(tagset_); diff --git a/libwccl/parser/Parser.h b/libwccl/parser/Parser.h index 09969a292086696d905342eaef3f0a4bf3e2ec50..bdc0a5e5417f739206ec62771869390e9caf2e5f 100644 --- a/libwccl/parser/Parser.h +++ b/libwccl/parser/Parser.h @@ -87,9 +87,9 @@ public: // --------------------------------------------------------------------------- // Parsing match rule from input string - boost::shared_ptr<MatchRule> + boost::shared_ptr<Matching::MatchRule> parseMatchRule(const std::string& rule_string) const; - boost::shared_ptr<MatchRule> + boost::shared_ptr<Matching::MatchRule> parseMatchRule(std::istream& is) const; // --------------------------------------------------------------------------- diff --git a/libwccl/parser/grammar.g b/libwccl/parser/grammar.g index c073e68415f021c689fcd9cff39a4a1b1fe84461..bde2a6227c20ee9e78ef984287c8878378ba4e11 100644 --- a/libwccl/parser/grammar.g +++ b/libwccl/parser/grammar.g @@ -278,10 +278,10 @@ parse_tag_rule_sequence // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Rule for parsing the match rules -// Returns boost::shared_ptr<MatchRule> +// Returns boost::shared_ptr<Matching::MatchRule> parse_match_rule [const Corpus2::Tagset& tagset] - returns [boost::shared_ptr<MatchRule> ret_match] + returns [boost::shared_ptr<Matching::MatchRule> ret_match] { Lexicons empty_lex; ParsingScope scope(tagset, empty_lex); @@ -1973,7 +1973,7 @@ symset_empty //---------------------------------------------------------------------------- // Strset empty() operator -// Returns boost::shared_ptr<Function<Bool> > +// Returns boost::shared_ptr<Function<Bool> > strset_empty [ParsingScope& scope] returns [boost::shared_ptr<Function<Bool> > op] @@ -2079,8 +2079,8 @@ tag_rules_section [WcclFile& wccl_file] match_rules_section [WcclFile& wccl_file] { ParsingScope scope(wccl_file); - boost::shared_ptr<MatchRule> match_rule; - boost::shared_ptr<MatchRuleSequence> rule_seq = boost::make_shared<MatchRuleSequence>(); + boost::shared_ptr<Matching::MatchRule> match_rule; + boost::shared_ptr<Matching::MatchRuleSequence> rule_seq = boost::make_shared<Matching::MatchRuleSequence>(); } : "match_rules" { if (wccl_file.has_match_rules()) { @@ -2484,30 +2484,30 @@ action_unmark // ---------------------------------------------------------------------------- // ---------------------------------------------------------------------------- // Match rules -// Returns boost::shared_ptr<MatchRule> +// Returns boost::shared_ptr<Matching::MatchRule> match_rule_operator [ParsingScope& scope] - returns [boost::shared_ptr<MatchRule> ret_op] + returns [boost::shared_ptr<Matching::MatchRule> ret_op] { - boost::shared_ptr<ApplyOperator> apply; + boost::shared_ptr<Matching::ApplyOperator> apply; scope.variables().get_put<Match>("_M"); } : apply = match_apply_operator [scope] { - ret_op = boost::make_shared<MatchRule>(scope.variables(), apply); + ret_op = boost::make_shared<Matching::MatchRule>(scope.variables(), apply); } ; // Match apply operator: // apply(match(), cond(conditions), actions(actions)) // apply(match(), actions(actions)) -// Returns boost::shared_ptr<ApplyOperator> +// Returns boost::shared_ptr<Matching::ApplyOperator> match_apply_operator [ParsingScope& scope] - returns [boost::shared_ptr<ApplyOperator> ret_op] + returns [boost::shared_ptr<Matching::ApplyOperator> ret_op] { VariableAccessor<Match> matches = scope.variables().create_accessor<Match>("_M");; - boost::shared_ptr<ConjConditions> match_cond; - boost::shared_ptr<std::vector<boost::shared_ptr<MatchAction> > > actions; + boost::shared_ptr<Matching::ConjConditions> match_cond; + boost::shared_ptr<std::vector<boost::shared_ptr<Matching::MatchAction> > > actions; boost::shared_ptr<std::vector<boost::shared_ptr<Function<Bool> > > > conditions; } : "apply" LPAREN @@ -2517,12 +2517,12 @@ match_apply_operator RPAREN { if (conditions) { ret_op.reset( - new ApplyOperator(matches, match_cond, actions, conditions) + new Matching::ApplyOperator(matches, match_cond, actions, conditions) ); } else { ret_op.reset( - new ApplyOperator(matches, match_cond, actions) + new Matching::ApplyOperator(matches, match_cond, actions) ); } } @@ -2531,22 +2531,22 @@ match_apply_operator // Match conditions. Wrapper for vector of the match conditions match_condition [ParsingScope& scope] - returns [boost::shared_ptr<ConjConditions> condition] + returns [boost::shared_ptr<Matching::ConjConditions> condition] { - std::vector<boost::shared_ptr<const MatchCondition> > m_cond; + std::vector<boost::shared_ptr<const Matching::MatchCondition> > m_cond; } : m_cond = match_condition_in [scope] { - condition.reset(new ConjConditions(m_cond)); + condition.reset(new Matching::ConjConditions(m_cond)); } ; // Match conditions. -// Retutns std::vector< boost::shared_ptr<const MatchCondition> > +// Retutns std::vector< boost::shared_ptr<const Matching::MatchCondition> > match_condition_in [ParsingScope& scope] - returns [std::vector< boost::shared_ptr<const MatchCondition> > ret] + returns [std::vector< boost::shared_ptr<const Matching::MatchCondition> > ret] { - boost::shared_ptr<const MatchCondition> r_cond; + boost::shared_ptr<const Matching::MatchCondition> r_cond; } : r_cond = match_cond_all[scope] { ret.push_back(r_cond); @@ -2560,14 +2560,14 @@ match_condition_in ; // Match variants variant(v1), variant(v2), ... -// Retutns boost::shared_ptr<std::vector<ConjConditions> > +// Retutns boost::shared_ptr<std::vector<Matching::ConjConditions> > match_variants [ParsingScope& scope] - returns [boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > variants] + returns [boost::shared_ptr<std::vector<boost::shared_ptr<Matching::ConjConditions> > > variants] { - variants.reset(new std::vector<boost::shared_ptr<ConjConditions> >()); + variants.reset(new std::vector<boost::shared_ptr<Matching::ConjConditions> >()); - boost::shared_ptr<ConjConditions> variant; + boost::shared_ptr<Matching::ConjConditions> variant; } : "variant" LPAREN variant = match_condition [scope] RPAREN { variants->push_back(variant); @@ -2580,10 +2580,10 @@ match_variants ; // One of the match condition -// Returns boost::shared_ptr<const MatchCondition> +// Returns boost::shared_ptr<const Matching::MatchCondition> match_cond_all [ParsingScope& scope] - returns [boost::shared_ptr<const MatchCondition> ret] + returns [boost::shared_ptr<const Matching::MatchCondition> ret] : ret = match_cond_optional [scope] | ret = match_cond_repeate [scope] | ret = match_cond_token [scope] @@ -2594,96 +2594,96 @@ match_cond_all ; // Match condition - token (wraps a L0 predicate) -// Returns boost::shared_ptr<const MatchCondition> +// Returns boost::shared_ptr<const Matching::MatchCondition> match_cond_token [ParsingScope& scope] - returns [boost::shared_ptr<const TokenCondition> ret] + returns [boost::shared_ptr<const Matching::TokenCondition> ret] { boost::shared_ptr<Function<Bool> > bool_op; } : bool_op = bool_operator [scope] { - ret = boost::make_shared<TokenCondition>(bool_op); + ret = boost::make_shared<Matching::TokenCondition>(bool_op); } ; // Match condition - optional -// Returns boost::shared_ptr<OptionalMatch> +// Returns boost::shared_ptr<Matching::OptionalMatch> match_cond_optional [ParsingScope& scope] - returns [boost::shared_ptr<OptionalMatch> mtch] + returns [boost::shared_ptr<Matching::OptionalMatch> mtch] { - boost::shared_ptr<ConjConditions> m_cond; + boost::shared_ptr<Matching::ConjConditions> m_cond; } : "optional" LPAREN m_cond = match_condition [scope] RPAREN { - mtch.reset(new OptionalMatch(m_cond)); + mtch.reset(new Matching::OptionalMatch(m_cond)); } ; // Match condition - repeat -// Returns boost::shared_ptr<RepeatedMatch> +// Returns boost::shared_ptr<Matching::RepeatedMatch> match_cond_repeate [ParsingScope& scope] - returns [boost::shared_ptr<RepeatedMatch> mtch] + returns [boost::shared_ptr<Matching::RepeatedMatch> mtch] { - boost::shared_ptr<ConjConditions> m_cond; + boost::shared_ptr<Matching::ConjConditions> m_cond; } : "repeat" LPAREN m_cond = match_condition [scope] RPAREN { - mtch.reset(new RepeatedMatch(m_cond)); + mtch.reset(new Matching::RepeatedMatch(m_cond)); } ; // Match condition - is(ann_name) -// Returns boost::shared_ptr<IsAnnotatedAs> +// Returns boost::shared_ptr<Matching::IsAnnotatedAs> match_cond_is - returns [boost::shared_ptr<IsAnnotatedAs> mtch] + returns [boost::shared_ptr<Matching::IsAnnotatedAs> mtch] : "is" LPAREN annotation_name: STRING RPAREN { - mtch.reset(new IsAnnotatedAs(token_ref_to_std_string(annotation_name))); + mtch.reset(new Matching::IsAnnotatedAs(token_ref_to_std_string(annotation_name))); } ; // Match condition - text(text) -// Returns boost::shared_ptr<MatchText> +// Returns boost::shared_ptr<Matching::MatchText> match_cond_text - returns [boost::shared_ptr<MatchText> mtch] + returns [boost::shared_ptr<Matching::MatchText> mtch] : "text" LPAREN txt: STRING RPAREN { - mtch.reset(new MatchText(token_ref_to_ustring(txt))); + mtch.reset(new Matching::MatchText(token_ref_to_ustring(txt))); } ; // Match condition - oneof(variant1(v1), variant(v2), ...) -// Returns boost::shared_ptr<OneOf> +// Returns boost::shared_ptr<Matching::OneOf> match_cond_oneof [ParsingScope& scope] - returns [boost::shared_ptr<OneOf> onf] + returns [boost::shared_ptr<Matching::OneOf> onf] { - boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > variants; + boost::shared_ptr<std::vector<boost::shared_ptr<Matching::ConjConditions> > > variants; } : "oneof" LPAREN variants = match_variants [scope] RPAREN { - onf.reset(new OneOf(variants)); + onf.reset(new Matching::OneOf(variants)); } ; // Match condition - longest(variant1(v1), variant(v2), ...) -// Returns boost::shared_ptr<Longest> +// Returns boost::shared_ptr<Matching::Longest> match_cond_longest [ParsingScope& scope] - returns [boost::shared_ptr<Longest> lng] + returns [boost::shared_ptr<Matching::Longest> lng] { - boost::shared_ptr<std::vector<boost::shared_ptr<ConjConditions> > > variants; + boost::shared_ptr<std::vector<boost::shared_ptr<Matching::ConjConditions> > > variants; } : "longest" LPAREN variants = match_variants [scope] RPAREN { - lng.reset(new Longest(variants)); + lng.reset(new Matching::Longest(variants)); } ; // ---------------------------------------------------------------------------- // Match actions. Match action can be mark or unmark -// Returns boost::shared_ptr<MatchAction> +// Returns boost::shared_ptr<Matching::MatchAction> match_action [ParsingScope& scope] - returns [boost::shared_ptr<MatchAction> m_act] + returns [boost::shared_ptr<Matching::MatchAction> m_act] : m_act = match_mark_action [scope] | m_act = match_unmark_action [scope] ; @@ -2692,7 +2692,7 @@ match_action // Returns match_mark_action [ParsingScope& scope] - returns [boost::shared_ptr<MarkMatch> m_act] + returns [boost::shared_ptr<Matching::MarkMatch> m_act] { boost::shared_ptr<Function<Match> > match_to; boost::shared_ptr<Function<Match> > match_from; @@ -2707,19 +2707,19 @@ match_mark_action RPAREN { if (!match_to) { m_act.reset( - new MarkMatch( + new Matching::MarkMatch( match_from, ((antlr::Token*)annotation_name)->getText())); } else { if (!head_match) { m_act.reset( - new MarkMatch( + new Matching::MarkMatch( match_from, match_to, ((antlr::Token*)annotation_name)->getText())); } else { m_act.reset( - new MarkMatch( + new Matching::MarkMatch( match_from, match_to, head_match, @@ -2730,10 +2730,10 @@ match_mark_action ; // Match unmark action -// Returns boost::shared_ptr<UnmarkMatch> +// Returns boost::shared_ptr<Matching::UnmarkMatch> match_unmark_action [ParsingScope& scope] - returns [boost::shared_ptr<UnmarkMatch> m_act] + returns [boost::shared_ptr<Matching::UnmarkMatch> m_act] { boost::shared_ptr<Function<Match> > match_at; } @@ -2742,22 +2742,22 @@ match_unmark_action annotation_name : STRING RPAREN { m_act.reset( - new UnmarkMatch( + new Matching::UnmarkMatch( match_at, ((antlr::Token*)annotation_name)->getText())); } ; // Match action separated by comma -// Returns boost::shared_ptr<std::vector<boost::shared_ptr<MatchAction> > > +// Returns boost::shared_ptr<std::vector<boost::shared_ptr<Matching::MatchAction> > > match_action_comma_sep [ParsingScope& scope] - returns [boost::shared_ptr<std::vector<boost::shared_ptr<MatchAction> > > r_vec] + returns [boost::shared_ptr<std::vector<boost::shared_ptr<Matching::MatchAction> > > r_vec] { - boost::shared_ptr<MatchAction> act; + boost::shared_ptr<Matching::MatchAction> act; r_vec.reset( - new std::vector<boost::shared_ptr<MatchAction> > + new std::vector<boost::shared_ptr<Matching::MatchAction> > ); } : act = match_action [scope] { diff --git a/libwccl/wcclfile.cpp b/libwccl/wcclfile.cpp index 22cb8edee7cbe91389bda809c3b5fbca9a85bb02..132fddfa489ab0240c07c91fafc323978bef39c3 100644 --- a/libwccl/wcclfile.cpp +++ b/libwccl/wcclfile.cpp @@ -36,7 +36,7 @@ boost::shared_ptr<const TagRuleSequence> WcclFile::get_tag_rules_ptr() const return tag_rules_; } -boost::shared_ptr<MatchRuleSequence> WcclFile::get_match_rules_ptr() +boost::shared_ptr<Matching::MatchRuleSequence> WcclFile::get_match_rules_ptr() { if (!has_match_rules()) { throw WcclError("There are no match rules."); @@ -44,7 +44,7 @@ boost::shared_ptr<MatchRuleSequence> WcclFile::get_match_rules_ptr() return match_rules_; } -boost::shared_ptr<const MatchRuleSequence> WcclFile::get_match_rules_ptr() const +boost::shared_ptr<const Matching::MatchRuleSequence> WcclFile::get_match_rules_ptr() const { if (!has_match_rules()) { throw WcclError("There are no match rules."); diff --git a/libwccl/wcclfile.h b/libwccl/wcclfile.h index e012b58b2e2357de68f534387c83fe02b4fba753..709ea59bc3872060572859d6c44981f22149d4e2 100644 --- a/libwccl/wcclfile.h +++ b/libwccl/wcclfile.h @@ -285,17 +285,17 @@ public: * @returns The match rules section from this WCCL file. * @throws WcclError if there is no match_rules section. */ - const MatchRuleSequence& get_match_rules() const; + const Matching::MatchRuleSequence& get_match_rules() const; /** * @returns The match rules section from this WCCL file. * @throws WcclError if there is no match_rules section. */ - boost::shared_ptr<MatchRuleSequence> get_match_rules_ptr(); + boost::shared_ptr<Matching::MatchRuleSequence> get_match_rules_ptr(); /** * @returns The match rules section from this WCCL file (const). * @throws WcclError if there is no match_rules section. */ - boost::shared_ptr<const MatchRuleSequence> get_match_rules_ptr() const; + boost::shared_ptr<const Matching::MatchRuleSequence> get_match_rules_ptr() const; /////////////////////////// // Miscelaneous @@ -324,13 +324,13 @@ public: void set_tag_rules(const boost::shared_ptr<TagRuleSequence>& tag_rules); - void set_match_rules(const boost::shared_ptr<MatchRuleSequence>& match_rules); + void set_match_rules(const boost::shared_ptr<Matching::MatchRuleSequence>& match_rules); private: std::ostream& write_to(std::ostream& ostream) const; std::vector<boost::shared_ptr<FunctionalOpSequence> > all_sections_; boost::shared_ptr<TagRuleSequence> tag_rules_; - boost::shared_ptr<MatchRuleSequence> match_rules_; + boost::shared_ptr<Matching::MatchRuleSequence> match_rules_; boost::shared_ptr<Lexicons> lexicons_; const Corpus2::Tagset& tagset_; PwrNlp::PathSearcher<Wccl::FileNotFound> path_; @@ -627,13 +627,13 @@ bool WcclFile::has_match_rules() const } inline -const MatchRuleSequence& WcclFile::get_match_rules() const +const Matching::MatchRuleSequence& WcclFile::get_match_rules() const { return *get_match_rules_ptr(); } inline -void WcclFile::set_match_rules(const boost::shared_ptr<MatchRuleSequence>& match_rules) +void WcclFile::set_match_rules(const boost::shared_ptr<Matching::MatchRuleSequence>& match_rules) { if (has_match_rules()) { throw WcclError("Tag rules already added."); diff --git a/swig/matchrule.i b/swig/matchrule.i index 41002c613db3ad9ec124e46686c8abd08b9847ca..52165c9300abf46ac053c48dae7b763b4da6868f 100644 --- a/swig/matchrule.i +++ b/swig/matchrule.i @@ -14,6 +14,7 @@ %include <libcorpus2/boost_shared_ptr.i> namespace Wccl { +namespace Matching { class MatchRule : public ParsedExpression { public: MatchRule( @@ -48,8 +49,10 @@ namespace Wccl { std::string to_string(const Corpus2::Tagset& tagset) const; }; } +} using namespace std; using namespace Wccl; +using namespace Wccl::Matching; #endif /* SWIG_LIBWCCL_MATCHRULE_I */ diff --git a/swig/matchrulesequence.i b/swig/matchrulesequence.i index 73c27e8d03986c207614b977c2fc3955a8fc6535..f746531ab45d5ac571465e6b177d9e0aeb760f03 100644 --- a/swig/matchrulesequence.i +++ b/swig/matchrulesequence.i @@ -14,11 +14,12 @@ %include "std_vector.i" %include <libcorpus2/boost_shared_ptr.i> -%template(MatchRuleVector) std::vector<Wccl::MatchRule>; -%template(MatchRuleSequencePtr) boost::shared_ptr<Wccl::MatchRule>; -%template(ConstMatchRuleSequencePtr) boost::shared_ptr<const Wccl::MatchRule>; +%template(MatchRuleVector) std::vector<Wccl::Matching::MatchRule>; +%template(MatchRuleSequencePtr) boost::shared_ptr<Wccl::Matching::MatchRule>; +%template(ConstMatchRuleSequencePtr) boost::shared_ptr<const Wccl::Matching::MatchRule>; namespace Wccl { +namespace Matching { class MatchRuleSequence : public std::vector<MatchRule>, public Expression { public: MatchRuleSequence(); @@ -38,9 +39,11 @@ namespace Wccl { std::string to_string(const Corpus2::Tagset& tagset) const; }; } +} using namespace boost; using namespace Wccl; using namespace std; +using namespace Wccl::Matching; #endif /* SWIG_LIBWCCL_MATCHRULESEQUENCE_I */ diff --git a/swig/wcclfile.i b/swig/wcclfile.i index 8e0fe411fb23f8ccca567bf92222d7e897bf36f0..f7821d63f4ffe284f470ab75169a996279db192d 100644 --- a/swig/wcclfile.i +++ b/swig/wcclfile.i @@ -303,10 +303,10 @@ namespace Wccl { bool has_match_rules() const; - const MatchRuleSequence& get_match_rules() const; + const Matching::MatchRuleSequence& get_match_rules() const; // shared_ptr<const MatchRuleSequence> get_match_rules_ptr() const; - shared_ptr<MatchRuleSequence> get_match_rules_ptr(); + shared_ptr<Matching::MatchRuleSequence> get_match_rules_ptr(); /* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */