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 DeSR_PosTagger_H
00025 #define DeSR_PosTagger_H
00026
00027 #include <vector>
00028 #include <map>
00029
00030 #include "text/WordSet.h"
00031 #include "include/error.h"
00032
00033 using namespace Tanl::Text;
00034
00035 namespace Parser {
00036
00037 struct Tagged
00038 {
00039 std::vector<char const*> words;
00040 std::vector<char const*> tags;
00041 std::vector<char const*> lemmas;
00042
00043 ~Tagged() { clear(); }
00044
00045 void clear() {
00046 words.clear();
00047
00048
00049 tags.clear();
00050 lemmas.clear();
00051 }
00052
00053 size_t length() { return words.size(); }
00054 };
00055
00059 struct PosTagger
00060 {
00061 PosTagger() { }
00062
00068 PosTagger(const char* PosParameters);
00069
00070 ~PosTagger() {
00071 tags.clear();
00072 }
00073
00079 virtual bool tag(Tagged& sentence);
00080
00084 WordSet tags;
00085
00086 };
00087
00088 struct PennPosTagger : public PosTagger
00089 {
00090 PennPosTagger(const char* PosParameters);
00091
00097 bool tag(Tagged& sentence);
00098
00102 typedef std::map<std::string, char const*> PosMap;
00103
00104 static PosMap posMap;
00105 static PosMap inversePosMap;
00106 };
00107
00108 struct PosTaggerError : public std::runtime_error {
00109 PosTaggerError(std::string const& msg) : std::runtime_error(msg) {}
00110 };
00111
00112 }
00113
00114 #endif // DeSR_PosTagger_H