Example #1
0
        public void Setup(bool debug)
        {
            var readModel = new ReadModel(InputModelFile);
            _weightVector = new WeightVector();

            foreach (var pair in readModel.ModelIterator())
            {
                _weightVector.Add(pair);
            }

            _tags = new Tags(_tagList);

            _viterbiForGlobalLinearModel = new ViterbiForGlobalLinearModel(_weightVector, _tags);

            // read input file in a class and per line iterator.
            var inputData = new ReadInputData(InputTestFile);
            var writeModel = new WriteModel(_outputTestFile);
            foreach (var line in inputData.GetSentence())
            {
                List<string> debugList;
                var outputTags = _viterbiForGlobalLinearModel.Decode(line, debug, out debugList);
                if (debug)
                {
                    writeModel.WriteDataWithTagDebug(line, outputTags, debugList);
                }
                else
                {
                    writeModel.WriteDataWithTag(line, outputTags);
                }

            }
            writeModel.Flush();
        }
 public ViterbiForGlobalLinearModel(WeightVector weightVector, Tags tags)
 {
     WeightVector = weightVector;
     Tags = tags;
     Pi = new List<Dictionary<string, float>>();
     Bp = new List<Dictionary<string, string>>();
 }
Example #3
0
 public WeightedFeatureSum(WeightVector weightVector, List<string> sentence)
 {
     _sentence = sentence;
     WeightVector = weightVector;
 }