mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-28 14:32:38 +03:00
create class for all consistent phrases. So they can be searched
This commit is contained in:
parent
cf59d6ea85
commit
64b82b2a0b
@ -146,7 +146,8 @@ void AlignedSentence::CreateConsistentPhrases(const Parameter ¶ms)
|
||||
continue;
|
||||
|
||||
// take note that this is a valid phrase alignment
|
||||
m_consistentPhrases.push_back(ConsistentPhrase(startS, endS, startT, endT, "[X]", "[X]"));
|
||||
ConsistentPhrase phrasePair(startS, endS, startT, endT, "[X]", "[X]");
|
||||
m_consistentPhrases.Add(phrasePair);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
#include "Word.h"
|
||||
#include "SyntaxTree.h"
|
||||
#include "ConsistentPhrase.h"
|
||||
#include "ConsistentPhrases.h"
|
||||
#include "moses/TypeDef.h"
|
||||
|
||||
typedef std::vector<Word*> Phrase;
|
||||
@ -29,14 +28,14 @@ public:
|
||||
const Phrase &GetPhrase(Moses::FactorDirection direction) const
|
||||
{ return (direction == Moses::Input) ? m_source : m_target; }
|
||||
|
||||
const std::vector<ConsistentPhrase> &GetConsistentPhrases() const
|
||||
const ConsistentPhrases &GetConsistentPhrases() const
|
||||
{ return m_consistentPhrases; }
|
||||
|
||||
protected:
|
||||
Phrase m_source, m_target;
|
||||
SyntaxTree sourceTree, targetTree;
|
||||
|
||||
std::vector<ConsistentPhrase> m_consistentPhrases;
|
||||
ConsistentPhrases m_consistentPhrases;
|
||||
|
||||
void PopulateWordVec(std::vector<Word*> &vec, const std::string &line);
|
||||
void PopulateAlignment(const std::string &line);
|
||||
|
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* ConsistentPhrases.cpp
|
||||
*
|
||||
* Created on: 18 Feb 2014
|
||||
* Author: s0565741
|
||||
*/
|
||||
|
||||
#include "ConsistentPhrases.h"
|
||||
|
||||
ConsistentPhrases::ConsistentPhrases() {
|
||||
// TODO Auto-generated constructor stub
|
||||
|
||||
}
|
||||
|
||||
ConsistentPhrases::~ConsistentPhrases() {
|
||||
// TODO Auto-generated destructor stub
|
||||
}
|
||||
|
||||
void ConsistentPhrases::Add(ConsistentPhrase &phrasePair)
|
||||
{
|
||||
m_coll.push_back(phrasePair);
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* ConsistentPhrases.h
|
||||
*
|
||||
* Created on: 18 Feb 2014
|
||||
* Author: s0565741
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "ConsistentPhrase.h"
|
||||
|
||||
class ConsistentPhrases {
|
||||
|
||||
typedef std::vector<ConsistentPhrase> Coll;
|
||||
|
||||
public:
|
||||
typedef Coll::iterator iterator;
|
||||
typedef Coll::const_iterator const_iterator;
|
||||
//! iterators
|
||||
const_iterator begin() const {
|
||||
return m_coll.begin();
|
||||
}
|
||||
const_iterator end() const {
|
||||
return m_coll.end();
|
||||
}
|
||||
|
||||
ConsistentPhrases();
|
||||
virtual ~ConsistentPhrases();
|
||||
|
||||
void Add(ConsistentPhrase &phrasePair);
|
||||
|
||||
protected:
|
||||
Coll m_coll;
|
||||
|
||||
};
|
||||
|
@ -23,9 +23,10 @@ Lattice::Lattice(const AlignedSentence &alignedSentence)
|
||||
}
|
||||
|
||||
// add non-terms
|
||||
const std::vector<ConsistentPhrase> &consistentPhrases = alignedSentence.GetConsistentPhrases();
|
||||
for (size_t i = 0; i < consistentPhrases.size(); ++i) {
|
||||
const ConsistentPhrase &consistentPhrase = consistentPhrases[i];
|
||||
const ConsistentPhrases &consistentPhrases = alignedSentence.GetConsistentPhrases();
|
||||
ConsistentPhrases::const_iterator iter;
|
||||
for (iter = consistentPhrases.begin(); iter != consistentPhrases.end(); ++iter) {
|
||||
const ConsistentPhrase &consistentPhrase = *iter;
|
||||
const ConsistentRange &nonTerm = consistentPhrase.GetConsistentRange(Moses::Input);
|
||||
|
||||
int start = nonTerm.GetStart();
|
||||
|
Loading…
Reference in New Issue
Block a user