mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-26 05:14:36 +03:00
Make Phrase::CreateFromString() more efficient
This commit is contained in:
parent
369e3411f9
commit
bce3b36170
@ -156,7 +156,7 @@ void Phrase::CreateFromString(FactorDirection direction
|
||||
,const std::vector<FactorType> &factorOrder
|
||||
,const StringPiece &phraseString
|
||||
,const StringPiece &factorDelimiter
|
||||
,Word *lhs)
|
||||
,Word **lhs)
|
||||
{
|
||||
// parse
|
||||
vector<StringPiece> annotatedWordVector;
|
||||
@ -181,8 +181,8 @@ void Phrase::CreateFromString(FactorDirection direction
|
||||
|
||||
// lhs
|
||||
CHECK(lhs);
|
||||
lhs->CreateFromString(direction, factorOrder, annotatedWord.substr(1, annotatedWord.size() - 2), true);
|
||||
assert(lhs->IsNonTerminal());
|
||||
(*lhs)->CreateFromString(direction, factorOrder, annotatedWord.substr(1, annotatedWord.size() - 2), true);
|
||||
assert((*lhs)->IsNonTerminal());
|
||||
}
|
||||
else {
|
||||
//CHECK(lhs == NULL);
|
||||
|
@ -75,7 +75,7 @@ public:
|
||||
, const std::vector<FactorType> &factorOrder
|
||||
, const StringPiece &phraseString
|
||||
, const StringPiece &factorDelimiter
|
||||
, Word *lhs);
|
||||
, Word **lhs);
|
||||
|
||||
/** copy factors from the other phrase to this phrase.
|
||||
IsCompatible() must be run beforehand to ensure incompatible factors aren't overwritten
|
||||
|
@ -220,12 +220,12 @@ bool RuleTableLoaderStandard::Load(FormatType format
|
||||
// parse source & find pt node
|
||||
|
||||
// constituent labels
|
||||
Word sourceLHS;
|
||||
Word *sourceLHS = new Word(true);
|
||||
Word *targetLHS = new Word(true);
|
||||
|
||||
// create target phrase obj
|
||||
TargetPhrase *targetPhrase = new TargetPhrase();
|
||||
targetPhrase->CreateFromString(Output, output, targetPhraseString, factorDelimiter, targetLHS);
|
||||
targetPhrase->CreateFromString(Output, output, targetPhraseString, factorDelimiter, &targetLHS);
|
||||
|
||||
// source
|
||||
targetPhrase->MutableSourcePhrase().CreateFromString(Input, input, sourcePhraseString, factorDelimiter, &sourceLHS);
|
||||
@ -244,7 +244,7 @@ bool RuleTableLoaderStandard::Load(FormatType format
|
||||
targetPhrase->GetScoreBreakdown().Assign(&ruleTable, scoreVector);
|
||||
targetPhrase->Evaluate();
|
||||
|
||||
TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(ruleTable, targetPhrase->GetSourcePhrase(), *targetPhrase, sourceLHS);
|
||||
TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(ruleTable, targetPhrase->GetSourcePhrase(), *targetPhrase, *sourceLHS);
|
||||
phraseColl.Add(targetPhrase);
|
||||
|
||||
count++;
|
||||
|
@ -217,7 +217,7 @@ namespace Moses
|
||||
// parse source & find pt node
|
||||
|
||||
// constituent labels
|
||||
Word sourceLHS;
|
||||
Word *sourceLHS = new Word(true);
|
||||
Word *targetLHS = new Word(true);
|
||||
|
||||
// source
|
||||
@ -226,7 +226,7 @@ namespace Moses
|
||||
|
||||
// create target phrase obj
|
||||
TargetPhrase *targetPhrase = new TargetPhrase();
|
||||
targetPhrase->CreateFromString(Output, *m_output, targetPhraseString, factorDelimiter, targetLHS);
|
||||
targetPhrase->CreateFromString(Output, *m_output, targetPhraseString, factorDelimiter, &targetLHS);
|
||||
|
||||
// rest of target phrase
|
||||
targetPhrase->SetAlignmentInfo(alignString);
|
||||
@ -240,7 +240,7 @@ namespace Moses
|
||||
targetPhrase->GetScoreBreakdown().Assign(this, scoreVector);
|
||||
targetPhrase->Evaluate();
|
||||
|
||||
TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(rootNode, sourcePhrase, *targetPhrase, sourceLHS);
|
||||
TargetPhraseCollection &phraseColl = GetOrCreateTargetPhraseCollection(rootNode, sourcePhrase, *targetPhrase, *sourceLHS);
|
||||
phraseColl.Add(targetPhrase);
|
||||
|
||||
count++;
|
||||
|
Loading…
Reference in New Issue
Block a user