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:
authorpjwilliams <pjwilliams@1f5c12ca-751b-0410-a591-d2e778427230>2011-02-28 14:41:08 +0300
committerpjwilliams <pjwilliams@1f5c12ca-751b-0410-a591-d2e778427230>2011-02-28 14:41:08 +0300
commit75709a6c878e7545e1b30636dec71bb9c648f8a3 (patch)
tree4b17fbdc501ef0b7a8354e45b09763dc4cc026bb /moses-cmd
parenta5a860ad1fc4c77f229b307fc4b728ca77ddbf26 (diff)
Memory efficiency: make the reserveSize argument non-optional in
Moses::Phrase's constructor. The default used to be ARRAY_SIZE_INCR = 10, which will be excessive in many cases. Where the default was used, I've set the exact size where that was obvious and explicitly used ARRAY_SIZE_INCR otherwise. If you know the code involved, it's probably worth reviewing. git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@3908 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses-cmd')
-rw-r--r--moses-cmd/src/LatticeMBR.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/moses-cmd/src/LatticeMBR.cpp b/moses-cmd/src/LatticeMBR.cpp
index cb7e3e1ca..24b9fd6d6 100644
--- a/moses-cmd/src/LatticeMBR.cpp
+++ b/moses-cmd/src/LatticeMBR.cpp
@@ -36,7 +36,7 @@ void extract_ngrams(const vector<Word >& sentence, map < Phrase, int > & allngr
{
for (int k = 0; k < (int)bleu_order; k++) {
for(int i =0; i < max((int)sentence.size()-k,0); i++) {
- Phrase ngram(Output);
+ Phrase ngram(Output, k+1);
for ( int j = i; j<= i+k; j++) {
ngram.AddWord(sentence[j]);
}
@@ -402,7 +402,7 @@ const NgramHistory& Edge::GetNgrams(map<const Hypothesis*, vector<Edge> > & inco
for (size_t start = 0; start < currPhrase.GetSize(); ++start) {
for (size_t end = start; end < start + bleu_order; ++end) {
if (end < currPhrase.GetSize()) {
- Phrase edgeNgram(Output);
+ Phrase edgeNgram(Output, end-start+1);
for (size_t index = start; index <= end; ++index) {
edgeNgram.AddWord(currPhrase.GetWord(index));
}
@@ -433,8 +433,8 @@ const NgramHistory& Edge::GetNgrams(map<const Hypothesis*, vector<Edge> > & inco
cerr << "edgeInNgram: " << edgeIncomingNgram << endl;
}
- Phrase edgeSuffix(Output);
- Phrase ngramSuffix(Output);
+ Phrase edgeSuffix(Output, ARRAY_SIZE_INCR);
+ Phrase ngramSuffix(Output, ARRAY_SIZE_INCR);
GetPhraseSuffix(edgeWords,back,edgeSuffix);
GetPhraseSuffix(edgeIncomingNgram,back,ngramSuffix);