Skip to content
Snippets Groups Projects
Select Git revision
  • 5ddecdd27045f82acb35fd2d2c6665ca2bc78ca5
  • master default protected
  • vertical_relations
  • lu_without_semantic_frames
  • hierarchy
  • additional-unification-filters
  • v0.1.1
  • v0.1.0
  • v0.0.9
  • v0.0.8
  • v0.0.7
  • v0.0.6
  • v0.0.5
  • v0.0.4
  • v0.0.3
  • v0.0.2
  • v0.0.1
17 results

Dockerfile

Blame
  • annotationmatch.cpp 1.06 KiB
    #include <libwccl/values/annotationmatch.h>
    #include <libwccl/values/position.h>
    #include <boost/lexical_cast.hpp>
    
    namespace Wccl {
    
    std::string AnnotationMatch::to_raw_string() const
    {
    	return "ANN[" + boost::lexical_cast<std::string>(abs_pos_) + "," + channel_ + "]";
    }
    
    int AnnotationMatch::first_token(const boost::shared_ptr<Corpus2::AnnotatedSentence>& s) const
    {
    	const Corpus2::AnnotationChannel& chan = s->get_channel(channel_);
    	int seg = chan.get_segment_at(abs_pos_);
    	if (seg > 0) {
    		for (int i = 0; i < abs_pos_; ++i) {
    			if (chan.get_segment_at(i) == seg) {
    				return i;
    			}
    		}
    		return abs_pos_;
    	} else {
    		return Position::Nowhere;
    	}
    }
    
    int AnnotationMatch::last_token(const boost::shared_ptr<Corpus2::AnnotatedSentence>& s) const
    {
    	const Corpus2::AnnotationChannel& chan = s->get_channel(channel_);
    	int seg = chan.get_segment_at(abs_pos_);
    	if (seg > 0) {
    		for (int i = s->size() - 1; i > abs_pos_; --i) {
    			if (chan.get_segment_at(i) == seg) {
    				return i;
    			}
    		}
    		return abs_pos_;
    	} else {
    		return Position::Nowhere;
    	}
    }
    
    
    } /* end ns Wccl */