On 2015-02-05 17:25, Hieu Hoang wrote:
> great, thanks. committed
>
> https://github.com/moses-smt/mosesdecoder/commit/70e8eb54ce75feb0a7d4ed00d275e56652c0a914
> I ran the regression tests before I commit, it's more extensive
That was fast - thanks! I'll make it a habit to run the regression tests.
I did find a spot that I missed:
LexicalReorderingTableCompact::CheckAndLoad().
That function's contract looks a little confused, by the way. It
handles both the case where the given file name ends in ".minlexr" and
the case where that suffix still needs to be added. But the only call
site always adds that suffix first, so as far as I can tell CheckAndLoad
ends up looking for "x.minlexr.minlexr" before it tries "x.minlexr".
I *think* the attached patch would iron out that wrinkle, but I'm having
some trouble actually exercising the code. Maybe it's not worth it just
now. :/
Jeroen
diff --git a/moses/TranslationModel/CompactPT/LexicalReorderingTableCompact.cpp b/moses/TranslationModel/CompactPT/LexicalReorderingTableCompact.cpp
index ad7591a..e0e281e 100644
--- a/moses/TranslationModel/CompactPT/LexicalReorderingTableCompact.cpp
+++ b/moses/TranslationModel/CompactPT/LexicalReorderingTableCompact.cpp
@@ -19,6 +19,8 @@ License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
***********************************************************************/
+#include <cassert>
+#include <boost/algorithm/string/predicate.hpp>
#include "LexicalReorderingTableCompact.h"
namespace Moses
@@ -125,17 +127,9 @@ LexicalReorderingTable* LexicalReorderingTableCompact::CheckAndLoad(
const std::vector<FactorType>& e_factors,
const std::vector<FactorType>& c_factors)
{
+ assert(boost::algorithm::ends_with(filePath, ".minlexr"));
#ifdef HAVE_CMPH
- std::string minlexr = ".minlexr";
- // file name is specified without suffix
- if(FileExists(filePath + minlexr)) {
- //there exists a compact binary version use that
- VERBOSE(2,"Using compact lexical reordering table" << std::endl);
- return new LexicalReorderingTableCompact(filePath + minlexr, f_factors, e_factors, c_factors);
- }
- // file name is specified with suffix
- if(filePath.substr(filePath.length() - minlexr.length(), minlexr.length()) == minlexr
- && FileExists(filePath)) {
+ if(FileExists(filePath)) {
//there exists a compact binary version use that
VERBOSE(2,"Using compact lexical reordering table" << std::endl);
return new LexicalReorderingTableCompact(filePath, f_factors, e_factors, c_factors);
_______________________________________________
Moses-support mailing list
[email protected]
http://mailman.mit.edu/mailman/listinfo/moses-support