DeSR Dependency Parser |
00001 /* 00002 ** DeSR 00003 ** src/EventStream.cpp 00004 ** ---------------------------------------------------------------------- 00005 ** Copyright (c) 2005 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 #include "EventStream.h" 00025 #include "Parser.h" 00026 00027 namespace Parser { 00028 00029 //====================================================================== 00030 // EventStream 00031 00032 bool EventStream::hasNext() 00033 { 00034 if (state && state->hasNext()) 00035 return true; 00036 while (sentenceCount++ < sentenceCutoff && reader->MoveNext()) { 00037 Sentence* sentence = reader->Current(); 00038 if (sentence->size()) { 00039 state = new TrainState(*sentence, info); 00040 delete sentence; // TrainState() copies it. 00041 return true; 00042 } 00043 delete sentence; 00044 } 00045 return false; 00046 } 00047 00055 Tanl::Classifier::Event* EventStream::next() 00056 { 00057 Tanl::Classifier::Event* ev = state->next(); 00058 state->transition(ev->className.c_str()); 00059 return ev; 00060 } 00061 00062 } // namespace Parser