00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef Tanl_SST_SST_H
00025 #define Tanl_SST_SST_H
00026
00027
00028 #include "conf/conf_bool.h"
00029 #include "conf/conf_float.h"
00030 #include "conf/conf_int.h"
00031 #include "conf/conf_string.h"
00032
00033
00034 #include "SstEventStream.h"
00035 #include "include/IPipe.h"
00036 #include "Corpus/Corpus.h"
00037 #include "classifier/MaxEnt.h"
00038
00039 namespace Tanl {
00040 namespace SST {
00041
00046
00047
00049
00051 extern IXE::conf<std::string> resourceDir;
00053 extern IXE::conf<std::string> language;
00055 extern IXE::conf<int> cutoff;
00057 extern IXE::conf<int> iter;
00059 extern IXE::conf<float> alpha;
00061 extern IXE::conf<bool> verbose;
00063
00065
00066
00070 class SST : public IPipe<std::vector<Token*>*, std::vector<Token*>*>
00071 {
00072 public:
00073
00078 SST(char const* modelFile, char const* configFile = 0);
00079
00080 ~SST();
00081
00086 void train(SentenceReader* sentenceReader, char const* modelFile);
00087
00088 Enumerator<std::vector<Token*>*>* pipe(Enumerator<std::vector<Token*>*>& sen);
00089
00090 friend class SSTPipe;
00091
00092 private:
00093 Classifier::MaxEnt* model;
00094 Resources resources;
00095 };
00096
00100 struct SSTPipe : public Enumerator<std::vector<Token*>*>
00101 {
00103 SSTPipe(SST& sst, Enumerator<std::vector<Token*>*>& se);
00104
00107 bool MoveNext();
00108
00110 std::vector<Token*>* Current();
00111
00112 private:
00113 SST& sst;
00114 Enumerator<std::vector<Token*>*>& se;
00115 SstEventStream eventStream;
00116 unordered_map<int, int> outcomeId;
00117 };
00118
00119 }
00120 }
00121
00122 #endif // Tanl_SST_SST_H