-
Notifications
You must be signed in to change notification settings - Fork 0
/
compare.hpp
61 lines (50 loc) · 1.76 KB
/
compare.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#pragma once
#include "grams.pb.h"
namespace cllc {
/////////////////////////////////////////////////////////////////////////////
// messages //
/////////////////////////////////////////////////////////////////////////////
struct BigramMore {
inline bool operator()(const grams::Bigram &l, const grams::Bigram &r) const {
return std::make_tuple(l.id1(), l.id2()) >
std::make_tuple(r.id1(), r.id2());
}
};
struct BigramEq {
inline bool operator()(const grams::Bigram &l, const grams::Bigram &r) const {
return (l.id1() == r.id1()) && (l.id2() == r.id2());
}
};
struct TrigramMore {
inline bool operator()(const grams::Trigram &l,
const grams::Trigram &r) const {
return std::make_tuple(l.id1(), l.id2(), l.id3()) >
std::make_tuple(r.id1(), r.id2(), r.id3());
}
};
struct TrigramEq {
inline bool operator()(const grams::Trigram &l,
const grams::Trigram &r) const {
return (l.id1() == r.id1()) && (l.id2() == r.id2()) && (l.id3() == r.id3());
}
};
struct Lem2AndWordsMore {
inline bool operator()(const grams::Lem2AndWords &l,
const grams::Lem2AndWords &r) const {
return std::make_tuple(l.lid1(), l.lid2()) >
std::make_tuple(r.lid1(), r.lid2());
}
};
struct Lem3AndWordsMore {
inline bool operator()(const grams::Lem3AndWords &l,
const grams::Lem3AndWords &r) const {
return std::make_tuple(l.lid1(), l.lid2(), l.lid3()) >
std::make_tuple(r.lid1(), r.lid2(), r.lid3());
}
};
template <class T> struct LemGroupLess {
inline bool operator()(const T &l, const T &r) const {
return l.weight() < r.weight();
}
};
} // namespace cllc