mosesdecoder/moses/PP/SourceLabelsPhraseProperty.h

75 lines
1.7 KiB
C
Raw Permalink Normal View History

2014-06-12 00:08:22 +04:00
#pragma once
#include "moses/PP/PhraseProperty.h"
#include "util/exception.hh"
2014-06-12 00:08:22 +04:00
#include <string>
#include <list>
namespace Moses
{
2015-01-14 14:07:42 +03:00
// Note that we require label tokens (strings) in the corresponding property values of phrase table entries
2014-06-12 00:08:22 +04:00
// to be replaced beforehand by indices (size_t) of a label vocabulary. (TODO: change that?)
class SourceLabelsPhrasePropertyItem
{
2015-01-14 14:07:42 +03:00
friend class SourceLabelsPhraseProperty;
2014-06-12 00:08:22 +04:00
public:
SourceLabelsPhrasePropertyItem() {};
2015-01-14 14:07:42 +03:00
float GetSourceLabelsRHSCount() const {
2014-06-12 00:08:22 +04:00
return m_sourceLabelsRHSCount;
};
2015-01-14 14:07:42 +03:00
const std::list<size_t> &GetSourceLabelsRHS() const {
2014-06-12 00:08:22 +04:00
return m_sourceLabelsRHS;
};
2015-01-14 14:07:42 +03:00
const std::list< std::pair<size_t,float> > &GetSourceLabelsLHSList() const {
2014-06-12 00:08:22 +04:00
return m_sourceLabelsLHSList;
};
private:
float m_sourceLabelsRHSCount;
std::list<size_t> m_sourceLabelsRHS; // should be of size nNTs-1 (empty if initial rule, i.e. no right-hand side non-terminals)
std::list< std::pair<size_t,float> > m_sourceLabelsLHSList; // list of left-hand sides for this right-hand side, with counts
};
class SourceLabelsPhraseProperty : public PhraseProperty
{
public:
SourceLabelsPhraseProperty() {};
2014-06-12 00:08:22 +04:00
virtual void ProcessValue(const std::string &value);
2014-06-12 00:08:22 +04:00
size_t GetNumberOfNonTerminals() const {
return m_nNTs;
}
float GetTotalCount() const {
return m_totalCount;
}
const std::list<SourceLabelsPhrasePropertyItem> &GetSourceLabelItems() const {
return m_sourceLabelItems;
};
2015-01-14 14:07:42 +03:00
virtual const std::string *GetValueString() const {
UTIL_THROW2("SourceLabelsPhraseProperty: value string not available in this phrase property");
2015-01-14 14:07:42 +03:00
return NULL;
};
2014-06-12 00:08:22 +04:00
protected:
size_t m_nNTs;
float m_totalCount;
std::list<SourceLabelsPhrasePropertyItem> m_sourceLabelItems;
};
} // namespace Moses