00001 #pragma once
00002
00003 #include <istream>
00004 #include <string>
00005 #include <vector>
00006
00007 #include <boost/unordered_map.hpp>
00008
00009 #include "Vocabulary.h"
00010
00011 namespace MosesTraining
00012 {
00013 namespace Syntax
00014 {
00015 namespace ScoreStsg
00016 {
00017
00018 class LexicalTable
00019 {
00020 public:
00021 LexicalTable(Vocabulary &, Vocabulary &);
00022
00023 void Load(std::istream &);
00024
00025 double PermissiveLookup(Vocabulary::IdType s, Vocabulary::IdType t) {
00026 OuterMap::const_iterator p = m_table.find(s);
00027 if (p == m_table.end()) {
00028 return 1.0;
00029 }
00030 const InnerMap &inner = p->second;
00031 InnerMap::const_iterator q = inner.find(t);
00032 return q == inner.end() ? 1.0 : q->second;
00033 }
00034
00035 private:
00036 typedef boost::unordered_map<Vocabulary::IdType, double> InnerMap;
00037 typedef boost::unordered_map<Vocabulary::IdType, InnerMap> OuterMap;
00038
00039 Vocabulary &m_srcVocab;
00040 Vocabulary &m_tgtVocab;
00041 OuterMap m_table;
00042 };
00043
00044 }
00045 }
00046 }