Skip to content
Snippets Groups Projects
Select Git revision
  • 3630de8d41e18d27861fcc242b1ab77572726430
  • main default protected
  • ud_training_script
  • fix_seed
  • merged-with-ner
  • multiword_fix_transformer
  • transformer_encoder
  • combo3
  • save_deprel_matrix_to_npz
  • master protected
  • combo-lambo
  • lambo-sent-attributes
  • adding_lambo
  • develop
  • update_allenlp2
  • develop_tmp
  • tokens_truncation
  • LR_test
  • eud_iwpt
  • iob
  • eud_iwpt_shared_task_bert_finetuning
  • 3.3.1
  • list
  • 3.2.1
  • 3.0.3
  • 3.0.1
  • 3.0.0
  • v1.0.6
  • v1.0.5
  • v1.0.4
  • v1.0.3
  • v1.0.2
  • v1.0.1
  • v1.0.0
34 results

test.tsv

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 */