Sha256: 7b1e9890fd93aafe9e709a1d3addd6c20157a6059583f368c6de7eac710830c0
Contents?: true
Size: 1.85 KB
Versions: 1
Compression:
Stored size: 1.85 KB
Contents
#ifndef _RULES_H_ #define _RULES_H_ #include <vector> #include <algorithm> #include "chunk.h" namespace rmmseg { template <typename Cmp> int take_highest(Chunk *chunks, int n, Cmp &cmp) { int i = 1, j; Chunk &max = chunks[0]; for (j = 1; j < n; ++j) { int rlt = cmp(chunks[j], max); if (rlt > 0) i = 0; if (rlt >= 0) std::swap(chunks[i++], chunks[j]); } return i; } struct MMCmp_t { int operator()(Chunk &a, Chunk &b) { return a.total_length() - b.total_length(); } } MMCmp; int mm_filter(Chunk *chunks, int n) { return take_highest(chunks, n, MMCmp); } struct LAWLCmp_t { int operator()(Chunk &a, Chunk &b) { double rlt = a.average_length() - b.average_length(); if (rlt == 0) return 0; if (rlt > 0) return 1; return -1; } } LAWLCmp; int lawl_filter(Chunk *chunks, int n) { return take_highest(chunks, n, LAWLCmp); } struct SVWLCmp_t { int operator()(Chunk &a, Chunk& b) { double rlt = a.variance() - b.variance(); if (rlt == 0) return 0; if (rlt < 0) return 1; return -1; } } SVWLCmp; int svwl_filter(Chunk *chunks, int n) { return take_highest(chunks, n, SVWLCmp); } struct LSDMFOCWCmp_t { int operator()(Chunk &a, Chunk& b) { return a.degree_of_morphemic_freedom() - b.degree_of_morphemic_freedom(); } } LSDMFOCWCmp; int lsdmfocw_filter(Chunk *chunks, int n) { return take_highest(chunks, n, LSDMFOCWCmp); } } #endif /* _RULES_H_ */
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rmmseg-cpp-0.2.7 | ext/rmmseg/rules.h |