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

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2017-02-15 13:05:58 +0300
committerHieu Hoang <hieuhoang@gmail.com>2017-02-15 13:05:58 +0300
commit75a736964819fc77a72ac360d7ae5a46f76bbaf5 (patch)
treec9514d0eb044a59667b16b00839823d0ddff0f0c /moses2/TranslationModel
parent3b65dc39a7f54e2aeef487031a733d8a26486ce5 (diff)
apply patch for windows compatibility
Diffstat (limited to 'moses2/TranslationModel')
-rw-r--r--moses2/TranslationModel/CompactPT/MmapAllocator.h7
-rw-r--r--moses2/TranslationModel/CompactPT/MurmurHash3.h7
-rw-r--r--moses2/TranslationModel/ProbingPT/ProbingPT.cpp6
-rw-r--r--moses2/TranslationModel/ProbingPT/probing_hash_utils.hh4
-rw-r--r--moses2/TranslationModel/ProbingPT/storing.cpp4
5 files changed, 21 insertions, 7 deletions
diff --git a/moses2/TranslationModel/CompactPT/MmapAllocator.h b/moses2/TranslationModel/CompactPT/MmapAllocator.h
index c92166da6..c2923cad5 100644
--- a/moses2/TranslationModel/CompactPT/MmapAllocator.h
+++ b/moses2/TranslationModel/CompactPT/MmapAllocator.h
@@ -25,13 +25,14 @@
#include <limits>
#include <iostream>
#include <cstdio>
-#include <unistd.h>
#if defined(_WIN32) || defined(_WIN64)
+#define _WINSOCKAPI_
#include <windows.h>
#include <io.h>
#else
#include <sys/mman.h>
+#include <unistd.h>
#endif
#include "util/mmap.hh"
@@ -129,7 +130,11 @@ public:
#endif
if (!m_fixed) {
size_t read = 0;
+#ifdef _WIN32
+ read += _chsize_s(m_file_desc, m_map_size);
+#else
read += ftruncate(m_file_desc, m_map_size);
+#endif
m_data_ptr = (char *) util::MapOrThrow(m_map_size, true, map_shared,
false, m_file_desc, 0);
return (pointer) m_data_ptr;
diff --git a/moses2/TranslationModel/CompactPT/MurmurHash3.h b/moses2/TranslationModel/CompactPT/MurmurHash3.h
index f513008cf..ef885a6d4 100644
--- a/moses2/TranslationModel/CompactPT/MurmurHash3.h
+++ b/moses2/TranslationModel/CompactPT/MurmurHash3.h
@@ -12,9 +12,10 @@
#if defined(_MSC_VER)
-typedef unsigned char uint8_t;
-typedef unsigned long uint32_t;
-typedef unsigned __int64 uint64_t;
+#include <stdint.h>
+//typedef unsigned char uint8_t;
+//typedef unsigned long uint32_t;
+//typedef unsigned __int64 uint64_t;
// Other compilers
diff --git a/moses2/TranslationModel/ProbingPT/ProbingPT.cpp b/moses2/TranslationModel/ProbingPT/ProbingPT.cpp
index d405bf026..86231842d 100644
--- a/moses2/TranslationModel/ProbingPT/ProbingPT.cpp
+++ b/moses2/TranslationModel/ProbingPT/ProbingPT.cpp
@@ -240,7 +240,7 @@ std::pair<bool, uint64_t> ProbingPT::GetKey(const Phrase<Moses2::Word> &sourcePh
size_t sourceSize = sourcePhrase.GetSize();
assert(sourceSize);
- uint64_t probingSource[sourceSize];
+ uint64_t *probingSource = new uint64_t[sourceSize];
GetSourceProbingIds(sourcePhrase, ret.first, probingSource);
if (!ret.first) {
// source phrase contains a word unknown in the pt.
@@ -317,7 +317,7 @@ TargetPhraseImpl *ProbingPT::CreateTargetPhrase(
}
} else {
// log score 1st
- SCORE logScores[totalNumScores];
+ SCORE *logScores = new SCORE[totalNumScores];
for (size_t i = 0; i < totalNumScores; ++i) {
logScores[i] = FloorScore(TransformScore(scores[i]));
}
@@ -622,7 +622,7 @@ SCFG::TargetPhraseImpl *ProbingPT::CreateTargetPhraseSCFG(
}
} else {
// log score 1st
- SCORE logScores[totalNumScores];
+ SCORE *logScores = new SCORE[totalNumScores];
for (size_t i = 0; i < totalNumScores; ++i) {
logScores[i] = FloorScore(TransformScore(scores[i]));
}
diff --git a/moses2/TranslationModel/ProbingPT/probing_hash_utils.hh b/moses2/TranslationModel/ProbingPT/probing_hash_utils.hh
index 7e275510a..fa5a9a5a0 100644
--- a/moses2/TranslationModel/ProbingPT/probing_hash_utils.hh
+++ b/moses2/TranslationModel/ProbingPT/probing_hash_utils.hh
@@ -2,7 +2,11 @@
#include "util/probing_hash_table.hh"
+#if defined(_WIN32) || defined(_WIN64)
+#include <mman.h>
+#else
#include <sys/mman.h>
+#endif
#include <boost/functional/hash.hpp>
#include <fcntl.h>
#include <fstream>
diff --git a/moses2/TranslationModel/ProbingPT/storing.cpp b/moses2/TranslationModel/ProbingPT/storing.cpp
index c27e99634..862aab3e8 100644
--- a/moses2/TranslationModel/ProbingPT/storing.cpp
+++ b/moses2/TranslationModel/ProbingPT/storing.cpp
@@ -67,6 +67,9 @@ void createProbingPT(const std::string &phrasetable_path,
const std::string &basepath, int num_scores, int num_lex_scores,
bool log_prob, int max_cache_size, bool scfg)
{
+#if defined(_WIN32) || defined(_WIN64)
+ std::cerr << "Create not implemented for Windows" << std::endl;
+#else
std::cerr << "Starting..." << std::endl;
//Get basepath and create directory if missing
@@ -231,6 +234,7 @@ void createProbingPT(const std::string &phrasetable_path,
configfile << "num_lex_scores\t" << num_lex_scores << '\n';
configfile << "log_prob\t" << log_prob << '\n';
configfile.close();
+#endif
}
size_t countUniqueSource(const std::string &path)