Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/moses-smt/mosesdecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
phikoehn committed Sep 4, 2016
2 parents 6e5da8c + aa20f04 commit 382cbf1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion contrib/moses2/System.cpp
Expand Up @@ -48,7 +48,7 @@ System::System(const Parameter &paramsArg) :
if (params.GetParam("show-weights")) {
cerr << "Showing weights then exit" << endl;
featureFunctions.ShowWeights(weights);
return;
//return;
}

cerr << "START featureFunctions.Load()" << endl;
Expand Down
13 changes: 9 additions & 4 deletions moses/LM/NeuralLMWrapper.cpp
Expand Up @@ -54,16 +54,21 @@ LMResult NeuralLMWrapper::GetValue(const vector<const Word*> &contextFactor, Sta
//TODO: config option?
m_neuralLM->set_cache(1000000);
}
size_t hashCode = 0;


vector<int> words(contextFactor.size());
for (size_t i=0, n=contextFactor.size(); i<n; i++) {
const size_t n = contextFactor.size();
for (size_t i=0; i<n; i++) {
const Word* word = contextFactor[i];
const Factor* factor = word->GetFactor(m_factorType);
const std::string string = factor->GetString().as_string();
int neuralLM_wordID = m_neuralLM->lookup_word(string);
words[i] = neuralLM_wordID;
boost::hash_combine(hashCode, neuralLM_wordID);
}
// Generate hashCode for only the last n-1 words, that represents the next LM
// state
size_t hashCode = 0;
for (size_t i=1; i<n; ++i) {
boost::hash_combine(hashCode, words[i]);
}

double value = m_neuralLM->lookup_ngram(words);
Expand Down
4 changes: 2 additions & 2 deletions scripts/training/train-model.perl
Expand Up @@ -1680,7 +1680,7 @@ sub score_phrase_phrase_extract {

# distinguish between score and consolidation options
my $ONLY_DIRECT = (defined($_SCORE_OPTIONS) && $_SCORE_OPTIONS =~ /OnlyDirect/);
my $PHRASE_COUNT = (!defined($_SCORE_OPTIONS) || $_SCORE_OPTIONS !~ /NoPhraseCount/);
my $PHRASE_COUNT = (defined($_SCORE_OPTIONS) && $_SCORE_OPTIONS =~ /PhraseCount/);
my $LOW_COUNT = (defined($_SCORE_OPTIONS) && $_SCORE_OPTIONS =~ /LowCountFeature/);
my ($SPARSE_COUNT_BIN,$COUNT_BIN,$DOMAIN) = ("","","");
$SPARSE_COUNT_BIN = $1 if defined($_SCORE_OPTIONS) && $_SCORE_OPTIONS =~ /SparseCountBinFeature ([\s\d]*\d)/;
Expand Down Expand Up @@ -1814,7 +1814,7 @@ sub score_phrase_phrase_extract {
$cmd .= " --LogProb" if $LOG_PROB;
$cmd .= " --NegLogProb" if $NEG_LOG_PROB;
$cmd .= " --OnlyDirect" if $ONLY_DIRECT;
$cmd .= " --NoPhraseCount" unless $PHRASE_COUNT;
$cmd .= " --PhraseCount" if $PHRASE_COUNT;
$cmd .= " --LowCountFeature" if $LOW_COUNT;
$cmd .= " --CountBinFeature $COUNT_BIN" if $COUNT_BIN;
$cmd .= " --SparseCountBinFeature $SPARSE_COUNT_BIN" if $SPARSE_COUNT_BIN;
Expand Down

0 comments on commit 382cbf1

Please sign in to comment.