/** * Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); }
/** Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); next = null; }
/** * Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); next = null; }
/** * Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); }
/** * Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); next = null; }
/** * Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); }
/** * Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); }
/** * Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); }
/** * Sets this parser back to the beginning of the raw data. */ public void reset() { parser.reset(); }
/** * Sets this parser back to the beginning of the raw data. This means arranging for all relevant * state variables to be reset appropriately as well, since the value of {@link #pivot} may have * changed. * * @see #setPivot(int) **/ public void reset() { if (parser != null) parser.reset(); if (splitPolicy == SplitPolicy.sequential || splitPolicy == SplitPolicy.random) { lowerBound = pivot * (examples / K) + Math.min(pivot, examples % K); upperBound = (pivot + 1) * (examples / K) + Math.min(pivot + 1, examples % K); } if (splitPolicy == SplitPolicy.random) shuffleIndex = lowerBound; if (splitPolicy == SplitPolicy.manual) fold = 0; exampleIndex = 0; }
/** * Trains the chunker models with the specified training data * * @param parser Parser for the training data. Initialized in trainModels(String trainingData) */ public void trainModelsWithParser(Parser parser) { Chunker.isTraining = true; // Run the learner for (int i = 1; i <= iter; i++) { LinkedVector ex; while ((ex = (LinkedVector) parser.next()) != null) { for (int j = 0; j < ex.size(); j++) { chunker.learn(ex.get(j)); } } parser.reset(); chunker.doneWithRound(); logger.info("Iteration number : " + i); } chunker.doneLearning(); }
/** * Trains the chunker models with the specified training data * * @param parser Parser for the training data. Initialized in trainModels(String trainingData) */ public void trainModelsWithParser(Parser parser) { Chunker.isTraining = true; chunker.forget(); // Run the learner for (int i = 1; i <= iter; i++) { LinkedVector ex; while ((ex = (LinkedVector) parser.next()) != null) { for (int j = 0; j < ex.size(); j++) { chunker.learn(ex.get(j)); } } parser.reset(); chunker.doneWithRound(); logger.info("Iteration number : " + i); } chunker.doneLearning(); }
public static EvaluateDiscrete structuredCVal(StructuredCommaClassifier model, Parser parser, boolean useGoldFeatures, boolean testOnTrain) throws Exception { Comma.useGoldFeatures(useGoldFeatures); int k = 5; parser.reset(); FoldParser foldParser = new FoldParser(parser, k, SplitPolicy.sequential, 0, false); EvaluateDiscrete cvalResult = new EvaluateDiscrete(); for (int i = 0; i < k; foldParser.setPivot(++i)) { foldParser.setFromPivot(false); foldParser.reset(); LinkedHashSet<CommaSRLSentence> trainSentences = new LinkedHashSet<>(); for (Object comma = foldParser.next(); comma != null; comma = foldParser.next()) { trainSentences.add(((Comma) comma).getSentence()); } model.train(new ArrayList<>(trainSentences), null); if (!testOnTrain) foldParser.setFromPivot(true); foldParser.reset(); LinkedHashSet<CommaSRLSentence> testSentences = new LinkedHashSet<>(); for (Object comma = foldParser.next(); comma != null; comma = foldParser.next()) { testSentences.add(((Comma) comma).getSentence()); } EvaluateDiscrete evaluator = model.test(new ArrayList<>(testSentences), null); cvalResult.reportAll(evaluator); } cvalResult.printPerformance(System.out); return cvalResult; }
public static EvaluateDiscrete structuredCVal(StructuredCommaClassifier model, Parser parser, boolean useGoldFeatures, boolean testOnTrain) throws Exception { Comma.useGoldFeatures(useGoldFeatures); int k = 5; parser.reset(); FoldParser foldParser = new FoldParser(parser, k, SplitPolicy.sequential, 0, false); EvaluateDiscrete cvalResult = new EvaluateDiscrete(); for (int i = 0; i < k; foldParser.setPivot(++i)) { foldParser.setFromPivot(false); foldParser.reset(); LinkedHashSet<CommaSRLSentence> trainSentences = new LinkedHashSet<>(); for (Object comma = foldParser.next(); comma != null; comma = foldParser.next()) { trainSentences.add(((Comma) comma).getSentence()); } model.train(new ArrayList<>(trainSentences), null); if (!testOnTrain) foldParser.setFromPivot(true); foldParser.reset(); LinkedHashSet<CommaSRLSentence> testSentences = new LinkedHashSet<>(); for (Object comma = foldParser.next(); comma != null; comma = foldParser.next()) { testSentences.add(((Comma) comma).getSentence()); } EvaluateDiscrete evaluator = model.test(new ArrayList<>(testSentences), null); cvalResult.reportAll(evaluator); } cvalResult.printPerformance(System.out); return cvalResult; }
/** * prints Bayraktar baseline performance based on only those commas whose Bayraktar patterns * have been annotated */ public static EvaluateDiscrete getBayraktarBaselinePerformance(Parser parser, boolean testOnGold) { parser.reset(); EvaluateDiscrete bayraktarEvaluation = new EvaluateDiscrete(); Comma comma; while ((comma = (Comma) parser.next()) != null) { if (!BayraktarPatternLabeler.isLabelAvailable(comma)) continue; Comma.useGoldFeatures(true); String goldLabel = comma.getLabel(); Comma.useGoldFeatures(testOnGold); String bayraktarPrediction = comma.getBayraktarLabel(); bayraktarEvaluation.reportPrediction(bayraktarPrediction, goldLabel); } return bayraktarEvaluation; }
train_parser.reset(); BatchTrainer trainer = new BatchTrainer(classifier, train_parser); String modelFileName = ""; examples ++; train_parser.reset(); classifier.initialize(examples, preExtractLearner.getLexicon().size()); for (Object example = train_parser.next(); example != null; example = train_parser.next()){ classifier.learn(example); train_parser.reset(); classifier.doneWithRound(); classifier.doneLearning();
/** * prints Bayraktar baseline performance based on only those commas whose Bayraktar patterns * have been annotated */ public static EvaluateDiscrete getBayraktarBaselinePerformance(Parser parser, boolean testOnGold) { parser.reset(); EvaluateDiscrete bayraktarEvaluation = new EvaluateDiscrete(); Comma comma; while ((comma = (Comma) parser.next()) != null) { if (!BayraktarPatternLabeler.isLabelAvailable(comma)) continue; Comma.useGoldFeatures(true); String goldLabel = comma.getLabel(); Comma.useGoldFeatures(testOnGold); String bayraktarPrediction = comma.getBayraktarLabel(); bayraktarEvaluation.reportPrediction(bayraktarPrediction, goldLabel); } return bayraktarEvaluation; }
train_parser.reset(); BatchTrainer trainer = new BatchTrainer(classifier, train_parser); String modelFileName = ""; examples ++; train_parser.reset(); classifier.initialize(examples, preExtractLearner.getLexicon().size()); for (Object example = train_parser.next(); example != null; example = train_parser.next()){ classifier.learn(example); train_parser.reset(); classifier.doneWithRound(); classifier.doneLearning();
LocalCommaClassifier learner = new LocalCommaClassifier(); learner.setLTU(new SparseAveragedPerceptron(learningRate, threshold, thickness)); parser.reset(); final FoldParser foldParser = new FoldParser(parser, k, SplitPolicy.sequential, 0, false); EvaluateDiscrete performanceRecord = new EvaluateDiscrete();
LocalCommaClassifier learner = new LocalCommaClassifier(); learner.setLTU(new SparseAveragedPerceptron(learningRate, threshold, thickness)); parser.reset(); final FoldParser foldParser = new FoldParser(parser, k, SplitPolicy.sequential, 0, false); EvaluateDiscrete performanceRecord = new EvaluateDiscrete();