mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-16 06:50:32 +03:00
clean up states after API change
This commit is contained in:
parent
0c3fea4014
commit
563552aea6
@ -22,33 +22,6 @@ BleuScoreState::BleuScoreState(): m_words(1),
|
||||
{
|
||||
}
|
||||
|
||||
int BleuScoreState::Compare(const FFState& o) const
|
||||
{
|
||||
if (&o == this)
|
||||
return 0;
|
||||
|
||||
if (StaticData::Instance().IsSyntax())
|
||||
return 0;
|
||||
|
||||
const BleuScoreState& other = dynamic_cast<const BleuScoreState&>(o);
|
||||
int c = m_words.Compare(other.m_words);
|
||||
if (c != 0)
|
||||
return c;
|
||||
|
||||
/*for(size_t i = 0; i < m_ngram_counts.size(); i++) {
|
||||
if (m_ngram_counts[i] < other.m_ngram_counts[i])
|
||||
return -1;
|
||||
if (m_ngram_counts[i] > other.m_ngram_counts[i])
|
||||
return 1;
|
||||
if (m_ngram_matches[i] < other.m_ngram_matches[i])
|
||||
return -1;
|
||||
if (m_ngram_matches[i] > other.m_ngram_matches[i])
|
||||
return 1;
|
||||
}*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t BleuScoreState::hash() const
|
||||
{
|
||||
if (StaticData::Instance().IsSyntax())
|
||||
|
@ -25,7 +25,6 @@ public:
|
||||
static size_t bleu_order;
|
||||
|
||||
BleuScoreState();
|
||||
virtual int Compare(const FFState& other) const;
|
||||
size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -22,13 +22,6 @@ ConstrainedDecodingState::ConstrainedDecodingState(const ChartHypothesis &hypo)
|
||||
hypo.GetOutputPhrase(m_outputPhrase);
|
||||
}
|
||||
|
||||
int ConstrainedDecodingState::Compare(const FFState& other) const
|
||||
{
|
||||
const ConstrainedDecodingState &otherFF = static_cast<const ConstrainedDecodingState&>(other);
|
||||
int ret = m_outputPhrase.Compare(otherFF.m_outputPhrase);
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t ConstrainedDecodingState::hash() const
|
||||
{
|
||||
size_t ret = hash_value(m_outputPhrase);
|
||||
|
@ -17,7 +17,6 @@ public:
|
||||
ConstrainedDecodingState(const Hypothesis &hypo);
|
||||
ConstrainedDecodingState(const ChartHypothesis &hypo);
|
||||
|
||||
int Compare(const FFState& other) const;
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -33,21 +33,6 @@ ControlRecombinationState::ControlRecombinationState(const ChartHypothesis &hypo
|
||||
}
|
||||
}
|
||||
|
||||
int ControlRecombinationState::Compare(const FFState& other) const
|
||||
{
|
||||
const ControlRecombinationState &otherFF = static_cast<const ControlRecombinationState&>(other);
|
||||
|
||||
if (m_ff.GetType() == SameOutput) {
|
||||
int ret = m_outputPhrase.Compare(otherFF.m_outputPhrase);
|
||||
return ret;
|
||||
} else {
|
||||
// compare hypo address. Won't be equal unless they're actually the same hypo
|
||||
if (m_hypo == otherFF.m_hypo)
|
||||
return 0;
|
||||
return (m_hypo < otherFF.m_hypo) ? -1 : +1;
|
||||
}
|
||||
}
|
||||
|
||||
size_t ControlRecombinationState::hash() const
|
||||
{
|
||||
size_t ret;
|
||||
|
@ -26,7 +26,6 @@ public:
|
||||
ControlRecombinationState(const Hypothesis &hypo, const ControlRecombination &ff);
|
||||
ControlRecombinationState(const ChartHypothesis &hypo, const ControlRecombination &ff);
|
||||
|
||||
int Compare(const FFState& other) const;
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -19,29 +19,6 @@ using namespace std;
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
int CoveredReferenceState::Compare(const FFState& other) const
|
||||
{
|
||||
const CoveredReferenceState &otherState = static_cast<const CoveredReferenceState&>(other);
|
||||
|
||||
if (m_coveredRef.size() != otherState.m_coveredRef.size()) {
|
||||
return (m_coveredRef.size() < otherState.m_coveredRef.size()) ? -1 : +1;
|
||||
} else {
|
||||
multiset<string>::const_iterator thisIt, otherIt;
|
||||
for (thisIt = m_coveredRef.begin(), otherIt = otherState.m_coveredRef.begin();
|
||||
thisIt != m_coveredRef.end();
|
||||
thisIt++, otherIt++) {
|
||||
if (*thisIt != *otherIt) return thisIt->compare(*otherIt);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
// return m_coveredRef == otherState.m_coveredRef;
|
||||
|
||||
// if (m_coveredRef == otherState.m_coveredRef)
|
||||
// return 0;
|
||||
// return (m_coveredRef.size() < otherState.m_coveredRef.size()) ? -1 : +1;
|
||||
}
|
||||
|
||||
size_t CoveredReferenceState::hash() const
|
||||
{
|
||||
UTIL_THROW2("TODO:Haven't figure this out yet");
|
||||
|
@ -19,7 +19,6 @@ class CoveredReferenceState : public FFState
|
||||
public:
|
||||
std::multiset<std::string> m_coveredRef;
|
||||
|
||||
int Compare(const FFState& other) const;
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -13,13 +13,6 @@ struct DistortionState_traditional : public FFState {
|
||||
WordsRange range;
|
||||
int first_gap;
|
||||
DistortionState_traditional(const WordsRange& wr, int fg) : range(wr), first_gap(fg) {}
|
||||
int Compare(const FFState& other) const {
|
||||
const DistortionState_traditional& o =
|
||||
static_cast<const DistortionState_traditional&>(other);
|
||||
if (range.GetEndPos() < o.range.GetEndPos()) return -1;
|
||||
if (range.GetEndPos() > o.range.GetEndPos()) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t hash() const {
|
||||
return range.GetEndPos();
|
||||
|
@ -12,7 +12,6 @@ class FFState
|
||||
{
|
||||
public:
|
||||
virtual ~FFState();
|
||||
//virtual int Compare(const FFState& other) const = 0;
|
||||
virtual size_t hash() const = 0;
|
||||
virtual bool operator==(const FFState& other) const = 0;
|
||||
|
||||
@ -25,9 +24,6 @@ class DummyState : public FFState
|
||||
{
|
||||
public:
|
||||
DummyState() {}
|
||||
int Compare(const FFState& other) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual size_t hash() const {
|
||||
return 0;
|
||||
|
@ -141,10 +141,6 @@ public:
|
||||
return m_tree;
|
||||
}
|
||||
|
||||
int Compare(const FFState& other) const {
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual size_t hash() const {
|
||||
return 0;
|
||||
}
|
||||
|
@ -312,25 +312,6 @@ PhraseBasedReorderingState(const LRModel &config,
|
||||
{ }
|
||||
|
||||
|
||||
int
|
||||
PhraseBasedReorderingState::
|
||||
Compare(const FFState& o) const
|
||||
{
|
||||
if (&o == this) return 0;
|
||||
|
||||
const PhraseBasedReorderingState* other = static_cast<const PhraseBasedReorderingState*>(&o);
|
||||
if (m_prevRange == other->m_prevRange) {
|
||||
if (m_direction == LRModel::Forward) {
|
||||
return ComparePrevScores(other->m_prevOption);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (m_prevRange < other->m_prevRange) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
size_t PhraseBasedReorderingState::hash() const
|
||||
{
|
||||
size_t ret;
|
||||
@ -378,21 +359,6 @@ Expand(const TranslationOption& topt, const InputType& input,
|
||||
///////////////////////////
|
||||
//BidirectionalReorderingState
|
||||
|
||||
int
|
||||
BidirectionalReorderingState::
|
||||
Compare(FFState const& o) const
|
||||
{
|
||||
/*
|
||||
if (&o == this) return 0;
|
||||
|
||||
BidirectionalReorderingState const &other
|
||||
= static_cast<BidirectionalReorderingState const&>(o);
|
||||
|
||||
int cmp = m_backward->Compare(*other.m_backward);
|
||||
return (cmp < 0) ? -1 : cmp ? 1 : m_forward->Compare(*other.m_forward);
|
||||
*/
|
||||
}
|
||||
|
||||
size_t BidirectionalReorderingState::hash() const
|
||||
{
|
||||
size_t ret = m_backward->hash();
|
||||
@ -436,16 +402,6 @@ HReorderingBackwardState(const LRModel &config, size_t offset)
|
||||
: LRState(config, LRModel::Backward, offset)
|
||||
{ }
|
||||
|
||||
|
||||
int
|
||||
HReorderingBackwardState::
|
||||
Compare(const FFState& o) const
|
||||
{
|
||||
const HReorderingBackwardState& other
|
||||
= static_cast<const HReorderingBackwardState&>(o);
|
||||
return m_reoStack.Compare(other.m_reoStack);
|
||||
}
|
||||
|
||||
size_t HReorderingBackwardState::hash() const
|
||||
{
|
||||
size_t ret = m_reoStack.hash();
|
||||
@ -497,20 +453,6 @@ HReorderingForwardState(const HReorderingForwardState *prev,
|
||||
m_coverage.SetValue(topt.GetSourceWordsRange(), true);
|
||||
}
|
||||
|
||||
int
|
||||
HReorderingForwardState::
|
||||
Compare(const FFState& o) const
|
||||
{
|
||||
if (&o == this) return 0;
|
||||
|
||||
HReorderingForwardState const& other
|
||||
= static_cast<HReorderingForwardState const&>(o);
|
||||
|
||||
return ((m_prevRange == other.m_prevRange)
|
||||
? ComparePrevScores(other.m_prevOption)
|
||||
: (m_prevRange < other.m_prevRange) ? -1 : 1);
|
||||
}
|
||||
|
||||
size_t HReorderingForwardState::hash() const
|
||||
{
|
||||
size_t ret;
|
||||
|
@ -218,10 +218,6 @@ public:
|
||||
delete m_forward;
|
||||
}
|
||||
|
||||
virtual
|
||||
int
|
||||
Compare(const FFState& o) const;
|
||||
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
@ -247,10 +243,6 @@ public:
|
||||
PhraseBasedReorderingState(const PhraseBasedReorderingState *prev,
|
||||
const TranslationOption &topt);
|
||||
|
||||
virtual
|
||||
int
|
||||
Compare(const FFState& o) const;
|
||||
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
@ -277,9 +269,6 @@ public:
|
||||
HReorderingBackwardState(const HReorderingBackwardState *prev,
|
||||
const TranslationOption &topt,
|
||||
ReorderingStack reoStack);
|
||||
|
||||
virtual int Compare(const FFState& o) const;
|
||||
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
@ -308,8 +297,6 @@ public:
|
||||
HReorderingForwardState(const HReorderingForwardState *prev,
|
||||
const TranslationOption &topt);
|
||||
|
||||
virtual int Compare(const FFState& o) const;
|
||||
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -22,23 +22,6 @@ void osmState::saveState(int jVal, int eVal, map <int , string> & gapVal)
|
||||
E = eVal;
|
||||
}
|
||||
|
||||
int osmState::Compare(const FFState& otherBase) const
|
||||
{
|
||||
const osmState &other = static_cast<const osmState&>(otherBase);
|
||||
if (j != other.j)
|
||||
return (j < other.j) ? -1 : +1;
|
||||
if (E != other.E)
|
||||
return (E < other.E) ? -1 : +1;
|
||||
if (gap != other.gap)
|
||||
return (gap < other.gap) ? -1 : +1;
|
||||
|
||||
if (lmState.length < other.lmState.length) return -1;
|
||||
|
||||
if (lmState.length > other.lmState.length) return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t osmState::hash() const
|
||||
{
|
||||
size_t ret = j;
|
||||
|
@ -16,7 +16,6 @@ class osmState : public FFState
|
||||
{
|
||||
public:
|
||||
osmState(const lm::ngram::State & val);
|
||||
int Compare(const FFState& other) const;
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -9,14 +9,6 @@ using namespace std;
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
int PhraseBoundaryState::Compare(const FFState& other) const
|
||||
{
|
||||
const PhraseBoundaryState& rhs = dynamic_cast<const PhraseBoundaryState&>(other);
|
||||
int tgt = Word::Compare(*m_targetWord,*(rhs.m_targetWord));
|
||||
if (tgt) return tgt;
|
||||
return Word::Compare(*m_sourceWord,*(rhs.m_sourceWord));
|
||||
}
|
||||
|
||||
size_t PhraseBoundaryState::hash() const
|
||||
{
|
||||
size_t ret = hash_value(*m_targetWord);
|
||||
|
@ -23,7 +23,6 @@ public:
|
||||
const Word* GetTargetWord() const {
|
||||
return m_targetWord;
|
||||
}
|
||||
virtual int Compare(const FFState& other) const;
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -99,47 +99,6 @@ public:
|
||||
return m_rightBoundaryNonTerminalR2LScores[2];
|
||||
}
|
||||
|
||||
|
||||
int Compare(const FFState& other) const {
|
||||
if (!m_distinguishStates) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const PhraseOrientationFeatureState &otherState = static_cast<const PhraseOrientationFeatureState&>(other);
|
||||
|
||||
if (!m_leftBoundaryIsSet && !otherState.m_leftBoundaryIsSet &&
|
||||
!m_rightBoundaryIsSet && !otherState.m_rightBoundaryIsSet) {
|
||||
return 0;
|
||||
}
|
||||
if (m_leftBoundaryIsSet && !otherState.m_leftBoundaryIsSet) {
|
||||
return 1;
|
||||
}
|
||||
if (!m_leftBoundaryIsSet && otherState.m_leftBoundaryIsSet) {
|
||||
return -1;
|
||||
}
|
||||
if (m_rightBoundaryIsSet && !otherState.m_rightBoundaryIsSet) {
|
||||
return 1;
|
||||
}
|
||||
if (!m_rightBoundaryIsSet && otherState.m_rightBoundaryIsSet) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (m_leftBoundaryIsSet) {
|
||||
int compareLeft = CompareLeftBoundaryRecursive(*this, otherState, m_useSparseNT);
|
||||
if (compareLeft != 0) {
|
||||
return compareLeft;
|
||||
}
|
||||
}
|
||||
if (m_rightBoundaryIsSet) {
|
||||
int compareRight = CompareRightBoundaryRecursive(*this, otherState, m_useSparseNT);
|
||||
if (compareRight != 0) {
|
||||
return compareRight;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -7,14 +7,6 @@ using namespace std;
|
||||
|
||||
namespace Moses
|
||||
{
|
||||
int SkeletonState::Compare(const FFState& other) const
|
||||
{
|
||||
const SkeletonState &otherState = static_cast<const SkeletonState&>(other);
|
||||
|
||||
if (m_targetLen == otherState.m_targetLen)
|
||||
return 0;
|
||||
return (m_targetLen < otherState.m_targetLen) ? -1 : +1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
SkeletonStatefulFF::SkeletonStatefulFF(const std::string &line)
|
||||
|
@ -15,8 +15,6 @@ public:
|
||||
:m_targetLen(targetLen) {
|
||||
}
|
||||
|
||||
int Compare(const FFState& other) const;
|
||||
|
||||
virtual size_t hash() const {
|
||||
return (size_t) m_targetLen;
|
||||
}
|
||||
|
@ -11,12 +11,6 @@ using namespace std;
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
int TargetBigramState::Compare(const FFState& other) const
|
||||
{
|
||||
const TargetBigramState& rhs = dynamic_cast<const TargetBigramState&>(other);
|
||||
return Word::Compare(m_word,rhs.m_word);
|
||||
}
|
||||
|
||||
size_t TargetBigramState::hash() const
|
||||
{
|
||||
std::size_t ret = hash_value(m_word);
|
||||
|
@ -20,7 +20,6 @@ public:
|
||||
const Word& GetWord() const {
|
||||
return m_word;
|
||||
}
|
||||
virtual int Compare(const FFState& other) const;
|
||||
size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -12,31 +12,6 @@ namespace Moses
|
||||
|
||||
using namespace std;
|
||||
|
||||
int TargetNgramState::Compare(const FFState& other) const
|
||||
{
|
||||
const TargetNgramState& rhs = dynamic_cast<const TargetNgramState&>(other);
|
||||
int result;
|
||||
if (m_words.size() == rhs.m_words.size()) {
|
||||
for (size_t i = 0; i < m_words.size(); ++i) {
|
||||
result = Word::Compare(m_words[i],rhs.m_words[i]);
|
||||
if (result != 0) return result;
|
||||
}
|
||||
return 0;
|
||||
} else if (m_words.size() < rhs.m_words.size()) {
|
||||
for (size_t i = 0; i < m_words.size(); ++i) {
|
||||
result = Word::Compare(m_words[i],rhs.m_words[i]);
|
||||
if (result != 0) return result;
|
||||
}
|
||||
return -1;
|
||||
} else {
|
||||
for (size_t i = 0; i < rhs.m_words.size(); ++i) {
|
||||
result = Word::Compare(m_words[i],rhs.m_words[i]);
|
||||
if (result != 0) return result;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
size_t TargetNgramState::hash() const
|
||||
{
|
||||
std::size_t ret = boost::hash_range(m_words.begin(), m_words.end());
|
||||
|
@ -25,7 +25,6 @@ public:
|
||||
const std::vector<Word> GetWords() const {
|
||||
return m_words;
|
||||
}
|
||||
virtual int Compare(const FFState& other) const;
|
||||
|
||||
size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
@ -158,25 +157,6 @@ public:
|
||||
return m_contextSuffix;
|
||||
}
|
||||
|
||||
int Compare(const FFState& o) const {
|
||||
const TargetNgramChartState &other =
|
||||
static_cast<const TargetNgramChartState &>( o );
|
||||
|
||||
// prefix
|
||||
if (m_startPos > 0) { // not for "<s> ..."
|
||||
int ret = GetPrefix().Compare(other.GetPrefix());
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (m_endPos < m_inputSize - 1) { // not for "... </s>"
|
||||
int ret = GetSuffix().Compare(other.GetSuffix());
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t hash() const {
|
||||
// not sure if this is correct
|
||||
size_t ret;
|
||||
|
@ -25,12 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
int BackwardLMState::Compare(const FFState &o) const
|
||||
{
|
||||
const BackwardLMState &other = static_cast<const BackwardLMState &>(o);
|
||||
return state.left.Compare(other.state.left);
|
||||
}
|
||||
|
||||
size_t BackwardLMState::hash() const
|
||||
{
|
||||
size_t ret = hash_value(state.left);
|
||||
|
@ -47,8 +47,6 @@ class BackwardLMState : public FFState
|
||||
|
||||
public:
|
||||
|
||||
int Compare(const FFState &o) const;
|
||||
|
||||
size_t hash() const;
|
||||
virtual bool operator==(const FFState& other) const;
|
||||
|
||||
|
@ -7,15 +7,6 @@ using namespace std;
|
||||
namespace Moses
|
||||
{
|
||||
|
||||
int BilingualLMState::Compare(const FFState& other) const
|
||||
{
|
||||
const BilingualLMState &otherState = static_cast<const BilingualLMState&>(other);
|
||||
|
||||
if (m_hash == otherState.m_hash)
|
||||
return 0;
|
||||
return (m_hash < otherState.m_hash) ? -1 : +1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
BilingualLM::BilingualLM(const std::string &line)
|
||||
: StatefulFeatureFunction(1, line),
|
||||
|
@ -37,8 +37,6 @@ public:
|
||||
return neuralLM_ids;
|
||||
}
|
||||
|
||||
int Compare(const FFState& other) const;
|
||||
|
||||
virtual size_t hash() const {
|
||||
return m_hash;
|
||||
}
|
||||
|
@ -145,29 +145,6 @@ public:
|
||||
return m_contextSuffix;
|
||||
}
|
||||
|
||||
int Compare(const FFState& o) const {
|
||||
/*
|
||||
const LanguageModelChartState &other =
|
||||
dynamic_cast<const LanguageModelChartState &>( o );
|
||||
|
||||
// prefix
|
||||
if (m_hypo.GetCurrSourceRange().GetStartPos() > 0) { // not for "<s> ..."
|
||||
int ret = GetPrefix().Compare(other.GetPrefix());
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
|
||||
// suffix
|
||||
size_t inputSize = m_hypo.GetManager().GetSource().GetSize();
|
||||
if (m_hypo.GetCurrSourceRange().GetEndPos() < inputSize - 1) { // not for "... </s>"
|
||||
int ret = other.GetRightContext()->Compare(*m_lmRightContext);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
size_t hash() const {
|
||||
size_t ret;
|
||||
|
||||
|
@ -55,13 +55,6 @@ namespace
|
||||
|
||||
struct KenLMState : public FFState {
|
||||
lm::ngram::State state;
|
||||
int Compare(const FFState &o) const {
|
||||
const KenLMState &other = static_cast<const KenLMState &>(o);
|
||||
if (state.length < other.state.length) return -1;
|
||||
if (state.length > other.state.length) return 1;
|
||||
return std::memcmp(state.words, other.state.words, sizeof(lm::WordIndex) * state.length);
|
||||
}
|
||||
|
||||
virtual size_t hash() const {
|
||||
size_t ret = hash_value(state);
|
||||
return ret;
|
||||
@ -312,12 +305,6 @@ public:
|
||||
return m_state;
|
||||
}
|
||||
|
||||
int Compare(const FFState& o) const {
|
||||
const LanguageModelChartStateKenLM &other = static_cast<const LanguageModelChartStateKenLM&>(o);
|
||||
int ret = m_state.Compare(other.m_state);
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t hash() const {
|
||||
size_t ret = hash_value(m_state);
|
||||
return ret;
|
||||
|
@ -10,13 +10,6 @@ struct PointerState : public FFState {
|
||||
PointerState(const void* lms) {
|
||||
lmstate = lms;
|
||||
}
|
||||
int Compare(const FFState& o) const {
|
||||
const PointerState& other = static_cast<const PointerState&>(o);
|
||||
if (other.lmstate > lmstate) return 1;
|
||||
else if (other.lmstate < lmstate) return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual size_t hash() const {
|
||||
return (size_t) lmstate;
|
||||
}
|
||||
|
@ -253,6 +253,25 @@ int Phrase::Compare(const Phrase &other) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Phrase::operator== (const Phrase &other) const {
|
||||
size_t thisSize = GetSize()
|
||||
,compareSize = other.GetSize();
|
||||
if (thisSize != compareSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t pos = 0 ; pos < thisSize ; pos++) {
|
||||
const Word &thisWord = GetWord(pos)
|
||||
,&otherWord = other.GetWord(pos);
|
||||
bool ret = thisWord == otherWord;
|
||||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Phrase::Contains(const vector< vector<string> > &subPhraseVector
|
||||
, const vector<FactorType> &inputFactor) const
|
||||
|
@ -192,8 +192,10 @@ public:
|
||||
return Compare(compare) < 0;
|
||||
}
|
||||
|
||||
bool operator== (const Phrase &compare) const {
|
||||
return Compare(compare) == 0;
|
||||
bool operator==(const Phrase &compare) const;
|
||||
bool operator!=(const Phrase &compare) const
|
||||
{
|
||||
return ! (*this == compare);
|
||||
}
|
||||
|
||||
void OnlyTheseFactors(const FactorMask &factors);
|
||||
|
@ -63,7 +63,22 @@ int Word::Compare(const Word &targetWord, const Word &sourceWord)
|
||||
return (targetFactor<sourceFactor) ? -1 : +1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool Word::operator==(const Word &compare) const {
|
||||
if (IsNonTerminal() != compare.IsNonTerminal()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (size_t factorType = 0 ; factorType < MAX_NUM_FACTORS ; factorType++) {
|
||||
const Factor *thisFactor = GetFactor(factorType);
|
||||
const Factor *otherFactor = compare.GetFactor(factorType);
|
||||
|
||||
if (thisFactor != otherFactor) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void Word::Merge(const Word &sourceWord)
|
||||
|
@ -124,15 +124,10 @@ public:
|
||||
return Compare(*this, compare) < 0;
|
||||
}
|
||||
|
||||
inline bool operator== (const Word &compare) const {
|
||||
// needed to store word in GenerationDictionary map
|
||||
// uses comparison of FactorKey
|
||||
// 'proper' comparison, not address/id comparison
|
||||
return Compare(*this, compare) == 0;
|
||||
}
|
||||
bool operator== (const Word &compare) const;
|
||||
|
||||
inline bool operator!= (const Word &compare) const {
|
||||
return Compare(*this, compare) != 0;
|
||||
return !(*this == compare);
|
||||
}
|
||||
|
||||
int Compare(const Word &other) const {
|
||||
|
Loading…
Reference in New Issue
Block a user