From 73a00e352849702c0d7fbc2506f1b383b567e25f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Sun, 10 Dec 2023 07:20:40 +0100 Subject: [PATCH] fix prevSize = 0 --- cpp/Context.cpp | 7 ++++++- cpp/TextProdChar.cpp | 2 ++ include/Context.hpp | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cpp/Context.cpp b/cpp/Context.cpp index 96c4f94..e85d7ac 100644 --- a/cpp/Context.cpp +++ b/cpp/Context.cpp @@ -9,10 +9,15 @@ using namespace std; // ======================================== -const int Context::prevSize (10); +const int Context::prevSize (16); const string Context::end (".?!"); const string Context::sep (" ,;’-"); +int +Context::getPrevSize () { + return prevSize; +} + bool Context::validChar (const char &c) { if (isalpha (c)) diff --git a/cpp/TextProdChar.cpp b/cpp/TextProdChar.cpp index 894aade..dd8560f 100644 --- a/cpp/TextProdChar.cpp +++ b/cpp/TextProdChar.cpp @@ -76,6 +76,8 @@ TextProdChar::prod (ostream &out, const long &size) { if (maj) boost::to_upper (next); out << next; + if (end && ! Context::getPrevSize ()) + break; if (context.isEnd (next) || (nl && context.isSep (next))) { out << endl; diff --git a/include/Context.hpp b/include/Context.hpp index 905e3d5..7bf4c70 100644 --- a/include/Context.hpp +++ b/include/Context.hpp @@ -20,6 +20,7 @@ class Context { static const string end; static const string sep; public: + static int getPrevSize (); static bool validChar (const char &c); static bool isEnd (const string &c); static bool isSep (const string &c);