diff options
author | hieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-11-06 18:01:30 +0300 |
---|---|---|
committer | hieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230> | 2006-11-06 18:01:30 +0300 |
commit | 2789059b80835b512451828ecea22e6b622f71c3 (patch) | |
tree | 46cb69e04a42bf5c06da64c0cdf53ceb1d11b702 /irstlm/src | |
parent | abefc351c55a23be9131d79fe11cba1b27f96ea9 (diff) |
added internal, x-platform LM which exactly mimics SRILM
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@953 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'irstlm/src')
-rw-r--r-- | irstlm/src/lmtable.cpp | 11 | ||||
-rw-r--r-- | irstlm/src/lmtable.h | 5 | ||||
-rw-r--r-- | irstlm/src/util.cpp | 7 |
3 files changed, 18 insertions, 5 deletions
diff --git a/irstlm/src/lmtable.cpp b/irstlm/src/lmtable.cpp index 2ebc5df31..0655fae63 100644 --- a/irstlm/src/lmtable.cpp +++ b/irstlm/src/lmtable.cpp @@ -17,8 +17,10 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ******************************************************************************/ +#ifndef WIN32 #include <sys/types.h> #include <sys/mman.h> +#endif #include <fcntl.h> #include <iostream> #include <fstream> @@ -72,7 +74,11 @@ lmtable::lmtable(){ //loadstd::istream& inp a lmtable from a lm file void lmtable::load(istream& inp,const char* filename,int keep_on_disk){ - + + #ifdef WIN32 + keep_on_disk = 0; + #endif + //give a look at the header to select loading method char header[1024]; inp >> header; cerr << header << "\n"; @@ -570,6 +576,7 @@ void lmtable::loadbin(istream& inp, const char* header,const char* filename,int dict->load(inp); //if MMAP is used, then open the file +#ifndef WIN32 if (filename and mmap>0){ if (mmap <= maxlev) @@ -590,7 +597,6 @@ void lmtable::loadbin(istream& inp, const char* header,const char* filename,int } - for (int l=1;l<=maxlev;l++){ if (isQtable) loadbincodebook(inp,l); if ((memmap == 0) or (l < memmap)){ @@ -608,6 +614,7 @@ void lmtable::loadbin(istream& inp, const char* header,const char* filename,int inp.seekg(cursize[l]*nodesize(tbltype[l]),ios_base::cur); } }; +#endif cerr << "done\n"; diff --git a/irstlm/src/lmtable.h b/irstlm/src/lmtable.h index df91a96c1..13bb49ad6 100644 --- a/irstlm/src/lmtable.h +++ b/irstlm/src/lmtable.h @@ -22,8 +22,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #ifndef MF_LMTABLE_H #define MF_LMTABLE_H +#ifndef WIN32 #include <sys/types.h> #include <sys/mman.h> +#endif + #include "util.h" #include "ngramcache.h" #include "dictionary.h" @@ -183,6 +186,7 @@ public: void reset_mmap(){ +#ifndef WIN32 if (memmap>0 and memmap<=maxlev) for (int l=memmap;l<=maxlev;l++){ std::cerr << "resetting mmap at level:" << l << "\n"; @@ -192,6 +196,7 @@ public: &tableGaps[l]); table[l]+=tableGaps[l]; } +#endif } bool is_probcache_active(){return probcache!=NULL;} diff --git a/irstlm/src/util.cpp b/irstlm/src/util.cpp index 42dd19f1c..cdebef571 100644 --- a/irstlm/src/util.cpp +++ b/irstlm/src/util.cpp @@ -1,10 +1,11 @@ #ifdef WIN32 #include <windows.h> -#endif - +#include <io.h> +#else #include <sys/types.h> #include <sys/mman.h> +#endif #include "util.h" @@ -101,7 +102,7 @@ void *MMap(int fd, int access, off_t offset, size_t len, off_t *gap) HANDLE fh, mh; - fh = (HANDLE)_get_osfhandle(fd) + fh = (HANDLE)_get_osfhandle(fd); if(offset) { /* bisogna accertarsi che l'offset abbia la granularita` * corretta, MAI PROVATA! */ |