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

getorth.cpp

Blame
  • user avatar
    Pawel Orlowicz authored
    00defdd2
    History
    getorth.cpp 1.49 KiB
    /*
        Copyright (C) 2011 Adam Wardyński, Tomasz Śniatowski, Paweł Kędzia,
        Adam Radziszewski, Bartosz Broda
        Part of the WCCL project
    
        This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU Lesser General Public License as published by the Free
    Software Foundation; either version 3 of the License, or (at your option)
    any later version.
    
        This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    or FITNESS FOR A PARTICULAR PURPOSE. 
    
        See the LICENSE, COPYING.LESSER and COPYING files for more details.
    */
    
    #include <libwccl/ops/functions/strset/getorth.h>
    #include <libwccl/ops/formatters.h>
    #include <libwccl/ops/functions/constant.h>
    
    namespace Wccl {
    
    std::string GetOrth::to_string(const Corpus2::Tagset& tagset) const
    {
    	return UnaryFunctionFormatter::to_string(tagset, *this, *pos_expr_, "[", "]");
    }
    
    std::ostream& GetOrth::write_to(std::ostream& os) const
    {
    	return os << raw_name() << "[" << *pos_expr_ << "]";
    }
    
    GetOrth::BaseRetValPtr GetOrth::apply_internal(const FunExecContext& context) const
    {
    	const boost::shared_ptr<const Position>& pos = pos_expr_->apply(context);
    	const SentenceContext& sc = context.sentence_context();
    	if (sc.is_outside(*pos)) {
    		return detail::DefaultFunction<StrSet>()->apply(context);
    	}
    	boost::shared_ptr<StrSet> u_set = boost::make_shared<StrSet>();
    	u_set->insert(sc.at(*pos)->orth());
    	return u_set;
    }
    
    } /* end ns Wccl */