Skip to content
Snippets Groups Projects
Select Git revision
  • 11e590fa32a9ecfafbe9be666769019889318ab4
  • master default protected
  • fix-words-ann
  • wccl-rules-migration
  • develop
5 results

isannotatedas.h

Blame
  • isannotatedas.h 1.24 KiB
    #ifndef LIBWCCL_OPS_MATCH_CONDITIONS_ISANNOTATEDAS_H
    #define LIBWCCL_OPS_MATCH_CONDITIONS_ISANNOTATEDAS_H
    
    #include <libwccl/ops/match/matchcondition.h>
    #include <libwccl/ops/function.h>
    
    namespace Wccl {
    
    /**
     * is() match condition - matches an annotation
     */
    class IsAnnotatedAs : public MatchCondition
    {
    public:
    	IsAnnotatedAs(const std::string& annotation_name)
    		: chan_name_(annotation_name) {
    			BOOST_ASSERT(!chan_name_.empty());
    	}
    	/**
    	 * @returns Name of the Condition.
    	 */
    	std::string name() const {
    		return "is";
    	}
    	/**
    	 * Applies the condition to the given execution context.
    	 * If a match is found, the current sentence Position is increased
    	 * by the lenght of matched annotation segment.
    	 */
    	MatchResult apply(const ActionExecContext& context) const;
    
    	/**
    	 * @returns String representation of the Condition
    	 */
    	std::string to_string(const Corpus2::Tagset& tagset) const;
    
    protected:
    	/**
    	 * Writes the string representation of the Condition to
    	 * an output stream.
    	 * @returns Stream written to.
    	 * @note May be incomplete and/or containt internal info.
    	 */
    	std::ostream& write_to(std::ostream& ostream) const;
    private:
    	const std::string chan_name_;
    };
    
    } /* end ns Wccl */
    
    #endif // LIBWCCL_OPS_MATCH_CONDITIONS_ISANNOTATEDAS_H