From abb7128422d475a2d05a7b4c710c60fa5ec1a179 Mon Sep 17 00:00:00 2001 From: Franck Dary <franck.dary@lis-lab.fr> Date: Sun, 15 Dec 2019 21:12:52 +0100 Subject: [PATCH] Added some members to Config --- reading_machine/include/Config.hpp | 14 ++++++++++---- reading_machine/include/SubConfig.hpp | 2 +- reading_machine/src/Config.cpp | 5 +++++ reading_machine/src/SubConfig.cpp | 1 - 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/reading_machine/include/Config.hpp b/reading_machine/include/Config.hpp index 1819615..c4f7607 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 5a6db8e..18fd0d3 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 839cca9..a1b8898 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 af9c3af..c93d145 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(); } -- GitLab