Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/marian-nmt/sentencepiece.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTaku Kudo <taku@google.com>2020-05-09 18:51:03 +0300
committerTaku Kudo <taku@google.com>2020-05-09 18:51:03 +0300
commitf341bb3ab41b754bdd20c0b0a884d17e93b746af (patch)
treec5cdda0f8455b6bb1977dd93dbe38cba281784ba /src
parente66fd4a63c08e916e9bafae7cda137e3ba2911d3 (diff)
Fixed windows build failure
Diffstat (limited to 'src')
-rw-r--r--src/bpe_model_test.cc10
-rw-r--r--src/unigram_model_test.cc9
2 files changed, 11 insertions, 8 deletions
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 <cstdio>
#include <string>
-#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<float> kAlpha = {0.0, 0.1, 0.5, 0.7, 0.9};
- for (const float alpha : kAlpha) {
+ const std::vector<double> kAlpha = {0.0, 0.1, 0.5, 0.7, 0.9};
+ for (const auto alpha : kAlpha) {
constexpr int kTrial = 100000;
std::map<std::string, int> freq;
for (int n = 0; n < kTrial; ++n)
- freq[get_tokens(model.SampleEncode("abcd", alpha))]++;
+ freq[get_tokens(
+ model.SampleEncode("abcd", static_cast<float>(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 <cmath>
#include <map>
#include <string>
@@ -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<float> kTheta = {0.0, 0.01, 0.5, 0.7, 1.0};
+ const std::vector<double> kTheta = {0.0, 0.01, 0.5, 0.7, 1.0};
for (int i = 0; i < kTheta.size(); ++i) {
- std::map<std::string, float> probs;
+ std::map<std::string, double> 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;