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 "moses/TypeDef.h"
00015 #include "moses/PrefixTree.h"
00016 #include "moses/File.h"
00017 #include "moses/ObjectPool.h"
00018 #include "moses/FF/LexicalReordering/LexicalReorderingTable.h"
00019 #include "moses/LVoc.h"
00020 #include "moses/TypeDef.h"
00021 #include "moses/Util.h"
00022 
00023 namespace Moses
00024 {
00025 
00026 class Phrase;
00027 class Word;
00028 class ConfusionNet;
00029 class PDTimp;
00030 
00031 typedef PrefixTreeF<LabelId,OFF_T> PTF;
00032 
00033 
00034 struct StringTgtCand {
00035   typedef std::vector<std::string const*> Tokens;
00036   Tokens tokens;
00037   Scores scores;
00038   Tokens fnames;
00039   std::vector<FValue> fvalues;
00040 
00041 };
00042 
00046 class PhraseDictionaryTree
00047 {
00048   PDTimp *imp; 
00049 
00050   PhraseDictionaryTree(const PhraseDictionaryTree&); 
00051   void operator=(const PhraseDictionaryTree&); 
00052 public:
00053   PhraseDictionaryTree();
00054 
00055   void NeedAlignmentInfo(bool a);
00056 
00057   void PrintWordAlignment(bool a);
00058   bool PrintWordAlignment();
00059 
00060 
00061   virtual ~PhraseDictionaryTree();
00062 
00063   size_t GetSize() const {
00064     return 0;
00065   }
00066 
00067   
00068   
00069   
00070   int Create(std::istream& in,const std::string& outFileNamePrefix);
00071 
00072   int Read(const std::string& fileNamePrefix);
00073 
00074   
00075   void FreeMemory() const;
00076 
00077 
00078   
00079 
00080 
00081   
00082   void PrintTargetCandidates(const std::vector<std::string>& src,
00083                              std::ostream& out) const;
00084 
00085   
00086   void GetTargetCandidates(const std::vector<std::string>& src,
00087                            std::vector<StringTgtCand>& rv) const;
00088 
00089 
00090   
00091   void GetTargetCandidates(const std::vector<std::string>& src,
00092                            std::vector<StringTgtCand>& rv,
00093                            std::vector<std::string>& wa) const;
00094 
00095   
00096 
00097 
00098 
00099   
00100   
00101   
00102   
00103 
00104   class PrefixPtr
00105   {
00106     PPimp* imp;
00107     friend class PDTimp;
00108   public:
00109     PrefixPtr(PPimp* x=0) : imp(x) {}
00110     operator bool() const;
00111   };
00112 
00113   
00114   PrefixPtr GetRoot() const;
00115   
00116   
00117   
00118   PrefixPtr Extend(PrefixPtr p,const std::string& s) const;
00119 
00120   
00121   
00122   void GetTargetCandidates(PrefixPtr p,
00123                            std::vector<StringTgtCand>& rv) const;
00124   void GetTargetCandidates(PrefixPtr p,
00125                            std::vector<StringTgtCand>& rv,
00126                            std::vector<std::string>& wa) const;
00127 
00128   
00129   
00130   void PrintTargetCandidates(PrefixPtr p,std::ostream& out) const;
00131 
00132 };
00133 
00134 
00135 }
00136 
00137 #endif