Beispiel #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();
        }
Beispiel #2
0
        public void StartMapping()
        {
            var inputData = new ReadInputData(_inputFile);
            foreach (var line in inputData.GetSentence())
            {
                var inputTags = new List<string>(line.Count);
                for (var j = 0; j < line.Count; j++)
                {
                    var split = line[j].Split(new char[] {' '});
                    line[j] = split[0];
                    inputTags.Add(split[1]);
                }
                GenerateMappingForSentence(line);

            }
            inputData.Reset();
            foreach (var pair in DictFeaturesToK)
            {
                writeModel.WriteLine(string.Format("{0}\t{1}", pair.Key, pair.Value));
            }
            writeModel.Flush();
        }