00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "text/strings.h"
00026 #include "conf/conf_bool.h"
00027
00028
00029 #include <iostream>
00030
00031
00032 #include "NerEventStream.h"
00033
00034 using namespace std;
00035 using namespace Tanl::Classifier;
00036
00037 namespace Tanl {
00038 namespace NER {
00039
00041 IXE::conf<bool> dumpEvents("DumpEvents", false);
00042
00043 NerEventStream::NerEventStream(Resources& resources) :
00044 position(0),
00045 featureExtractor(resources)
00046 { }
00047
00048 bool NerEventStream::hasNext()
00049 {
00050 return position < sentence->size();
00051 }
00052
00056 Event* NerEventStream::next()
00057 {
00058 Token* token = (*sentence)[position];
00059 char const* word = token->form.c_str();
00060 const string* tag = token->get(featureExtractor.resources.NEtag);
00061 char const* neTag = tag ? tag->c_str() : "";
00062
00063
00064 Event* event = new Event(neTag);
00065 featureExtractor.extract(event->features, position);
00066
00067
00068 featureExtractor.classified(position, neTag);
00069
00070 if (dumpEvents)
00071 cerr << *event << endl;
00072 position++;
00073 return event;
00074 }
00075
00076 void NerEventStream::predicted(char const* neTag, int pos)
00077 {
00078 if (pos < 0)
00079 pos = position-1;
00080 featureExtractor.classified(pos, neTag);
00081 }
00082
00083 }
00084 }