00001
00002
00003 #ifndef moses_PhraseDictionaryTree_h
00004 #define moses_PhraseDictionaryTree_h
00005
00006 #include <string>
00007 #include <vector>
00008 #include <iostream>
00009
00010 #ifdef WITH_THREADS
00011 #include <boost/thread/mutex.hpp>
00012 #endif
00013
00014 #include "TypeDef.h"
00015 #include "Dictionary.h"
00016
00017
00018 #include "PrefixTree.h"
00019 #include "File.h"
00020 #include "ObjectPool.h"
00021 #include "LexicalReorderingTable.h"
00022 #include "LVoc.h"
00023 #include "TypeDef.h"
00024 #include "Util.h"
00025
00026 namespace Moses
00027 {
00028
00029 class Phrase;
00030 class Word;
00031 class ConfusionNet;
00032 class PDTimp;
00033
00034 typedef PrefixTreeF<LabelId,OFF_T> PTF;
00035
00036 class PhraseDictionaryTree : public Dictionary
00037 {
00038 PDTimp *imp;
00039
00040 PhraseDictionaryTree();
00041 PhraseDictionaryTree(const PhraseDictionaryTree&);
00042 void operator=(const PhraseDictionaryTree&);
00043 public:
00044 PhraseDictionaryTree(size_t numScoreComponent);
00045
00046 void UseWordAlignment(bool a);
00047 bool UseWordAlignment();
00048
00049 void PrintWordAlignment(bool a);
00050 bool PrintWordAlignment();
00051
00052
00053 virtual ~PhraseDictionaryTree();
00054
00055 DecodeType GetDecodeType() const {
00056 return Translate;
00057 }
00058 size_t GetSize() const {
00059 return 0;
00060 }
00061
00062
00063
00064
00065 int Create(std::istream& in,const std::string& outFileNamePrefix);
00066
00067 int Read(const std::string& fileNamePrefix);
00068
00069
00070 void FreeMemory() const;
00071
00072
00073
00074
00075
00076
00077 void PrintTargetCandidates(const std::vector<std::string>& src,
00078 std::ostream& out) const;
00079
00080
00081 void GetTargetCandidates(const std::vector<std::string>& src,
00082 std::vector<StringTgtCand>& rv) const;
00083
00084
00085 void GetTargetCandidates(const std::vector<std::string>& src,
00086 std::vector<StringTgtCand>& rv,
00087 std::vector<std::string>& wa) const;
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 class PrefixPtr
00099 {
00100 PPimp* imp;
00101 friend class PDTimp;
00102 public:
00103 PrefixPtr(PPimp* x=0) : imp(x) {}
00104 operator bool() const;
00105 };
00106
00107
00108 PrefixPtr GetRoot() const;
00109
00110
00111
00112 PrefixPtr Extend(PrefixPtr p,const std::string& s) const;
00113
00114
00115
00116 void GetTargetCandidates(PrefixPtr p,
00117 std::vector<StringTgtCand>& rv) const;
00118 void GetTargetCandidates(PrefixPtr p,
00119 std::vector<StringTgtCand>& rv,
00120 std::vector<std::string>& wa) const;
00121
00122
00123
00124 void PrintTargetCandidates(PrefixPtr p,std::ostream& out) const;
00125 std::string GetScoreProducerDescription(unsigned) const;
00126 std::string GetScoreProducerWeightShortName(unsigned) const {
00127 return "tm";
00128 }
00129 };
00130
00131
00132 }
00133
00134 #endif