public ViterbiForGlobalLinearModel(WeightVector weightVector, Tags tags) { WeightVector = weightVector; Tags = tags; Pi = new List<Dictionary<string, float>>(); Bp = new List<Dictionary<string, string>>(); }
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 MapFeaturesToK(string inputFile, string outputFile, List<string> tagList) { writeModel = new WriteModel(outputFile); _inputFile = inputFile; _tagList = tagList; DictFeaturesToK = new Dictionary<string, int>(); _featureCount = 0; _tags = new Tags(tagList); }
/* static void Test() { const string inputFile = "../../data/tag.model"; //const string outputFile = "../../test.output1"; var readModel = new ReadModel(inputFile); //var writeModel = new WriteModel(outputFile); var weightVector = new WeightVector(); var tags = new List<string> {"I-GENE", "O"}; PrintFeatureList(tags); foreach (var pair in readModel.ModelIterator()) { weightVector.Add(pair); } //writeModel.WriteLine(line); //writeModel.Flush(); } */ static void PrintFeatureList(List<string> tags) { var featureTags = new Tags(tags); featureTags.Dump(3); }