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_Classifier_Classifier_H
00025 #define Tanl_Classifier_Classifier_H
00026
00027 #include "include/config.h"
00028 #include "Event.h"
00029
00030 namespace Tanl {
00031 namespace Classifier {
00032
00043 class Classifier
00044 {
00045 public:
00046
00047 Classifier() :
00048 verbose(false)
00049 { }
00050
00054 Classifier(char const* file);
00055
00059 Classifier(std::istream& ifs);
00060
00061 virtual ~Classifier() { }
00062
00070 ClassID BestOutcome(double* ocs) const;
00071
00078 char const* OutcomeName(int i) const { return outcomeLabels[i]; }
00079
00086 ClassID OutcomeID(char const* c) const {
00087 for (int i = 0; i < outcomeLabels.size(); i++)
00088 if (!strcmp(outcomeLabels[i], c))
00089 return i;
00090 return (ClassID)-1;
00091 }
00092
00096 int NumOutcomes() const { return numOutcomes; }
00097
00104 std::string PredicateName(int i) const { return predLabels[i]; }
00105
00112 int PredicateIndex(char const* name) { return predIndex[name]; }
00113
00117 void load(std::istream& is);
00118
00122 void save(char const* file);
00123
00124 Text::WordIndex& PredIndex() { return predIndex; }
00125
00127 bool verbose;
00128
00129 protected:
00130
00131 std::vector<std::string> predLabels;
00132
00133
00134 Text::WordIndex predIndex;
00135
00136 std::vector<char const*> outcomeLabels;
00137
00138 ClassID numOutcomes;
00139
00140 };
00141
00142 }
00143 }
00144
00145 #endif // Tanl_Classifier_Classifier_H