public MaximumEntropyPOSTagger(int beamSize, MaxEntropyModel_Interface model, IPosContextGenerator contextGenerator, Interfaces.PosLookupList dictionary) { mBeamSize = beamSize; mPosModel = model; mContextGenerator = contextGenerator; Beam = new PosBeamSearch(this, mBeamSize, contextGenerator, model); mDictionary = dictionary; }
/// <summary> /// Creates new search object. /// </summary> /// <param name="size"> /// The size of the beam (k). /// </param> /// <param name="contextGenerator"> /// the context generator for the model. /// </param> /// <param name="model"> /// the model for assigning probabilities to the sequence outcomes. /// </param> /// <param name="cacheSize"> /// size of the cache to use for performance. /// </param> public BeamSearch(int size, IBeamSearchContextGenerator contextGenerator, MaxEntropyModel_Interface model, int cacheSize) { Size = size; ContextGenerator = contextGenerator; Model = model; mProbabilities = new double[model.OutcomeCount]; if (cacheSize > 0) { mContextsCache = new Cache(cacheSize); } }
public virtual void LocalEvaluate(MaxEntropyModel_Interface posModel, System.IO.StreamReader reader, out double accuracy, out double sentenceAccuracy) { mPosModel = posModel; float total = 0, correct = 0, sentences = 0, sentencesCorrect = 0; System.IO.StreamReader sentenceReader = new System.IO.StreamReader(reader.BaseStream, System.Text.Encoding.UTF7); string line; while ((object)(line = sentenceReader.ReadLine()) != null) { sentences++; Util.Pair <ArrayList, ArrayList> annotatedPair = Interfaces.PosEventReader.ConvertAnnotatedString(line); ArrayList words = annotatedPair.FirstValue; ArrayList outcomes = annotatedPair.SecondValue; ArrayList tags = new ArrayList(Beam.BestSequence(words, null).Outcomes); int count = 0; bool isSentenceOK = true; for (System.Collections.IEnumerator tagIndex = tags.GetEnumerator(); tagIndex.MoveNext(); count++) { total++; string tag = (string)tagIndex.Current; if (tag == (string)outcomes[count]) { correct++; } else { isSentenceOK = false; } } if (isSentenceOK) { sentencesCorrect++; } } accuracy = correct / total; sentenceAccuracy = sentencesCorrect / sentences; }
/// <summary> /// Creates a new name finder with the specified model and context generator. /// </summary> /// <param name="model"> /// The model to be used to find names. /// </param> /// <param name="contextGenerator"> /// The context generator to be used with this name finder. /// </param> /// <param name="beamSize"> /// The size of the beam to be used in decoding this model. /// </param> public MaximumEntropyNameFinder(MaxEntropyModel_Interface model, Interfaces.INameContextGenerator contextGenerator, int beamSize) { mModel = model; mContextGenerator = contextGenerator; mBeam = new NameBeamSearch(this, beamSize, contextGenerator, model, beamSize); }
/// <summary> /// Creates a new name finder with the specified model and context generator. /// </summary> /// <param name="model"> /// The model to be used to find names. /// </param> /// <param name="contextGenerator"> /// The context generator to be used with this name finder. /// </param> public MaximumEntropyNameFinder(MaxEntropyModel_Interface model, Interfaces.INameContextGenerator contextGenerator) : this(model, contextGenerator, 10) { }
/// <summary> /// Creates a new name finder with the specified model. /// </summary> /// <param name="model"> /// The model to be used to find names. /// </param> public MaximumEntropyNameFinder(MaxEntropyModel_Interface model) : this(model, new Interfaces.DefaultNameContextGenerator(10), 10) { }
/// <summary> /// Creates a beam seach of the specified size using the specified model with the specified context generator. /// </summary> /// <param name="nameFinder"> /// The associated MaximumEntropyNameFinder instance. /// </param> /// <param name="size"> /// The size of the beam. /// </param> /// <param name="contextGenerator"> /// The context generator used with the specified model. /// </param> /// <param name="model"> /// The model used to determine names. /// </param> /// <param name="beamSize"> /// The size of the beam to use in searching. /// </param> public NameBeamSearch(MaximumEntropyNameFinder nameFinder, int size, Interfaces.INameContextGenerator contextGenerator, MaxEntropyModel_Interface model, int beamSize) : base(size, contextGenerator, model, beamSize) { mNameFinder = nameFinder; }
public PosBeamSearch(MaximumEntropyPOSTagger posTagger, int size, Util.IBeamSearchContextGenerator contextGenerator, MaxEntropyModel_Interface model, int cacheSize) : base(size, contextGenerator, model, cacheSize) { mMaxentPosTagger = posTagger; }
public MaximumEntropyPOSTagger(MaxEntropyModel_Interface model, IPosContextGenerator contextGenerator, Interfaces.PosLookupList dictionary) : this(mDefaultBeamSize, model, contextGenerator, dictionary) { }
public MaximumEntropyPOSTagger(MaxEntropyModel_Interface model, IPosContextGenerator contextGenerator) : this(mDefaultBeamSize, model, contextGenerator, null) { }
// Constructors public MaximumEntropyPOSTagger(MaxEntropyModel_Interface model) : this(model, new POS_ContextGenerator()) { }
/// <summary> /// Creates new search object. /// </summary> /// <param name="size"> /// The size of the beam (k). /// </param> /// <param name="contextGenerator"> /// the context generator for the model. /// </param> /// <param name="model"> /// the model for assigning probabilities to the sequence outcomes. /// </param> public BeamSearch(int size, IBeamSearchContextGenerator contextGenerator, MaxEntropyModel_Interface model) : this(size, contextGenerator, model, 0) { }
/// <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> /// Creates a chunker using the specified model. /// </summary> /// <param name="model"> /// The maximum entropy model for this chunker. /// </param> public MaximumEntropyChunker(MaxEntropyModel_Interface model):this(model, new DefaultChunkerContextGenerator(), 10) { }
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 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; }