From dc6930c00b4b276883280cff1ed6dcd9ddef03c7 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Tue, 8 Dec 2009 21:38:55 -0500 Subject: LICENSE fixes, full support of lattice decoding --- src/lattice.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'src/lattice.h') diff --git a/src/lattice.h b/src/lattice.h index 1177e768..71589b92 100644 --- a/src/lattice.h +++ b/src/lattice.h @@ -4,6 +4,14 @@ #include #include #include "wordid.h" +#include "array2d.h" + +class Lattice; +struct LatticeTools { + static bool LooksLikePLF(const std::string &line); + static void ConvertTextToLattice(const std::string& text, Lattice* pl); + static void ConvertTextOrPLF(const std::string& text_or_plf, Lattice* pl); +}; struct LatticeArc { WordID label; @@ -14,18 +22,20 @@ struct LatticeArc { }; class Lattice : public std::vector > { + friend void LatticeTools::ConvertTextOrPLF(const std::string& text_or_plf, Lattice* pl); public: Lattice() {} explicit Lattice(size_t t, const std::vector& v = std::vector()) : std::vector >(t, v) {} - - // TODO add distance functions -}; + int Distance(int from, int to) const { + if (dist_.empty()) + return (to - from); + return dist_(from, to); + } -struct LatticeTools { - static bool LooksLikePLF(const std::string &line); - static void ConvertTextToLattice(const std::string& text, Lattice* pl); - static void ConvertTextOrPLF(const std::string& text_or_plf, Lattice* pl); + private: + void ComputeDistances(); + Array2D dist_; }; #endif -- cgit v1.2.3