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:
authorhieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230>2011-08-04 11:36:25 +0400
committerhieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230>2011-08-04 11:36:25 +0400
commitcdbb850cc3771770e3abbe378757659bae14962d (patch)
tree34c89cb65af0bc42d1ec4cdb6498becdf14df0e3 /scripts
parente7b97c1b1a42728f226ba39813efa497620fc91b (diff)
fix new scorer to output phrase pairs in same order as old scorer
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4110 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'scripts')
-rw-r--r--scripts/training/phrase-extract/score2.cpp29
-rw-r--r--scripts/training/phrase-extract/score2.h25
2 files changed, 47 insertions, 7 deletions
diff --git a/scripts/training/phrase-extract/score2.cpp b/scripts/training/phrase-extract/score2.cpp
index 5b70c0c58..d359859c0 100644
--- a/scripts/training/phrase-extract/score2.cpp
+++ b/scripts/training/phrase-extract/score2.cpp
@@ -311,10 +311,10 @@ void processPhrasePairs( vector< PhraseAlignment > &phrasePair, ostream &phraseT
// check for matches
//cerr << "phrasePairGroup.size() = " << phrasePairGroup.size() << endl;
- PhraseAlignmentCollection dummyColl;
- dummyColl.push_back(&currPhrasePair);
+ PhraseAlignmentCollection phraseAlignColl;
+ phraseAlignColl.push_back(&currPhrasePair);
pair<PhrasePairGroup::iterator, bool> retInsert;
- retInsert = phrasePairGroup.insert(dummyColl);
+ retInsert = phrasePairGroup.insert(phraseAlignColl);
if (!retInsert.second)
{ // already exist. Add to that collection instead
PhraseAlignmentCollection &existingColl = const_cast<PhraseAlignmentCollection&>(*retInsert.first);
@@ -323,10 +323,12 @@ void processPhrasePairs( vector< PhraseAlignment > &phrasePair, ostream &phraseT
}
- PhrasePairGroup::iterator iter;
- for(iter = phrasePairGroup.begin(); iter != phrasePairGroup.end(); ++iter)
+ const PhrasePairGroup::SortedColl &sortedColl = phrasePairGroup.GetSortedColl();
+ PhrasePairGroup::SortedColl::const_iterator iter;
+
+ for(iter = sortedColl.begin(); iter != sortedColl.end(); ++iter)
{
- const PhraseAlignmentCollection &group = *iter;
+ const PhraseAlignmentCollection &group = **iter;
outputPhrasePair( group, totalSource, phraseTableFile );
}
}
@@ -496,3 +498,18 @@ void LexicalTable::load( char *fileName )
cerr << endl;
}
+
+std::pair<PhrasePairGroup::Coll::iterator,bool> PhrasePairGroup::insert ( const PhraseAlignmentCollection& obj )
+{
+ std::pair<iterator,bool> ret = m_coll.insert(obj);
+
+ if (ret.second)
+ { // obj inserted. Also add to sorted vector
+ const PhraseAlignmentCollection &insertedObj = *ret.first;
+ m_sortedColl.push_back(&insertedObj);
+ }
+
+ return ret;
+}
+
+
diff --git a/scripts/training/phrase-extract/score2.h b/scripts/training/phrase-extract/score2.h
index 2d8f84c12..ea50d8cb7 100644
--- a/scripts/training/phrase-extract/score2.h
+++ b/scripts/training/phrase-extract/score2.h
@@ -32,8 +32,31 @@ public:
};
-typedef std::set<PhraseAlignmentCollection, PhraseAlignmentCollectionOrderer> PhrasePairGroup;
+//typedef std::set<PhraseAlignmentCollection, PhraseAlignmentCollectionOrderer> PhrasePairGroup;
+class PhrasePairGroup
+{
+private:
+ typedef std::set<PhraseAlignmentCollection, PhraseAlignmentCollectionOrderer> Coll;
+ Coll m_coll;
+
+
+public:
+ typedef Coll::iterator iterator;
+ typedef Coll::const_iterator const_iterator;
+ typedef std::vector<const PhraseAlignmentCollection *> SortedColl;
+
+ std::pair<Coll::iterator,bool> insert ( const PhraseAlignmentCollection& obj );
+
+ const SortedColl &GetSortedColl() const
+ { return m_sortedColl; }
+
+private:
+ SortedColl m_sortedColl;
+
+};
+
+// other functions *********************************************
inline bool isNonTerminal( std::string &word )
{
return (word.length()>=3 &&