-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdyana_ioe_readout.hpp
41 lines (30 loc) · 1.13 KB
/
dyana_ioe_readout.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//
// Created by YAN Yuchen on 5/8/2018.
//
#ifndef FRAME_ANALYSIS_DYNET_IOE_READOUT_HPP
#define FRAME_ANALYSIS_DYNET_IOE_READOUT_HPP
#include "dyana_iobes_readout_base.hpp"
namespace dyana {
class ioe_readout : public iobes_readout_base {
public:
ioe_readout() = default;
ioe_readout(const ioe_readout &) = default;
ioe_readout(ioe_readout &&) = default;
ioe_readout &operator=(const ioe_readout &) = default;
ioe_readout &operator=(ioe_readout &&) = default;
template<typename RANGE_EXP>
ioe_readout(RANGE_EXP &&tokens) :
iobes_readout_base({"I", "E"}, tokens) {}
protected:
virtual std::pair<std::string, std::string>
get_prefixed_label_at_token_index(unsigned index, const std::vector<labeled_span_type> &labeled_spans) const {
for (auto itr = labeled_spans.begin(); itr != labeled_spans.end(); ++itr) {
if (index < itr->s()) continue;
if (index + 1 == itr->t()) return make_pair("E", itr->label());
if (index < itr->t()) return make_pair("I", itr->label());
}
return std::make_pair("O", "");
}
};
}
#endif //FRAME_ANALYSIS_DYNET_IOE_READOUT_HPP