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:
authorHieu Hoang <hieu@hoang.co.uk>2014-06-06 15:19:28 +0400
committerHieu Hoang <hieu@hoang.co.uk>2014-06-06 15:19:28 +0400
commit8c648197734bfd8e7a3b564230d035da96716317 (patch)
tree643ef988c7f8f9b5e898a814192b213ccab9c665 /OnDiskPt
parent5032fc1d33dbbbd9af7fc9848e45ee38a171a4d7 (diff)
properties in OnDiskPt
Diffstat (limited to 'OnDiskPt')
-rw-r--r--OnDiskPt/Main.cpp29
-rw-r--r--OnDiskPt/TargetPhrase.h5
2 files changed, 16 insertions, 18 deletions
diff --git a/OnDiskPt/Main.cpp b/OnDiskPt/Main.cpp
index f2d75ed05..fdfc561be 100644
--- a/OnDiskPt/Main.cpp
+++ b/OnDiskPt/Main.cpp
@@ -109,6 +109,8 @@ bool Flush(const OnDiskPt::SourcePhrase *prevSourcePhrase, const OnDiskPt::Sourc
OnDiskPt::PhrasePtr Tokenize(SourcePhrase &sourcePhrase, TargetPhrase &targetPhrase, char *line, OnDiskWrapper &onDiskWrapper, int numScores, vector<float> &misc)
{
+ stringstream property;
+
size_t scoreInd = 0;
// MAIN LOOP
@@ -118,6 +120,7 @@ OnDiskPt::PhrasePtr Tokenize(SourcePhrase &sourcePhrase, TargetPhrase &targetPhr
2 = scores
3 = align
4 = count
+ 7 = properties
*/
char *tok = strtok (line," ");
OnDiskPt::PhrasePtr out(new Phrase());
@@ -148,29 +151,18 @@ OnDiskPt::PhrasePtr Tokenize(SourcePhrase &sourcePhrase, TargetPhrase &targetPhr
targetPhrase.CreateAlignFromString(tok);
break;
}
- case 4:
- ++stage;
+ case 4: {
break;
- /* case 5: {
- // count info. Only store the 2nd one
- float val = Moses::Scan<float>(tok);
- misc[0] = val;
- ++stage;
- break;
- }*/
+ }
case 5: {
- // count info. Only store the 2nd one
- //float val = Moses::Scan<float>(tok);
- //misc[0] = val;
- ++stage;
+ // store only the 3rd one (rule count)
+ float val = Moses::Scan<float>(tok);
+ misc[0] = val;
break;
}
case 6: {
- // store only the 3rd one (rule count)
- float val = Moses::Scan<float>(tok);
- misc[0] = val;
- ++stage;
- break;
+ property << tok << " ";
+ break;
}
default:
cerr << "ERROR in line " << line << endl;
@@ -183,6 +175,7 @@ OnDiskPt::PhrasePtr Tokenize(SourcePhrase &sourcePhrase, TargetPhrase &targetPhr
} // while (tok != NULL)
assert(scoreInd == numScores);
+ targetPhrase.SetProperty(Moses::Trim(property.str()));
targetPhrase.SortAlign();
return out;
} // Tokenize()
diff --git a/OnDiskPt/TargetPhrase.h b/OnDiskPt/TargetPhrase.h
index 5b8a30296..283e7815e 100644
--- a/OnDiskPt/TargetPhrase.h
+++ b/OnDiskPt/TargetPhrase.h
@@ -50,6 +50,7 @@ class TargetPhrase: public Phrase
protected:
AlignType m_align;
PhrasePtr m_sourcePhrase;
+ std::string m_property;
std::vector<float> m_scores;
UINT64 m_filePos;
@@ -110,6 +111,10 @@ public:
virtual void DebugPrint(std::ostream &out, const Vocab &vocab) const;
+ void SetProperty(const std::string prop)
+ {
+ m_property = prop;
+ }
};
}