From f341bb3ab41b754bdd20c0b0a884d17e93b746af Mon Sep 17 00:00:00 2001 From: Taku Kudo Date: Sun, 10 May 2020 00:51:03 +0900 Subject: Fixed windows build failure --- src/bpe_model_test.cc | 10 ++++++---- src/unigram_model_test.cc | 9 +++++---- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/bpe_model_test.cc b/src/bpe_model_test.cc index ac12436..ccd0066 100644 --- a/src/bpe_model_test.cc +++ b/src/bpe_model_test.cc @@ -12,10 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License.! +#include "bpe_model.h" + #include #include -#include "bpe_model.h" #include "model_interface.h" #include "testharness.h" @@ -276,12 +277,13 @@ TEST(SampleModelTest, EncodeTest) { }; const Model model(model_proto); - const std::vector kAlpha = {0.0, 0.1, 0.5, 0.7, 0.9}; - for (const float alpha : kAlpha) { + const std::vector kAlpha = {0.0, 0.1, 0.5, 0.7, 0.9}; + for (const auto alpha : kAlpha) { constexpr int kTrial = 100000; std::map freq; for (int n = 0; n < kTrial; ++n) - freq[get_tokens(model.SampleEncode("abcd", alpha))]++; + freq[get_tokens( + model.SampleEncode("abcd", static_cast(alpha)))]++; int num = 0; if (alpha == 0.0) EXPECT_EQ(1, freq.size()); diff --git a/src/unigram_model_test.cc b/src/unigram_model_test.cc index 384a5d4..d6375e7 100644 --- a/src/unigram_model_test.cc +++ b/src/unigram_model_test.cc @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License.! +#include "unigram_model.h" + #include #include #include @@ -22,7 +24,6 @@ #include "testharness.h" #include "third_party/absl/strings/str_cat.h" #include "third_party/absl/strings/str_join.h" -#include "unigram_model.h" #include "util.h" namespace sentencepiece { @@ -282,9 +283,9 @@ TEST(LatticeTest, SampleTest) { InsertWithScoreAndId(&lattice, 1, 2, 1.7, 4); // BC InsertWithScoreAndId(&lattice, 0, 3, 1.8, 5); // ABC - const std::vector kTheta = {0.0, 0.01, 0.5, 0.7, 1.0}; + const std::vector kTheta = {0.0, 0.01, 0.5, 0.7, 1.0}; for (int i = 0; i < kTheta.size(); ++i) { - std::map probs; + std::map probs; // Expands all paths in the lattice. probs["A B C"] = exp(kTheta[i] * (1.0 + 1.2 + 1.5)); // A B C probs["AB C"] = exp(kTheta[i] * (1.6 + 1.5)); // AB C @@ -292,7 +293,7 @@ TEST(LatticeTest, SampleTest) { probs["ABC"] = exp(kTheta[i] * 1.8); // ABC // Computes expected probabilities. - float Z = 0.0; + double Z = 0.0; for (const auto &it : probs) Z += it.second; for (auto &it : probs) it.second /= Z; -- cgit v1.2.3