public int getIndex(String category) { return model.getMaxentModel().getIndex(category); }
private Parser(MaxentModel buildModel, MaxentModel attachModel, MaxentModel checkModel, POSTagger tagger, Chunker chunker, HeadRules headRules, int beamSize, double advancePercentage) { super(tagger,chunker,headRules,beamSize,advancePercentage); this.buildModel = buildModel; this.attachModel = attachModel; this.checkModel = checkModel; this.buildContextGenerator = new BuildContextGenerator(); this.attachContextGenerator = new AttachContextGenerator(punctSet); this.checkContextGenerator = new CheckContextGenerator(punctSet); this.bprobs = new double[buildModel.getNumOutcomes()]; this.aprobs = new double[attachModel.getNumOutcomes()]; this.cprobs = new double[checkModel.getNumOutcomes()]; this.doneIndex = buildModel.getIndex(DONE); this.sisterAttachIndex = attachModel.getIndex(ATTACH_SISTER); this.daughterAttachIndex = attachModel.getIndex(ATTACH_DAUGHTER); this.nonAttachIndex = attachModel.getIndex(NON_ATTACH); attachments = new int[] {daughterAttachIndex,sisterAttachIndex}; this.completeIndex = checkModel.getIndex(Parser.COMPLETE); }
model.eval(cg.getContext(tok, j - origStart)); String best = model.getBestOutcome(probs); tokenProb *= probs[model.getIndex(best)]; if (best.equals(TokenizerME.SPLIT)) { newTokens.add(new Span(start, j));
positions.add(getFirstNonWS(s, cint + 1)); sentProbs.add(probs[model.getIndex(bestOutcome)]);
public int getIndex(String category) { return model.getMaxentModel().getIndex(category); }
public int getIndex(String category) { return model.getMaxentModel().getIndex(category); }
public int getIndex(String category) { return this.model.getMaxentModel().getIndex(category); }
private SimilarityModel(String modelName, boolean train) throws IOException { this.modelName = modelName; if (train) { events = new ArrayList<Event>(); } else { testModel = (new SuffixSensitiveGISModelReader(new File(modelName + modelExtension))).getModel(); SAME_INDEX = testModel.getIndex(SAME); } }
private Parser(MaxentModel buildModel, MaxentModel attachModel, MaxentModel checkModel, POSTagger tagger, Chunker chunker, HeadRules headRules, int beamSize, double advancePercentage) { super(tagger,chunker,headRules,beamSize,advancePercentage); this.buildModel = buildModel; this.attachModel = attachModel; this.checkModel = checkModel; this.buildContextGenerator = new BuildContextGenerator(); this.attachContextGenerator = new AttachContextGenerator(punctSet); this.checkContextGenerator = new CheckContextGenerator(punctSet); this.bprobs = new double[buildModel.getNumOutcomes()]; this.aprobs = new double[attachModel.getNumOutcomes()]; this.cprobs = new double[checkModel.getNumOutcomes()]; this.doneIndex = buildModel.getIndex(DONE); this.sisterAttachIndex = attachModel.getIndex(ATTACH_SISTER); this.daughterAttachIndex = attachModel.getIndex(ATTACH_DAUGHTER); this.nonAttachIndex = attachModel.getIndex(NON_ATTACH); attachments = new int[] {daughterAttachIndex,sisterAttachIndex}; this.completeIndex = checkModel.getIndex(Parser.COMPLETE); }
private Parser(MaxentModel buildModel, MaxentModel attachModel, MaxentModel checkModel, POSTagger tagger, Chunker chunker, HeadRules headRules, int beamSize, double advancePercentage) { super(tagger,chunker,headRules,beamSize,advancePercentage); this.buildModel = buildModel; this.attachModel = attachModel; this.checkModel = checkModel; this.buildContextGenerator = new BuildContextGenerator(); this.attachContextGenerator = new AttachContextGenerator(punctSet); this.checkContextGenerator = new CheckContextGenerator(punctSet); this.bprobs = new double[buildModel.getNumOutcomes()]; this.aprobs = new double[attachModel.getNumOutcomes()]; this.cprobs = new double[checkModel.getNumOutcomes()]; this.doneIndex = buildModel.getIndex(DONE); this.sisterAttachIndex = attachModel.getIndex(ATTACH_SISTER); this.daughterAttachIndex = attachModel.getIndex(ATTACH_DAUGHTER); this.nonAttachIndex = attachModel.getIndex(NON_ATTACH); attachments = new int[] {daughterAttachIndex,sisterAttachIndex}; this.completeIndex = checkModel.getIndex(Parser.COMPLETE); }
private NumberModel(String modelName, boolean train) throws IOException { this.modelName = modelName; if (train) { events = new ArrayList<Event>(); } else { //if (MaxentResolver.loadAsResource()) { // testModel = (new PlainTextGISModelReader(new BufferedReader(new InputStreamReader( // this.getClass().getResourceAsStream(modelName))))).getModel(); //} testModel = (new SuffixSensitiveGISModelReader(new File(modelName + modelExtension))).getModel(); singularIndex = testModel.getIndex(NumberEnum.SINGULAR.toString()); pluralIndex = testModel.getIndex(NumberEnum.PLURAL.toString()); } }
public DefaultNonReferentialResolver(String projectName, String name, ResolverMode mode) throws IOException { this.mode = mode; this.modelName = projectName + "/" + name + ".nr"; if (mode == ResolverMode.TRAIN) { events = new ArrayList<Event>(); } else if (mode == ResolverMode.TEST) { if (loadAsResource) { model = new BinaryGISModelReader(new DataInputStream( this.getClass().getResourceAsStream(modelName))).getModel(); } else { model = (new SuffixSensitiveGISModelReader(new File(modelName + modelExtension))).getModel(); } nonRefIndex = model.getIndex(MaxentResolver.SAME); } else { throw new RuntimeException("unexpected mode " + mode); } }
private GenderModel(String modelName, boolean train) throws IOException { this.modelName = modelName; maleNames = readNames(modelName + ".mas"); femaleNames = readNames(modelName + ".fem"); if (train) { events = new ArrayList<Event>(); } else { //if (MaxentResolver.loadAsResource()) { // testModel = (new BinaryGISModelReader(new DataInputStream( // this.getClass().getResourceAsStream(modelName)))).getModel(); //} testModel = (new SuffixSensitiveGISModelReader(new File(modelName + modelExtension))).getModel(); maleIndex = testModel.getIndex(GenderEnum.MALE.toString()); femaleIndex = testModel.getIndex(GenderEnum.FEMALE.toString()); neuterIndex = testModel.getIndex(GenderEnum.NEUTER.toString()); } }
if (ResolverMode.TEST == this.mode) { model = (new SuffixSensitiveGISModelReader(new File(modelName + modelExtension))).getModel(); sameIndex = model.getIndex(SAME);
model.eval(cg.getContext(tok, j - origStart)); String best = model.getBestOutcome(probs); tokenProb *= probs[model.getIndex(best)]; if (best.equals(TokenizerME.SPLIT)) { newTokens.add(new Span(start, j));