From acc4e4d14d7bb818ba5c9596d7feb320ffa80fa4 Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 28 Dec 2023 15:09:55 +0100 Subject: [PATCH] Fixed crash. --- mlpp/data/data.cpp | 6 ++++-- mlpp/data/data_old.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/mlpp/data/data.cpp b/mlpp/data/data.cpp index 2ccac6e..efc330e 100644 --- a/mlpp/data/data.cpp +++ b/mlpp/data/data.cpp @@ -1086,10 +1086,12 @@ MLPPData::WordsToVecResult MLPPData::word_to_vec(std::vector senten for (uint32_t i = 0; i < segmented_sentences.size(); i++) { for (uint32_t j = 0; j < segmented_sentences[i].size(); j++) { for (int k = windowSize; k > 0; k--) { - if (j - k >= 0) { + int jmk = (int)j - k; + + if (jmk >= 0) { inputStrings.push_back(segmented_sentences[i][j]); - outputStrings.push_back(segmented_sentences[i][j - k]); + outputStrings.push_back(segmented_sentences[i][jmk]); } if (j + k <= segmented_sentences[i].size() - 1) { inputStrings.push_back(segmented_sentences[i][j]); diff --git a/mlpp/data/data_old.cpp b/mlpp/data/data_old.cpp index 2fec574..488fc13 100644 --- a/mlpp/data/data_old.cpp +++ b/mlpp/data/data_old.cpp @@ -597,10 +597,12 @@ std::tuple>, std::vector> MLPPDataO for (uint32_t i = 0; i < segmented_sentences.size(); i++) { for (uint32_t j = 0; j < segmented_sentences[i].size(); j++) { for (int k = windowSize; k > 0; k--) { - if (j - k >= 0) { + int jmk = (int)j - k; + + if (jmk >= 0) { inputStrings.push_back(segmented_sentences[i][j]); - outputStrings.push_back(segmented_sentences[i][j - k]); + outputStrings.push_back(segmented_sentences[i][jmk]); } if (j + k <= segmented_sentences[i].size() - 1) { inputStrings.push_back(segmented_sentences[i][j]);