00001 00002 #pragma once 00003 00004 #include <string> 00005 #include <set> 00006 #include <map> 00007 #include <vector> 00008 #include "moses/PP/PhraseProperty.h" 00009 00010 namespace Moses 00011 { 00012 00013 class SpanLengthPhraseProperty : public PhraseProperty 00014 { 00015 public: 00016 SpanLengthPhraseProperty(); 00017 00018 void ProcessValue(const std::string &value); 00019 00020 float GetProb(size_t ntInd, size_t sourceWidth, float smoothing) const; 00021 protected: 00022 // fractional counts 00023 typedef std::map<size_t, float> Map; 00024 typedef std::vector<std::pair<Map, float> > Vec; 00025 Vec m_source, m_target; 00026 00027 void Populate(const std::set< std::vector<std::string> > &indices, float count); 00028 void Populate(const std::vector<size_t> &toks, float count); 00029 void Populate(Map &map, size_t span, float count); 00030 00031 void CalcTotals(Vec &vec); 00032 }; 00033 00034 } // namespace Moses 00035