diff options
author | Chris Dyer <redpony@gmail.com> | 2014-10-09 00:43:57 -0400 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2014-10-09 00:43:57 -0400 |
commit | 1d87fbb31502ba27f0469e4a576e410ee43ad77a (patch) | |
tree | dbc8a9d743a77fb1a6be229af2c49f9fe4858c8a /decoder/lattice.h | |
parent | 8601c7fa4ca6fe8093ec54cd2c150cf130484297 (diff) |
make tree terminals available to feature functions
Diffstat (limited to 'decoder/lattice.h')
-rw-r--r-- | decoder/lattice.h | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/decoder/lattice.h b/decoder/lattice.h index ad4ca50d..39db0a0e 100644 --- a/decoder/lattice.h +++ b/decoder/lattice.h @@ -25,22 +25,24 @@ class Lattice : public std::vector<std::vector<LatticeArc> > { friend void LatticeTools::ConvertTextOrPLF(const std::string& text_or_plf, Lattice* pl); friend void LatticeTools::ConvertTextToLattice(const std::string& text, Lattice* pl); public: - Lattice() : is_sentence_(false) {} + Lattice() {} explicit Lattice(size_t t, const std::vector<LatticeArc>& v = std::vector<LatticeArc>()) : - std::vector<std::vector<LatticeArc> >(t, v), - is_sentence_(false) {} + std::vector<std::vector<LatticeArc>>(t, v) {} int Distance(int from, int to) const { if (dist_.empty()) return (to - from); return dist_(from, to); } - // TODO this should actually be computed based on the contents - // of the lattice - bool IsSentence() const { return is_sentence_; } private: void ComputeDistances(); Array2D<int> dist_; - bool is_sentence_; }; +inline bool IsSentence(const Lattice& in) { + bool res = true; + for (auto& alt : in) + if (alt.size() > 1) { res = false; break; } + return res; +} + #endif |