From 26f56ceef0e917b13da823f6829aa89988d3f3bb Mon Sep 17 00:00:00 2001 From: Adam Radziszewski <adam.radziszewski@pwr.wroc.pl> Date: Thu, 5 Jul 2012 13:07:06 +0200 Subject: [PATCH] add add_channel to annot sent --- libcorpus2/ann/annotatedsentence.h | 13 +++++++++++++ swig/annotatedsentence.i | 1 + 2 files changed, 14 insertions(+) diff --git a/libcorpus2/ann/annotatedsentence.h b/libcorpus2/ann/annotatedsentence.h index b1207f4..d186248 100644 --- a/libcorpus2/ann/annotatedsentence.h +++ b/libcorpus2/ann/annotatedsentence.h @@ -96,6 +96,19 @@ public: return i->second; } + /** + * Add a copy of the given annotation channel. + * If a channel of the given name already exists, will do nothing and return false. + * Otherwise, will add the channel and return true. + */ + bool add_channel(const std::string& name, const AnnotationChannel& chan) { + if (has_channel(name)) { + return false; + } + channels_.insert(std::make_pair(name, chan)); + return true; + } + const chan_map_t& all_channels() const { return channels_; } diff --git a/swig/annotatedsentence.i b/swig/annotatedsentence.i index 07232be..0c59edb 100644 --- a/swig/annotatedsentence.i +++ b/swig/annotatedsentence.i @@ -49,6 +49,7 @@ namespace Corpus2 { AnnotationChannel& get_channel(const std::string& name); const AnnotationChannel& get_channel(const std::string& name) const; + bool add_channel(const std::string& name, const AnnotationChannel& chan); const chan_map_t& all_channels() const; /* --------------------------------------------------------------------- */ -- GitLab