Tanl Linguistic Pipeline |
00001 /* 00002 ** DeSR 00003 ** src/ReviseEventStream.h 00004 ** ---------------------------------------------------------------------- 00005 ** Copyright (c) 2006 Giuseppe Attardi (attardi@di.unipi.it). 00006 ** ---------------------------------------------------------------------- 00007 ** 00008 ** This file is part of DeSR. 00009 ** 00010 ** DeSR is free software; you can redistribute it and/or modify it 00011 ** under the terms of the GNU General Public License, version 3, 00012 ** as published by the Free Software Foundation. 00013 ** 00014 ** DeSR is distributed in the hope that it will be useful, 00015 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 ** GNU General Public License for more details. 00018 ** 00019 ** You should have received a copy of the GNU General Public License 00020 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00021 ** ---------------------------------------------------------------------- 00022 */ 00023 00024 #ifndef DesR_ReviseEventStream_H 00025 #define DesR_ReviseEventStream_H 00026 00027 // library 00028 #include "Classifier.h" 00029 00030 // local 00031 #include "SentenceReader.h" 00032 00033 using namespace Tanl; 00034 00035 namespace Parser { 00036 00040 class ReviseStream 00041 { 00042 public: 00043 ReviseStream() { } 00044 00045 virtual ~ReviseStream() { delete sentence; } 00046 00050 std::vector<std::string> actions; 00051 00052 protected: 00053 00054 ReviseStream(SentenceReader* reader); 00055 00056 void clear(); 00057 void predicates(Tanl::Classifier::Features& preds); 00058 void childFeatures(TreeToken* tok, char const* tag, 00059 Tanl::Classifier::Features& preds); 00060 00064 SentenceReader* reader; 00065 00066 Sentence* sentence; 00067 00068 public: /* FIXME: temporary */ 00069 unsigned cur; 00070 00071 }; 00072 00076 class ReviseEventStream : public ReviseStream 00077 { 00078 ReviseEventStream() { } 00079 }; 00080 00084 class ReviseContextStream : public ReviseStream, public Tanl::Classifier::ContextStream 00085 { 00086 public: 00092 ReviseContextStream(SentenceReader* reader, WordIndex& predIndex) : 00093 ReviseStream(reader), 00094 predIndex(predIndex) 00095 { } 00096 00097 bool hasNext(); 00098 Tanl::Classifier::Context* next(); 00099 char const* Outcome(); 00100 00104 void revise(); 00105 00106 private: 00107 int performAction(TreeToken* to, int from, char const* action); 00108 00109 WordIndex& predIndex; 00110 Tanl::Classifier::Context context; 00111 }; 00112 00113 } // namespace Parser 00114 00115 #endif // DesR_ReviseEventStream_H