Ejemplo n.º 1
0
        public GenericModelWriter(AbstractModel model, Jfile file)
        {
            string filename = file.Name;
            OutputStream os;
            // handle the zipped/not zipped distinction
            if (filename.EndsWith(".gz", StringComparison.Ordinal))
            {
                os = new GZIPOutputStream(new FileOutputStream(file));
                filename = filename.Substring(0, filename.Length - 3);
            }
            else
            {
                os = new FileOutputStream(file);
            }

            // handle the different formats
            if (filename.EndsWith(".bin", StringComparison.Ordinal))
            {
                init(model, new DataOutputStream(os));
            }
            else // filename ends with ".txt"
            {
                init(model, new BufferedWriter(new OutputStreamWriter(os)));
            }
        }
Ejemplo n.º 2
0
        public QNModelWriter(AbstractModel model)
        {
            object[] data = model.DataStructures;
            cParameters  = (Context[])data[0];
            pmap         = (IndexHashTable <string>)data[1];
            outcomeNames = (string[])data[2];

            QNModel qnModel = (QNModel)model;

            parameters = qnModel.Parameters;
        }
Ejemplo n.º 3
0
 private void init(AbstractModel model, BufferedWriter bw)
 {
     if (model.ModelType == ModelType.Perceptron)
     {
         delegateWriter = new PlainTextPerceptronModelWriter(model, bw);
     }
     else if (model.ModelType == ModelType.Maxent)
     {
         delegateWriter = new PlainTextGISModelWriter(model, bw);
     }
 }
Ejemplo n.º 4
0
 private void init(AbstractModel model, DataOutputStream dos)
 {
     if (model.ModelType == ModelType.Perceptron)
     {
         delegateWriter = new BinaryPerceptronModelWriter(model, dos);
     }
     else if (model.ModelType == ModelType.Maxent)
     {
         delegateWriter = new BinaryGISModelWriter(model, dos);
     }
     else if (model.ModelType == ModelType.MaxentQn)
     {
         delegateWriter = new BinaryQNModelWriter(model, dos);
     }
 }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            AbstractModel m = (new GenericModelReader(new Jfile(args[0]))).Model;

            (new GenericModelWriter(m, new Jfile(args[1]))).persist();
        }
Ejemplo n.º 6
0
 public GenericModelWriter(AbstractModel model, DataOutputStream dos)
 {
     init(model, dos);
 }