/// <summary> /// Creates a new event reader based on the specified data reader using the specified context generator. /// </summary> /// <param name="dataReader"> /// The data reader for this event reader. /// </param> /// <param name="contextGenerator"> /// The context generator which should be used in the creation of events for this event reader. /// </param> public ChunkerEventReader(SharpEntropy.ITrainingDataReader<string> dataReader, IChunkerContextGenerator contextGenerator) { mContextGenerator = contextGenerator; mDataReader = dataReader; mEventIndex = 0; if (dataReader.HasNext()) { AddNewEvents(); } else { mEvents = new SharpEntropy.TrainingEvent[0]; } }
/// <summary> /// Create an event reader based on the specified data reader of the specified type using the specified head rules. /// </summary> /// <param name="dataReader"> /// A 1-parse-per-line Penn Treebank Style parse. /// </param> /// <param name="rules"> /// The head rules. /// </param> /// <param name="eventType"> /// The type of events desired (tag, chunk, build, or check). /// </param> public ParserEventReader(SharpEntropy.ITrainingDataReader<string> dataReader, IHeadRules rules, EventType eventType) { if (eventType == EventType.Build) { mBuildContextGenerator = new BuildContextGenerator(); } else if (eventType == EventType.Check) { mCheckContextGenerator = new CheckContextGenerator(); } else if (eventType == EventType.Chunk) { mChunkContextGenerator = new ChunkContextGenerator(); } else if (eventType == EventType.Tag) { mPosContextGenerator = new PosTagger.DefaultPosContextGenerator(); } mHeadRules = rules; mEventType = eventType; mDataReader = dataReader; mEventIndex = 0; if (dataReader.HasNext()) { AddNewEvents(); } else { mEvents = new SharpEntropy.TrainingEvent[0]; } }