diff --git a/reading_machine/include/Config.hpp b/reading_machine/include/Config.hpp index 1819615fd48c0d04ed51e1a687b4fc6246f8e0d7..c4f760739bee682a97cc199addbc962e7046ccd4 100644 --- a/reading_machine/include/Config.hpp +++ b/reading_machine/include/Config.hpp @@ -5,6 +5,7 @@ #include <string> #include <vector> #include <boost/flyweight.hpp> +#include <boost/circular_buffer.hpp> #include "util.hpp" class Config @@ -24,6 +25,10 @@ class Config using ConstValueIterator = std::vector<String>::const_iterator; std::vector<String> lines; + std::size_t wordIndex{0}; + std::size_t characterIndex{0}; + String state{"NONE"}; + boost::circular_buffer<String> history{10}; protected : @@ -39,13 +44,9 @@ class Config std::size_t getNbLines() const; void addLines(unsigned int nbLines); void resizeLines(unsigned int nbLines); - String & get(const std::string & colName, int lineIndex, int hypothesisIndex); String & get(int colIndex, int lineIndex, int hypothesisIndex); - const String & getConst(const std::string & colName, int lineIndex, int hypothesisIndex) const; const String & getConst(int colIndex, int lineIndex, int hypothesisIndex) const; - String & getLastNotEmpty(const std::string & colName, int lineIndex); String & getLastNotEmpty(int colIndex, int lineIndex); - const String & getLastNotEmptyConst(const std::string & colName, int lineIndex) const; const String & getLastNotEmptyConst(int colIndex, int lineIndex) const; ValueIterator getIterator(int colIndex, int lineIndex, int hypothesisIndex); ConstValueIterator getConstIterator(int colIndex, int lineIndex, int hypothesisIndex) const; @@ -54,6 +55,11 @@ class Config virtual ~Config() {} void print(FILE * dest) const; + String & get(const std::string & colName, int lineIndex, int hypothesisIndex); + const String & getConst(const std::string & colName, int lineIndex, int hypothesisIndex) const; + String & getLastNotEmpty(const std::string & colName, int lineIndex); + const String & getLastNotEmptyConst(const std::string & colName, int lineIndex) const; + void addToHistory(const String & transition); }; #endif diff --git a/reading_machine/include/SubConfig.hpp b/reading_machine/include/SubConfig.hpp index 5a6db8e4eebac5b864ca83948bfde3d5e70787d0..18fd0d31d9a6ede7144c399f55dbc60f48d9461b 100644 --- a/reading_machine/include/SubConfig.hpp +++ b/reading_machine/include/SubConfig.hpp @@ -13,7 +13,7 @@ class SubConfig : public Config private : const BaseConfig & model; - int firstLineIndex; + int firstLineIndex{0}; private : diff --git a/reading_machine/src/Config.cpp b/reading_machine/src/Config.cpp index 839cca9139c9f21775341e830916baf5a6575411..a1b88982fefce7a2d1899d2b879fc3a58e3170d7 100644 --- a/reading_machine/src/Config.cpp +++ b/reading_machine/src/Config.cpp @@ -100,3 +100,8 @@ Config::ConstValueIterator Config::getConstIterator(int colIndex, int lineIndex, return lines.begin() + getIndexOfLine(lineIndex-getFirstLineIndex()) + getIndexOfCol(colIndex) + hypothesisIndex; } +void Config::addToHistory(const Config::String & transition) +{ + history.push_back(transition); +} + diff --git a/reading_machine/src/SubConfig.cpp b/reading_machine/src/SubConfig.cpp index af9c3af22e48bf96faa6f3be142d06479a9c10f6..c93d145ab51c906252e6fd83b908fdbeebed4425 100644 --- a/reading_machine/src/SubConfig.cpp +++ b/reading_machine/src/SubConfig.cpp @@ -2,7 +2,6 @@ SubConfig::SubConfig(BaseConfig & model) : model(model) { - firstLineIndex = 0; update(); }