protected AbstractParserEventStream( IObjectStream <Parse> samples, IHeadRules headRules, ParserEventTypeEnum type, Dictionary.Dictionary dictionary) : base(samples) { Rules = headRules; Punctuation = headRules.PunctuationTags; Dictionary = dictionary; FixPossesives = false; Type = type; #pragma warning disable 618 switch (type) { case ParserEventTypeEnum.Chunk: chunkerContextGenerator = new ChunkContextGenerator(); break; case ParserEventTypeEnum.Tag: posContextGenerator = new DefaultPOSContextGenerator(null); break; } #pragma warning restore 618 }
/// <summary> /// Initializes a new instance of the <see cref="ChunkerME"/> with the specified <see cref="ChunkerModel"/>. /// </summary> /// <param name="model">The chunker model.</param> public ChunkerME(ChunkerModel model) { contextGenerator = model.Factory.GetContextGenerator(); sequenceValidator = model.Factory.GetSequenceValidator(); this.model = model.ChunkerSequenceModel ?? new BeamSearch(model.BeamSize, model.MaxentModel); }
/// <summary> /// Initializes the current instance with the specified model and the specified beam size. /// </summary> /// <param name="model">The model for this chunker</param> /// <param name="beamSize">The size of the beam that should be used when decoding sequences.</param> /// <param name="sequenceValidator">The <see cref="ISequenceValidator{String}"/> to determines whether the outcome is valid for the preceding sequence. This can be used to implement constraints on what sequences are valid..</param> /// <param name="contextGenerator">The context generator.</param> internal ChunkerME(ChunkerModel model, int beamSize, ISequenceValidator<string> sequenceValidator, IChunkerContextGenerator contextGenerator) { // This method is marked as deprecated in the OpenNLP, but it is required in the Parser, // I could change the cg in the factory, but its not ideal in this situation (i think) :P this.sequenceValidator = sequenceValidator; this.contextGenerator = contextGenerator; this.model = model.ChunkerSequenceModel ?? new BeamSearch(beamSize, model.MaxentModel); }
/// <summary> /// Initializes the current instance with the specified model and the specified beam size. /// </summary> /// <param name="model">The model for this chunker</param> /// <param name="beamSize">The size of the beam that should be used when decoding sequences.</param> /// <param name="sequenceValidator">The <see cref="ISequenceValidator{String}"/> to determines whether the outcome is valid for the preceding sequence. This can be used to implement constraints on what sequences are valid..</param> /// <param name="contextGenerator">The context generator.</param> internal ChunkerME(ChunkerModel model, int beamSize, ISequenceValidator <string> sequenceValidator, IChunkerContextGenerator contextGenerator) { // This method is marked as deprecated in the OpenNLP, but it is required in the Parser, // I could change the cg in the factory, but its not ideal in this situation (i think) :P this.sequenceValidator = sequenceValidator; this.contextGenerator = contextGenerator; this.model = model.ChunkerSequenceModel ?? new BeamSearch(beamSize, model.MaxentModel); }
/// <summary> /// Initializes a new instance of the <see cref="ChunkSampleSequenceStream" /> class using the given parameters. /// </summary> /// <param name="samples">The chunk samples.</param> /// <param name="contextGenerator">The chunker context generator.</param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="samples"/> is null. /// or /// The <paramref name="contextGenerator"/> is null. /// </exception> public ChunkSampleSequenceStream(IObjectStream<ChunkSample> samples, IChunkerContextGenerator contextGenerator) { if (samples == null) throw new ArgumentNullException("samples"); if (contextGenerator == null) throw new ArgumentNullException("contextGenerator"); this.samples = samples; this.contextGenerator = contextGenerator; }
/// <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> /// 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> /// Initializes a new instance of the <see cref="ChunkSampleSequenceStream" /> class using the given parameters. /// </summary> /// <param name="samples">The chunk samples.</param> /// <param name="contextGenerator">The chunker context generator.</param> /// <exception cref="System.ArgumentNullException"> /// The <paramref name="samples"/> is null. /// or /// The <paramref name="contextGenerator"/> is null. /// </exception> public ChunkSampleSequenceStream(IObjectStream <ChunkSample> samples, IChunkerContextGenerator contextGenerator) { if (samples == null) { throw new ArgumentNullException(nameof(samples)); } if (contextGenerator == null) { throw new ArgumentNullException(nameof(contextGenerator)); } this.samples = samples; this.contextGenerator = contextGenerator; }
public ChunkBeamSearch(MaximumEntropyChunker maxentChunker, int size, IChunkerContextGenerator contextGenerator, SharpEntropy.IMaximumEntropyModel model) : base(size, contextGenerator, model) { mMaxentChunker = maxentChunker; }
/// <summary> /// Creates a chunker using the specified model and context generator and decodes the /// model using a beam search of the specified size. /// </summary> /// <param name="model">The maximum entropy model for this chunker</param> /// <param name="contextGenerator">The context generator to be used by the specified model</param> /// <param name="beamSize">The size of the beam that should be used when decoding sequences</param> public MaximumEntropyChunker(SharpEntropy.IMaximumEntropyModel model, IChunkerContextGenerator contextGenerator, int beamSize) { Beam = new ChunkBeamSearch(this, beamSize, contextGenerator, model); Model = model; }
/// <summary> /// Creates a chunker using the specified model and context generator and decodes the /// model using a beam search of the specified size. /// </summary> /// <param name="model"> /// The maximum entropy model for this chunker. /// </param> /// <param name="contextGenerator"> /// The context generator to be used by the specified model. /// </param> /// <param name="beamSize"> /// The size of the beam that should be used when decoding sequences. /// </param> public MaximumEntropyChunker(SharpEntropy.IMaximumEntropyModel model, IChunkerContextGenerator contextGenerator, int beamSize) { mBeam = new ChunkBeamSearch(this, beamSize, contextGenerator, model); mModel = model; }
public ChunkBeamSearch(MaximumEntropyChunker maxentChunker, int size, IChunkerContextGenerator contextGenerator, SharpEntropy.IMaximumEntropyModel model) : base(size, contextGenerator, model) { _maxentChunker = maxentChunker; }
/// <summary> /// Creates a chunker using the specified model and context generator. /// </summary> /// <param name="model">The maximum entropy model for this chunker</param> /// <param name="contextGenerator">The context generator to be used by the specified model</param> public MaximumEntropyChunker(SharpEntropy.IMaximumEntropyModel model, IChunkerContextGenerator contextGenerator): this(model, contextGenerator, 10){}
/// <summary> /// Creates a chunker using the specified model and context generator. /// </summary> /// <param name="model"> /// The maximum entropy model for this chunker. /// </param> /// <param name="contextGenerator"> /// The context generator to be used by the specified model. /// </param> public MaximumEntropyChunker(MaxEntropyModel_Interface model, IChunkerContextGenerator contextGenerator):this(model, contextGenerator, 10) { }
/// <summary> /// Initializes a new instance of the <see cref="ChunkerME"/> with the specified <see cref="ChunkerModel"/>. /// </summary> /// <param name="model">The chunker model.</param> public ChunkerME(ChunkerModel model) { contextGenerator = model.Factory.GetContextGenerator(); sequenceValidator = model.Factory.GetSequenceValidator(); this.model = model.ChunkerSequenceModel ?? new BeamSearch(model.BeamSize, model.MaxentModel); }
public ChunkBeamSearch(MaximumEntropyChunker maxentChunker, int size, IChunkerContextGenerator contextGenerator, MaxEntropyModel_Interface model):base(size, contextGenerator, model) { mMaxentChunker = maxentChunker; }
/// <summary> /// Creates a chunker using the specified model and context generator. /// </summary> /// <param name="model"> /// The maximum entropy model for this chunker. /// </param> /// <param name="contextGenerator"> /// The context generator to be used by the specified model. /// </param> public MaximumEntropyChunker(SharpEntropy.IMaximumEntropyModel model, IChunkerContextGenerator contextGenerator) : this(model, contextGenerator, 10) { }
/// <summary> /// Creates a new event stream based on the specified data stream using the specified context generator. /// </summary> /// <param name="samples">The samples for this event stream.</param> /// <param name="cg">The context generator which should be used in the creation of events for this event stream.</param> public ChunkerEventStream(IObjectStream <ChunkSample> samples, IChunkerContextGenerator cg) : base(samples) { this.cg = cg; }
/// <summary> /// Initializes a new instance of the <see cref="ChunkSampleSequenceStream"/> class using the given parameters. /// </summary> /// <param name="samples">The chunk samples.</param> /// <param name="contextGenerator">The chunker context generator.</param> public ChunkSampleSequenceStream(IObjectStream <ChunkSample> samples, IChunkerContextGenerator contextGenerator) { this.samples = samples; this.contextGenerator = contextGenerator; }
/// <summary> /// Creates a chunker using the specified model and context generator and decodes the /// model using a beam search of the specified size. /// </summary> /// <param name="model"> /// The maximum entropy model for this chunker. /// </param> /// <param name="contextGenerator"> /// The context generator to be used by the specified model. /// </param> /// <param name="beamSize"> /// The size of the beam that should be used when decoding sequences. /// </param> public MaximumEntropyChunker(MaxEntropyModel_Interface model, IChunkerContextGenerator contextGenerator, int beamSize) { mBeam = new ChunkBeamSearch(this, beamSize, contextGenerator, model); mModel = model; }