Example #1
0
    public void FinishLearning()
    {
        train_file.Close();
        train_file = null;

        train_file2.Close();
        train_file2 = null;

        System.IO.StreamReader            trainingStreamReader = new System.IO.StreamReader(train_file_path);
        SharpEntropy.ITrainingEventReader eventReader          = new SharpEntropy.BasicEventReader(new SharpEntropy.PlainTextByLineDataReader(trainingStreamReader));
        SharpEntropy.GisTrainer           trainer = new SharpEntropy.GisTrainer();
        System.Console.WriteLine("Training MaxEnt...");

        trainer.TrainModel(eventReader);
        mModel = new SharpEntropy.GisModel(trainer);

        string modelDataFile = @"maxent_model.txt";

        //SharpEntropy.IO.BinaryGisModelWriter writer = new SharpEntropy.IO.BinaryGisModelWriter();
        SharpEntropy.IO.PlainTextGisModelWriter writer = new SharpEntropy.IO.PlainTextGisModelWriter();
        writer.Persist(mModel, modelDataFile);

        result_label2id = new Dictionary <string, int>();

        foreach (string label in result_labels)
        {
            int id = mModel.GetOutcomeIndex(label);
            result_label2id.Add(label, id);
        }

        return;
    }
Example #2
0
        private static void ConvertBinaryGisFileToPlainText(string inputFilePath, string outputFilePath)
        {
            var reader = new BinaryGisModelReader(inputFilePath);
            var model = new GisModel(reader);

            var writer = new PlainTextGisModelWriter();
            writer.Persist(model, outputFilePath);
        }