/// <summary> /// Main method. Call as follows: /// <para> /// java ModelApplier modelFile dataFile /// </para> /// </summary> public static void Main(string[] args) { string dataFileName, modelFileName; bool real = false; string type = "maxent"; int ai = 0; if (args.Length == 0) { usage(); } if (args.Length > 0) { while (args[ai].StartsWith("-", StringComparison.Ordinal)) { if (args[ai].Equals("-real")) { real = true; } else if (args[ai].Equals("-perceptron")) { type = "perceptron"; } else { usage(); } ai++; } modelFileName = args[ai++]; dataFileName = args[ai++]; ModelApplier predictor = null; try { MaxentModel m = (new GenericModelReader(new Jfile(modelFileName))).Model; predictor = new ModelApplier(m); } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); Environment.Exit(0); } try { EventStream es = new BasicEventStream(new PlainTextByLineDataStream(new FileReader(new Jfile(dataFileName))), ","); while (es.hasNext()) { predictor.eval(es.next(), real); } return; } catch (Exception e) { Console.WriteLine("Unable to read from specified file: " + modelFileName); Console.WriteLine(); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } } }