From 95e50962fe307b930e835513e4d9998df91426a4 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Wed, 16 Mar 2011 20:30:37 -0400 Subject: possible mert bug with rules with alignments --- decoder/trule.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'decoder/trule.cc') diff --git a/decoder/trule.cc b/decoder/trule.cc index 9820e6d5..fda62741 100644 --- a/decoder/trule.cc +++ b/decoder/trule.cc @@ -145,7 +145,9 @@ bool TRule::ReadFromString(const string& line, bool strict, bool mono) { getline(is, ss); //cerr << "L: " << ss << endl; int start = 0; - const int len = ss.size(); + int len = ss.size(); + const size_t ppos = ss.find(" |||"); + if (ppos != string::npos) { len = ppos; } while (start < len) { while(start < len && (ss[start] == ' ' || ss[start] == ';')) ++start; -- cgit v1.2.3 From 918ed4bf919a55e3eb5d99d98c9b915921dc11ab Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Wed, 23 Mar 2011 22:53:44 -0400 Subject: remove thread-local stuff which was fragile on some build systems --- decoder/trule.cc | 3 +-- utils/static_utoa.h | 2 +- utils/tdict.cc | 1 - utils/threadlocal.h | 71 ----------------------------------------------------- 4 files changed, 2 insertions(+), 75 deletions(-) delete mode 100755 utils/threadlocal.h (limited to 'decoder/trule.cc') diff --git a/decoder/trule.cc b/decoder/trule.cc index fda62741..40235542 100644 --- a/decoder/trule.cc +++ b/decoder/trule.cc @@ -5,7 +5,6 @@ #include "stringlib.h" #include "tdict.h" #include "rule_lexer.h" -#include "threadlocal.h" using namespace std; @@ -99,7 +98,7 @@ TRule* TRule::CreateRuleMonolingual(const string& rule) { namespace { // callback for lexer -THREADLOCAL int n_assigned=0; +int n_assigned=0; void assign_trule(const TRulePtr& new_rule, const unsigned int ctf_level, const TRulePtr& coarse_rule, void* extra) { TRule *assignto=(TRule *)extra; *assignto=*new_rule; diff --git a/utils/static_utoa.h b/utils/static_utoa.h index d15ed35b..bb3d821f 100755 --- a/utils/static_utoa.h +++ b/utils/static_utoa.h @@ -7,7 +7,7 @@ namespace { static const int utoa_bufsize=40; // 64bit safe. static const int utoa_bufsizem1=utoa_bufsize-1; // 64bit safe. -THREADLOCAL char utoa_buf[utoa_bufsize]; // to put end of string character at buf[20] +static char utoa_buf[utoa_bufsize]; // to put end of string character at buf[20] } inline char *static_utoa(unsigned n) { diff --git a/utils/tdict.cc b/utils/tdict.cc index 23a298f8..c21b2b48 100644 --- a/utils/tdict.cc +++ b/utils/tdict.cc @@ -8,7 +8,6 @@ #include "dict.h" #include "tdict.h" #include "stringlib.h" -#include "threadlocal.h" using namespace std; diff --git a/utils/threadlocal.h b/utils/threadlocal.h deleted file mode 100755 index d79f5d9d..00000000 --- a/utils/threadlocal.h +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef THREADLOCAL_H -#define THREADLOCAL_H - -#ifndef SETLOCAL_SWAP -# define SETLOCAL_SWAP 0 -#endif - -#ifdef BOOST_NO_MT - -# define THREADLOCAL - -#else - -#ifdef _MSC_VER - -//FIXME: doesn't work with DLLs ... use TLS apis instead (http://www.boost.org/libs/thread/doc/tss.html) -# define THREADLOCAL __declspec(thread) - -#else - -# define THREADLOCAL __thread - -#endif - -#endif - -#include //swap - -// naturally, the below are only thread-safe if value is THREADLOCAL -template -struct SaveLocal { - D &value; - D old_value; - SaveLocal(D& val) : value(val), old_value(val) {} - ~SaveLocal() { -#if SETLOCAL_SWAP - swap(value,old_value); -#else - value=old_value; -#endif - } -}; - -template -struct SetLocal { - D &value; - D old_value; - SetLocal(D& val,const D &new_value) : value(val), old_value( -#if SETLOCAL_SWAP - new_value -#else - val -#endif - ) { -#if SETLOCAL_SWAP - swap(value,old_value); -#else - value=new_value; -#endif - } - ~SetLocal() { -#if SETLOCAL_SWAP - swap(value,old_value); -#else - value=old_value; -#endif - } -}; - - -#endif -- cgit v1.2.3