public AbstractModel(Context[] params, String[] predLabels, String[] outcomeNames) { init(predLabels, params, outcomeNames); this.evalParams = new EvalParameters(params, outcomeNames.length); }
/** * Retrieves an array of all possible part-of-speech tags from the * tagger. * * @return String[] */ public String[] getAllPosTags() { return model.getOutcomes(); }
@Override public void writeUTF(String s) throws IOException { delegateWriter.writeUTF(s); } }
private Event createEvent(String obs) { int lastSpace = obs.lastIndexOf(' '); if (lastSpace == -1) return null; else { String[] contexts = obs.substring(0,lastSpace).split("\\s+"); float[] values = RealValueFileEventStream.parseContexts(contexts); return new Event(obs.substring(lastSpace + 1),contexts,values); } }
@Override public String[] getOutcomes() { String[] outcomes = new String[model.getNumOutcomes()]; for (int i = 0; i < model.getNumOutcomes(); i++) { outcomes[i] = model.getOutcome(i); } return outcomes; } }
public AbstractModel create(InputStream in) throws IOException { return new GenericModelReader(new BinaryFileDataReader(in)).getModel(); }
protected double[] initOutcomeTotals(String[] outcomeNames, Context[] params) { double[] outcomeTotals = new double[outcomeNames.length]; for (int i = 0; i < params.length; ++i) { Context context = params[i]; for (int j = 0; j < context.getOutcomes().length; ++j) { int outcome = context.getOutcomes()[j]; double count = context.getParameters()[j]; outcomeTotals[outcome] += count; } } return outcomeTotals; }
public Sequence[] topKLemmaClasses(String[] sentence, String[] tags, double minSequenceScore) { return model.bestSequences(DEFAULT_BEAM_SIZE, sentence, new Object[] { tags }, minSequenceScore, contextGenerator, sequenceValidator); } }
/** * Constructor which directly instantiates the DataInputStream containing * the model contents. * * @param dis The DataInputStream containing the model information. */ public BinaryNaiveBayesModelReader(DataInputStream dis) { super(new BinaryFileDataReader(dis)); }
/** * Constructor which directly instantiates the BufferedReader containing * the model contents. * * @param br The BufferedReader containing the model information. */ public PlainTextNaiveBayesModelReader(BufferedReader br) { super(new PlainTextFileDataReader(br)); }
/** * Implement as needed for the format the model is stored in. */ public double readDouble() throws java.io.IOException { return dataReader.readDouble(); }
protected AbstractModel(Context[] params, String[] predLabels, Map<String, Context> pmap, String[] outcomeNames) { this.pmap = pmap; this.outcomeNames = outcomeNames; this.evalParams = new EvalParameters(params,outcomeNames.length); }
/** * Implement as needed for the format the model is stored in. */ public String readUTF() throws java.io.IOException { return dataReader.readUTF(); }
@Override public void persist() throws IOException { delegateWriter.persist(); }
@Override public void writeDouble(double d) throws IOException { delegateWriter.writeDouble(d); }
/** * Implement as needed for the format the model is stored in. */ public int readInt() throws java.io.IOException { return dataReader.readInt(); }
/** * Constructor which directly instantiates the DataInputStream containing the * model contents. * * @param dis * The DataInputStream containing the model information. */ public BinaryGISModelReader(DataInputStream dis) { super(new BinaryFileDataReader(dis)); } }
/** * Constructor which directly instantiates the DataInputStream containing the * model contents. * * @param dis * The DataInputStream containing the model information. */ public BinaryQNModelReader(DataInputStream dis) { super(new BinaryFileDataReader(dis)); } }