edu.cornell.cs.nlp.spf.mr.lambda.LogicalExpression Java Examples
The following examples show how to use
edu.cornell.cs.nlp.spf.mr.lambda.LogicalExpression.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SmatchStats.java From amr with GNU General Public License v2.0 | 6 votes |
@Override public void recordParsesWithSkipping(LabeledAmrSentence dataItem, List<LogicalExpression> candidates) { if (new HashSet<>(underspecified ? candidates.stream().map(AMRServices::underspecifyAndStrip) .collect(Collectors.toList()) : candidates).size() == 1) { LOG.info("%s stats -- multiple identical parses with skipping", metricName); recordParseWithSkipping(dataItem, candidates.get(0)); } else { // Reset cache. globalScore = null; globalSloppyScore = null; // Multiple parses are treated as no parses. Pair the reference AMR // with an empty one. Update both sloppy and exact lists. sloppyInferenceAmrPairs.add(pair(dataItem, EMPTY_AMR)); multipleSloppyDerivations.inc(); LOG.info("%s stats -- multiple parses, recording as no parse [%d]", metricName, sloppyInferenceAmrPairs.size()); } }
Example #2
Source File: ForwardCompositionTest.java From spf with GNU General Public License v2.0 | 6 votes |
@Test public void test() { final Category<LogicalExpression> primary = TestServices .getCategoryServices() .read("NP/N : (lambda $0:<e,t> (lambda $1:e (and:<t*,t> ($0 $1) (c_ARGX:<e,<e,t>> $1 (a:<id,<<e,t>,e>> na:id (lambda $2:e (and:<t*,t> (oppose-01:<e,t> $2) (c_ARGX:<e,<e,t>> $2 (a:<id,<<e,t>,e>> na:id (lambda $3:e (terrorism:<e,t> $3)))))))))))"); final Category<LogicalExpression> secondary = TestServices .getCategoryServices() .read("N[pl]\\(N[x]/N[x]) : (lambda $0:<<e,t>,<e,t>> (lambda $1:e (and:<t*,t> (person:<e,t> $1) (c_ARGX-of:<e,<e,t>> $1 (a:<id,<<e,t>,e>> na:id (lambda $2:e ($0 (lambda $3:e (expert-41:<e,t> $3)) $2)))))))"); final ForwardComposition<LogicalExpression> rule = new ForwardComposition<LogicalExpression>( TestServices.getCategoryServices(), 1, true); final ParseRuleResult<LogicalExpression> result = rule.apply(primary, secondary, new SentenceSpan(0, 1, 2)); Assert.assertEquals( ">xcomp1->NP\\(N[x]/N[x]) : (lambda $0:<<e,t>,<e,t>> (lambda $1:e (and:<t*,t> (person:<e,t> $1) (c_ARGX-of:<e,<e,t>> $1 (a:<id,<<e,t>,e>> na:id (lambda $2:e ($0 (lambda $3:e (expert-41:<e,t> $3)) $2)))) (c_ARGX:<e,<e,t>> $1 (a:<id,<<e,t>,e>> na:id (lambda $4:e (and:<t*,t> (oppose-01:<e,t> $4) (c_ARGX:<e,<e,t>> $4 (a:<id,<<e,t>,e>> na:id (lambda $5:e (terrorism:<e,t> $5)))))))))))", result.toString()); }
Example #3
Source File: FactoredLexicon.java From spf with GNU General Public License v2.0 | 6 votes |
/** * Get all {@link LexicalEntry}s for a given {@link LexicalTemplate}. */ private Set<LexicalEntry<LogicalExpression>> getEntries( LexicalTemplate template) { final Set<LexicalEntry<LogicalExpression>> entries = new HashSet<LexicalEntry<LogicalExpression>>(); final FactoringSignature typeSignature = template.getSignature(); if (lexemesByType.containsKey(typeSignature)) { for (final Lexeme lexeme : lexemesByType.get(typeSignature)) { final FactoredLexicalEntry entry = applyTemplate(template, lexeme); if (entry != null) { entries.add(entry); } } } return entries; }
Example #4
Source File: SloppyAmrClosureTest.java From amr with GNU General Public License v2.0 | 6 votes |
@Test public void test() { final LogicalExpression semantics = TestServices .getCategoryServices() .readSemantics( "(lambda $0:<e,t> (lambda $1:e (and:<t*,t>\n" + " ($0 $1)\n" + " (c_ARGX:<e,<e,t>> $1 \n" + " (a:<id,<<e,t>,e>> na:id (lambda $2:e (and:<t*,t>\n" + " (c_REL:<e,<e,t>> $2 \n" + " (a:<id,<<e,t>,e>> na:id (lambda $3:e (and:<t*,t>\n" + " (country:<e,t> $3)\n" + " (c_op:<e,<txt,t>> $3 United++States:txt)))))\n" + " (name:<e,t> $2))))))))"); final LogicalExpression expected = TestServices .getCategoryServices() .readSemantics( "(a:<id,<<e,t>,e>> na:id (lambda $2:e (and:<t*,t>\n" + " (c_REL:<e,<e,t>> $2 \n" + " (a:<id,<<e,t>,e>> na:id (lambda $3:e (and:<t*,t>\n" + " (country:<e,t> $3)\n" + " (c_op:<e,<txt,t>> $3 United++States:txt)))))\n" + " (name:<e,t> $2))))"); final LogicalExpression actual = SloppyAmrClosure.of(semantics); Assert.assertEquals(expected, actual); }
Example #5
Source File: LogicalExpressionCooccurrenceFeatureSet.java From spf with GNU General Public License v2.0 | 6 votes |
@Override public void setFeatures(IParseStep<LogicalExpression> parseStep, IHashVector feats, DI dataItem) { if (!parseStep.isFullParse()) { // Only generate logical expression features of the final logical // format return; } // Generate deep semantic features final IHashVector features = ExtractFeatures .of(parseStep.getRoot().getSemantics(), 1.0); if (feats != null) { features.addTimesInto(1.0, feats); } }
Example #6
Source File: OnlineLearner.java From amr with GNU General Public License v2.0 | 6 votes |
protected OnlineLearner(int numIterations, IDataCollection<LabeledAmrSentence> trainingData, int maxSentenceLength, GraphAmrParser parser, IJointOutputLogger<LogicalExpression, LogicalExpression, LogicalExpression> parserOutputLogger, ICategoryServices<LogicalExpression> categoryServices, ILexiconGeneratorPrecise<LabeledAmrSentence, LogicalExpression, IJointModelImmutable<SituatedSentence<AMRMeta>, LogicalExpression, LogicalExpression>> genlex, IJointInferenceFilterFactory<LabeledAmrSentence, LogicalExpression, LogicalExpression, LogicalExpression> filterFactory, IntConsumer postIteration, boolean sortData, IWeightUpdateProcedure estimator, IGradientFunction gradientFunction, Integer conditionedInferenceBeam, boolean resumeLearning) { super(numIterations, trainingData, maxSentenceLength, parser, parserOutputLogger, categoryServices, genlex, filterFactory, postIteration, sortData, estimator, gradientFunction, conditionedInferenceBeam, resumeLearning); }
Example #7
Source File: ClosureFeature.java From amr with GNU General Public License v2.0 | 6 votes |
@Override public List<Runnable> createFactorJobs(FactorGraph graph, AMRMeta meta, IJointDataItemModel<LogicalExpression, LogicalExpression> model) { if (graph.isClosure()) { final IBaseNode root = graph.getRoot(); if (root instanceof LiteralNode && AMRServices.isSkolemTerm(root.getExpression()) && ((LiteralNode) root).getArgs().size() == 2 && ((LiteralNode) root).getArgs() .get(0) instanceof SkolemIdNode) { return ListUtils .createSingletonList(() -> FactorGraphFeatureServices .addFactor((values, nodes) -> { // Closure feature. final IHashVector features = HashVectorFactory .create(); features.set(FEATURE_TAG, 1.0); return features; } , model, FEATURE_TAG, ((LiteralNode) root).getArgs().get(0))); } } return Collections.emptyList(); }
Example #8
Source File: GetAlignedSubExpTest.java From amr with GNU General Public License v2.0 | 6 votes |
@Test public void test() { final LogicalExpression semantics = TestServices.getCategoryServices() .readSemantics( "(a:<id,<<e,t>,e>> !1 (lambda $0:e (and:<t*,t>\n" + " (date-entity:<e,t> $0)\n" + " (c_year:<e,<i,t>> $0 2002:i)\n" + " (c_month:<e,<i,t>> $0 1:i)\n" + " (c_day:<e,<i,t>> $0 5:i))))"); final String indexSet = "0+0.0+0.1+0.2"; final LogicalExpression expected = TestServices.getCategoryServices() .readSemantics( "(a:<id,<<e,t>,e>> !1 (lambda $0:e (and:<t*,t>\n" + " (date-entity:<e,t> $0)\n" + " (c_year:<e,<i,t>> $0 2002:i)\n" + " (c_month:<e,<i,t>> $0 1:i)\n" + " (c_day:<e,<i,t>> $0 5:i))))"); final LogicalExpression actual = GetAlignedSubExp.of(semantics, indexSet); Assert.assertEquals(expected, actual); }
Example #9
Source File: AMRServices.java From amr with GNU General Public License v2.0 | 5 votes |
public static boolean isSkolemPredicate(LogicalExpression exp) { if (exp instanceof LogicalConstant && ((LogicalConstant) exp) .getBaseName().equals(INSTANCE.skolemPredicateBaseName)) { // Get return type, create a skolem predicate for it and compare. return exp .equals(createSkolemPredicate(getFinalType(exp.getType()))); } return false; }
Example #10
Source File: ExecOutput.java From amr with GNU General Public License v2.0 | 5 votes |
@Override public List<IExecution<LogicalExpression>> getExecutions( IFilter<LogicalExpression> filter) { return output.getDerivations().stream().map((derivation) -> { return new Execution(derivation, model); }).filter((execuction) -> filter.test(execuction.getResult())) .collect(Collectors.toList()); }
Example #11
Source File: AMRServices.java From amr with GNU General Public License v2.0 | 5 votes |
public static boolean isRefPredicate(LogicalExpression exp) { if (exp instanceof LogicalConstant && ((LogicalConstant) exp) .getBaseName().equals(INSTANCE.refPredicateBaseName)) { // Get return type, create a skolem predicate for it and compare. return exp.equals(createRefPredicate(getFinalType(exp.getType()))); } return false; }
Example #12
Source File: ThatlessRelative.java From spf with GNU General Public License v2.0 | 5 votes |
public ThatlessRelative( ICategoryServices<LogicalExpression> categoryServices) { super(RULE_LABEL, Direction.FORWARD, categoryServices); this.workerCategoryForwardSlash = (ComplexCategory<LogicalExpression>) categoryServices .read("N/(S/NP)/N : (lambda $0:<e,t> (lambda $1:<e,t> (lambda $2:e (and:<t*,t> ($0 $2) ($1 $2)))))"); this.workerCategoryBackSlash = (ComplexCategory<LogicalExpression>) categoryServices .read("N/(S\\NP)/N : (lambda $0:<e,t> (lambda $1:<e,t> (lambda $2:e (and:<t*,t> ($0 $2) ($1 $2)))))"); }
Example #13
Source File: PrepositionTypeShifting.java From spf with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public PrepositionTypeShifting create(Parameters params, IResourceRepository repo) { return new PrepositionTypeShifting( (ICategoryServices<LogicalExpression>) repo .get(ParameterizedExperiment.CATEGORY_SERVICES_RESOURCE)); }
Example #14
Source File: SentenceWithDummy.java From amr with GNU General Public License v2.0 | 5 votes |
public SentenceWithDummy( ICategoryServices<LogicalExpression> categoryServices) { this.categoryServices = categoryServices; this.name = UnaryRuleName.create(LABEL); this.targetSyntax = Syntax.read("S[x]\\S[x]"); this.sourceSyntax = Syntax.read("S[dcl]"); this.helperCategory = categoryServices .readSemantics("(lambda $2:<e,<e,t>> (lambda $3:<e,t> (lambda $0:<e,t> (lambda $1:e (and:<t*,t> ($0 $1) ($2 $1 (a:<id,<<e,t>,e>> na:id $3)))))))"); }
Example #15
Source File: AToExistsTest.java From spf with GNU General Public License v2.0 | 5 votes |
@Test public void test8() { final LogicalExpression exp = LogicalExpression .read("(fun:<e,e> (a:<<e,t>,e> (lambda $0:e (pred:<e,t> $0))))"); final LogicalExpression result = LogicalExpression .read("(lambda $1:e (exists:<<e,t>,t> (lambda $0:e (and:<t*,t> (pred:<e,t> $0) (eq:<e,<e,t>> $1 (fun:<e,e> $0)))))))"); final LogicalExpression out = AToExists.of(exp, existsPredicate, aPredicate, equalsPredicates); Assert.assertEquals(Simplify.of(result), out); }
Example #16
Source File: LogicalExpressionEqualsTest.java From spf with GNU General Public License v2.0 | 5 votes |
@Test public void test8() { final LogicalExpression e1 = LogicalExpression .read("(lambda $0:e (exists:<<e,t>,t> (lambda $1:e (and:<t*,t> (place:<p,t> $1) (exists:<<e,t>,t> (lambda $2:e (and:<t*,t> (state:<s,t> $2) (loc:<lo,<lo,t>> $2 $2)))) (equals:<e,<e,t>> $0 $1)))))"); final LogicalExpression e2 = LogicalExpression .read("(lambda $0:e (exists:<<e,t>,t> (lambda $1:e (and:<t*,t> (place:<p,t> $1) (exists:<<e,t>,t> (lambda $2:e (and:<t*,t> (state:<s,t> $2) (loc:<lo,<lo,t>> $2 $1)))) (equals:<e,<e,t>> $0 $1)))))"); Assert.assertFalse(e1.equals(e2)); }
Example #17
Source File: SingleSentenceLexDataset.java From spf with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public SingleSentenceLexDataset create(Parameters params, IResourceRepository repo) { return SingleSentenceLexDataset .read(params.getAsFile("file"), new StubStringFilter(), (ICategoryServices<LogicalExpression>) repo .get(ParameterizedExperiment.CATEGORY_SERVICES_RESOURCE), params.get("origin"), (ITokenizer) (params.contains("tokenizer") ? repo.get(params.get("tokenizer")) : null)); }
Example #18
Source File: GetApplicationArgumentTest.java From spf with GNU General Public License v2.0 | 5 votes |
@Test public void test4() { final LogicalExpression result = TestServices.getCategoryServices() .readSemantics( "(lambda $1:e (lambda $2:e (a:<t,e> (boo:<e,<e,t>> $2 $1))))"); final LogicalExpression function = TestServices.getCategoryServices() .readSemantics( "(lambda $0:<e,<e,t>> (lambda $1:e (lambda $2:e (a:<t,e> ($0 $1 $2)))))"); final LogicalExpression expectedArgument = TestServices .getCategoryServices().readSemantics( "(lambda $0:e (lambda $1:e (boo:<e,<e,t>> $1 $0)))"); Assert.assertEquals(expectedArgument, GetApplicationArgument.of(function, result)); }
Example #19
Source File: GetMaxEvaluations.java From amr with GNU General Public License v2.0 | 5 votes |
@Override public void visit(LiteralNode node) { node.getPredicate().accept(this); final List<Pair<LogicalExpression, Map<INode, LogicalExpression>>> predicateMaxes = maxes; int numAssignments = predicateMaxes.size(); final List<List<Pair<LogicalExpression, Map<INode, LogicalExpression>>>> argMaxes = new ArrayList<>( node.getArgs().size()); for (final IBaseNode argNode : node.getArgs()) { argNode.accept(this); numAssignments *= maxes.size(); if (numAssignments == 0 || numAssignments > limit) { LOG.debug("Too many evaluation for: %s", node); maxes = Collections.emptyList(); return; } argMaxes.add(maxes); } // Create the max literal assignments. maxes = new LinkedList<>(); for (final Pair<LogicalExpression, Map<INode, LogicalExpression>> predicate : predicateMaxes) { for (final List<Pair<LogicalExpression, Map<INode, LogicalExpression>>> argPairs : CollectionUtils .cartesianProduct(argMaxes)) { final Map<INode, LogicalExpression> mapping = new HashMap<>( predicate.second()); final LogicalExpression[] args = new LogicalExpression[argPairs .size()]; for (int i = 0; i < args.length; ++i) { final Pair<LogicalExpression, Map<INode, LogicalExpression>> pair = argPairs .get(i); mapping.putAll(pair.second()); args[i] = pair.first(); } maxes.add(Pair.of(new Literal(predicate.first(), args), mapping)); } } }
Example #20
Source File: SkolemIdInstanceWrapper.java From spf with GNU General Public License v2.0 | 5 votes |
@Override public boolean equals(LogicalExpression exp, ScopeMapping<Variable, Variable> mapping) { if (exp instanceof SkolemIdInstanceWrapper) { return base == ((SkolemIdInstanceWrapper) exp).base; } else { return base == exp; } }
Example #21
Source File: DatesGeneratorTest.java From amr with GNU General Public License v2.0 | 5 votes |
@Test public void test3() { final Set<LexicalEntry<LogicalExpression>> lexicon = gen .generateLexicon(create("01-09-11")); Assert.assertTrue(lexicon.contains(LexicalEntry .read("01-09-11 :- NP[sg] : (a:<id,<<e,t>,e>> na:id (lambda $0:e (and:<t*,t> (date-entity:<e,t> $0) (c_year:<e,<i,t>> $0 1901:i) (c_month:<e,<i,t>> $0 9:i) (c_day:<e,<i,t>> $0 11:i))))", TestServices.getCategoryServices(), "dummy"))); Assert.assertTrue(lexicon.contains(LexicalEntry .read("01-09-11 :- NP[sg] : (a:<id,<<e,t>,e>> na:id (lambda $0:e (and:<t*,t> (date-entity:<e,t> $0) (c_year:<e,<i,t>> $0 2001:i) (c_month:<e,<i,t>> $0 9:i) (c_day:<e,<i,t>> $0 11:i))))", TestServices.getCategoryServices(), "dummy"))); }
Example #22
Source File: GetApplicationArgumentTest.java From spf with GNU General Public License v2.0 | 5 votes |
@Test public void test28() { final LogicalExpression result = TestServices.getCategoryServices() .readSemantics( "(lambda $0:e (lambda $1:e (and:<t*,t> (c_ARG0:<e,<e,t>> $1 $0) (c_ARG1:<e,t> $1))))"); final LogicalExpression function = TestServices.getCategoryServices() .readSemantics( "(lambda $0:<e,t> (lambda $1:e (lambda $2:e (and:<t*,t> ($0 $2) (c_ARG0:<e,<e,t>> $2 $1)))))"); final LogicalExpression expectedArg = TestServices.getCategoryServices() .readSemantics("(lambda $0:e (c_ARG1:<e,t> $0))"); Assert.assertEquals(expectedArg, GetApplicationArgument.of(function, result)); }
Example #23
Source File: LogicalExpressionCategoryServicesTest.java From spf with GNU General Public License v2.0 | 5 votes |
@Test public void compose5() { final LogicalExpression f = TestServices.getCategoryServices() .readSemantics("(lambda $0:t (and:<t*,t> true:t $0))"); final LogicalExpression g = TestServices.getCategoryServices() .readSemantics("g:<e,t>"); final LogicalExpression expected = TestServices.getCategoryServices() .readSemantics("(lambda $0:e (g:<e,t> $0))"); final LogicalExpressionCategoryServices cs = new LogicalExpressionCategoryServices(); final LogicalExpression result = cs.compose(f, g, 1); assertTrue(String.format("Expected: %s\nGot: %s", expected, result), expected.equals(result)); }
Example #24
Source File: AToExistsTest.java From spf with GNU General Public License v2.0 | 5 votes |
@Test public void test2() { final LogicalExpression exp = LogicalExpression .read("(lambda $0:e (to:<e,<e,t>> $0 (a:<<e,t>,e> (lambda $1:e (and:<t*,t> (chair:<e,t> $1) (intersect:<e,<e,t>> $1 (a:<<e,t>,e> (lambda $2:e (corner:<e,t> $2)))))))))"); final LogicalExpression result = LogicalExpression .read("(lambda $0:e (exists:<<e,t>,t> (lambda $1:e (and:<t*,t> (to:<e,<e,t>> $0 $1) (chair:<e,t> $1) (exists:<<e,t>,t> (lambda $2:e (and:<t*,t> (intersect:<e,<e,t>> $1 $2) (corner:<e,t> $2))))))))"); final LogicalExpression out = AToExists.of(exp, existsPredicate, aPredicate, equalsPredicates); Assert.assertEquals(result, out); }
Example #25
Source File: AbstractAmrParserOutput.java From amr with GNU General Public License v2.0 | 5 votes |
@Override public List<DERIV> getMaxDerivations(IFilter<LogicalExpression> filter) { switch (inferenceMethod) { case NONE: case BEAM: final List<DERIV> filtered = jointDerivations.stream() .filter(d -> filter.test(d.getResult())) .collect(Collectors.toList()); final List<DERIV> maxScoring = new LinkedList<>(); final double maxScore = -Double.MAX_VALUE; for (final DERIV derivation : filtered) { final double score = derivation.getViterbiScore(); if (score == maxScore) { maxScoring.add(derivation); } else if (score > maxScore) { maxScoring.clear(); maxScoring.add(derivation); } } return maxScoring; case LBP: throw new IllegalStateException( "Max-scoring derivation filtering is not possible with AMR LBP inference since we can't enumerate parses and the filter doesn't decompose"); default: throw new IllegalStateException( "Unknown inference method: " + inferenceMethod); } }
Example #26
Source File: PreciseGenlexWrapper.java From amr with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") protected void addRule(Object rule, List<IBinaryReversibleParseRule<LogicalExpression>> binaryRules, List<IUnaryReversibleParseRule<LogicalExpression>> unaryRules) { if (rule instanceof IBinaryReversibleParseRule) { binaryRules.add( (IBinaryReversibleParseRule<LogicalExpression>) rule); } else if (rule instanceof IUnaryReversibleParseRule) { unaryRules.add( (IUnaryReversibleParseRule<LogicalExpression>) rule); } else { throw new IllegalArgumentException( "Invalid rule class: " + rule); } }
Example #27
Source File: GetAllSkolemTerms.java From amr with GNU General Public License v2.0 | 5 votes |
/** * @param shallow * Don't visit extract skolem terms. */ public static Set<LogicalExpression> of(LogicalExpression exp, boolean shallow) { final GetAllSkolemTerms visitor = new GetAllSkolemTerms(shallow); visitor.visit(exp); return visitor.skolemTerms; }
Example #28
Source File: AbstractAmrParser.java From amr with GNU General Public License v2.0 | 5 votes |
/** * Do LBP inference for the factor graph and extract the * {@link EvaluationResult}s. * * * @return Pair with list of {@link EvaluationResult} and an inference flag * (if the flag is 'true', there were too many max-scoring * evaluations and none were returned). */ private Pair<List<EvaluationResult>, Boolean> doLoopyBPInference( FactorGraph graph, IJointDataItemModel<LogicalExpression, LogicalExpression> model, boolean sloppyInference) { // Loopy BP inference LoopyBP.of(graph, bpConvergenceThreshold, bpMaxIterations, bpMaxTime); // Get the max configurations. final List<EvaluationResult> argmax = new LinkedList<>( GetMaxEvaluations.of(graph, maxLimit, model, sloppyInference)); return Pair.of(argmax, !argmax.isEmpty()); }
Example #29
Source File: AmrExp.java From amr with GNU General Public License v2.0 | 5 votes |
private Job createGradientCheckJob(Parameters params) throws FileNotFoundException { // The model to use. final JointModel<SituatedSentence<AMRMeta>, LogicalExpression, LogicalExpression> model = get( params.get("model")); // The gradient checker. final GradientChecker checker = get(params.get("checker")); return new Job(params.get("id"), new HashSet<>(params.getSplit("dep")), this, createJobOutputFile(params.get("id")), createJobLogFile(params.get("id"))) { @Override protected void doJob() { final long startTime = System.currentTimeMillis(); // Start job LOG.info("============ (Job %s started)", getId()); // Do the gradient checking. checker.check(model); // Output total run time LOG.info("Total run time %.4f seconds", (System.currentTimeMillis() - startTime) / 1000.0); // Job completed LOG.info("============ (Job %s completed)", getId()); } }; }
Example #30
Source File: GeoExp.java From spf with GNU General Public License v2.0 | 5 votes |
@SuppressWarnings("unchecked") private Job createTrainJob(Parameters params) throws FileNotFoundException { // The model to use final Model<Sentence, LogicalExpression> model = (Model<Sentence, LogicalExpression>) get(params .get("model")); // The learning final ILearner<Sentence, SingleSentence, Model<Sentence, LogicalExpression>> learner = (ILearner<Sentence, SingleSentence, Model<Sentence, LogicalExpression>>) get(params .get("learner")); return new Job(params.get("id"), new HashSet<String>( params.getSplit("dep")), this, createJobOutputFile(params.get("id")), createJobLogFile(params.get("id"))) { @Override protected void doJob() { final long startTime = System.currentTimeMillis(); // Start job LOG.info("============ (Job %s started)", getId()); // Do the learning learner.train(model); // Log the final model LOG.info("Final model:\n%s", model); // Output total run time LOG.info("Total run time %.4f seconds", (System.currentTimeMillis() - startTime) / 1000.0); // Job completed LOG.info("============ (Job %s completed)", getId()); } }; }