andThen ( )源码实例Demo

java.util.function.IntConsumer#andThen ( )源码实例Demo

下面列出了java.util.function.IntConsumer#andThen ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: j2objc   文件: IntConsumerTest.java
public void testAndThen_null() throws Exception {
  IntConsumer one = s -> {};
  try {
    one.andThen(null);
    fail();
  } catch (NullPointerException expected) {}
}
 
源代码2 项目: amr   文件: HybridBatchLearner.java
@Override
public HybridBatchLearner create(Parameters params,
		IResourceRepository repo) {

	final IDataCollection<LabeledAmrSentence> trainingData = repo
			.get(params.get("data"));
	final int numIterations = params.getAsInteger("iter");
	final int maxSentenceLength = params
			.getAsInteger("maxSentenceLength", Integer.MAX_VALUE);
	final boolean sortData = params.getAsBoolean("sortData", false);

	final ICategoryServices<LogicalExpression> categoryServices;
	final ILexiconGeneratorPrecise<LabeledAmrSentence, LogicalExpression, IJointModelImmutable<SituatedSentence<AMRMeta>, LogicalExpression, LogicalExpression>> genlex;
	if (params.contains("genlex")) {
		genlex = repo.get(params.get("genlex"));
		categoryServices = repo.get(
				ParameterizedExperiment.CATEGORY_SERVICES_RESOURCE);
	} else {
		genlex = null;
		categoryServices = null;
	}

	final IJointOutputLogger<LogicalExpression, LogicalExpression, LogicalExpression> parserOutputLogger;
	if (params.contains("parseLogger")) {
		parserOutputLogger = repo.get(params.get("parseLogger"));
	} else {
		parserOutputLogger = null;
	}

	final IJointInferenceFilterFactory<LabeledAmrSentence, LogicalExpression, LogicalExpression, LogicalExpression> filterFactory;
	if (params.contains("filterFactory")) {
		filterFactory = repo.get(params.get("filterFactory"));
	} else {
		filterFactory = new IJointInferenceFilterFactory<LabeledAmrSentence, LogicalExpression, LogicalExpression, LogicalExpression>() {
			private static final long serialVersionUID = 5208726408785946328L;

			@Override
			public Predicate<ParsingOp<LogicalExpression>> create(
					LabeledAmrSentence object) {
				return JointInferenceFilterUtils.stubTrue();
			}

			@Override
			public IJointInferenceFilter<LogicalExpression, LogicalExpression, LogicalExpression> createJointFilter(
					LabeledAmrSentence ibj) {
				return JointInferenceFilterUtils.stubTrue();
			}
		};

	}

	IntConsumer postIteration = (i) -> {
		return;
	};
	for (final String id : params.getSplit("postIteration")) {
		postIteration = postIteration.andThen(repo.get(id));
	}

	final BiFunction<Predicate<LexicalEntry<LogicalExpression>>, Map<LexicalEntry<LogicalExpression>, Double>, Set<LexicalEntry<LogicalExpression>>> votingProcedure;
	if (params.contains("voter")) {
		votingProcedure = repo.get(params.get("voter"));
	} else {
		votingProcedure = new StubVoting();
	}

	Integer conditionedInferenceBeam;
	if (params.contains("conditionedBeam")) {
		conditionedInferenceBeam = params
				.getAsInteger("conditionedBeam");
	} else {
		conditionedInferenceBeam = null;
	}

	final ILexiconGenerator<LabeledAmrSentence, LogicalExpression, IJointModelImmutable<SituatedSentence<AMRMeta>, LogicalExpression, LogicalExpression>> alignmentGenlex;
	if (params.contains("alignGenlex")) {
		alignmentGenlex = repo.get(params.get("alignGenlex"));
	} else {
		alignmentGenlex = null;
	}

	final ILexiconImmutable<LogicalExpression> keepEntries;
	if (params.contains("keepEntries")) {
		keepEntries = repo.get(params.get("keepEntries"));
	} else {
		keepEntries = new Lexicon<>();
	}

	return new HybridBatchLearner(numIterations, trainingData, sortData,
			maxSentenceLength,
			repo.get(ParameterizedExperiment.PARSER_RESOURCE),
			parserOutputLogger, categoryServices, genlex, filterFactory,
			postIteration, params.getAsBoolean("prune", false),
			votingProcedure,
			repo.<IWeightUpdateProcedure> get(params.get("estimator")),
			repo.get(params.get("gradient")), conditionedInferenceBeam,
			alignmentGenlex, params.getAsBoolean("resume", false),
			keepEntries);
}
 
源代码3 项目: amr   文件: DistributeMiniBatchLearner.java
@Override
public DistributeMiniBatchLearner create(Parameters params,
		IResourceRepository repo) {

	final IDataCollection<LabeledAmrSentence> trainingData = repo
			.get(params.get("data"));
	final int numIterations = params.getAsInteger("iter");
	final int maxSentenceLength = params
			.getAsInteger("maxSentenceLength", Integer.MAX_VALUE);
	final boolean sortData = params.getAsBoolean("sortData", false);

	final ICategoryServices<LogicalExpression> categoryServices;
	final ILexiconGeneratorPrecise<LabeledAmrSentence, LogicalExpression, IJointModelImmutable<SituatedSentence<AMRMeta>, LogicalExpression, LogicalExpression>> genlex;
	if (params.contains("genlex")) {
		genlex = repo.get(params.get("genlex"));
		categoryServices = repo.get(
				ParameterizedExperiment.CATEGORY_SERVICES_RESOURCE);
	} else {
		genlex = null;
		categoryServices = null;
	}

	final IJointOutputLogger<LogicalExpression, LogicalExpression, LogicalExpression> parserOutputLogger;
	if (params.contains("parseLogger")) {
		parserOutputLogger = repo.get(params.get("parseLogger"));
	} else {
		parserOutputLogger = null;
	}

	final IJointInferenceFilterFactory<LabeledAmrSentence, LogicalExpression, LogicalExpression, LogicalExpression> filterFactory;
	if (params.contains("filterFactory")) {
		filterFactory = repo.get(params.get("filterFactory"));
	} else {
		filterFactory = new IJointInferenceFilterFactory<LabeledAmrSentence, LogicalExpression, LogicalExpression, LogicalExpression>() {
			private static final long serialVersionUID = -8410588783722286647L;

			@Override
			public Predicate<ParsingOp<LogicalExpression>> create(
					LabeledAmrSentence object) {
				return JointInferenceFilterUtils.stubTrue();
			}

			@Override
			public IJointInferenceFilter<LogicalExpression, LogicalExpression, LogicalExpression> createJointFilter(
					LabeledAmrSentence ibj) {
				return JointInferenceFilterUtils.stubTrue();
			}
		};

	}

	IntConsumer postIteration = (i) -> {
		return;
	};
	for (final String id : params.getSplit("postIteration")) {
		postIteration = postIteration.andThen(repo.get(id));
	}

	final BiFunction<Predicate<LexicalEntry<LogicalExpression>>, Map<LexicalEntry<LogicalExpression>, Double>, Set<LexicalEntry<LogicalExpression>>> votingProcedure;
	if (params.contains("voter")) {
		votingProcedure = repo.get(params.get("voter"));
	} else {
		votingProcedure = new StubVoting();
	}

	Integer conditionedInferenceBeam;
	if (params.contains("conditionedBeam")) {
		conditionedInferenceBeam = params
				.getAsInteger("conditionedBeam");
	} else {
		conditionedInferenceBeam = null;
	}

	final ILexiconGenerator<LabeledAmrSentence, LogicalExpression, IJointModelImmutable<SituatedSentence<AMRMeta>, LogicalExpression, LogicalExpression>> alignmentGenlex;
	if (params.contains("alignGenlex")) {
		alignmentGenlex = repo.get(params.get("alignGenlex"));
	} else {
		alignmentGenlex = null;
	}

	final ILexiconImmutable<LogicalExpression> keepEntries;
	if (params.contains("keepEntries")) {
		keepEntries = repo.get(params.get("keepEntries"));
	} else {
		keepEntries = new Lexicon<>();
	}

	return new DistributeMiniBatchLearner(numIterations, trainingData,
			sortData, maxSentenceLength,
			repo.get(ParameterizedExperiment.PARSER_RESOURCE),
			parserOutputLogger, categoryServices, genlex, filterFactory,
			postIteration, params.getAsBoolean("prune", false),
			votingProcedure, repo.get(params.get("manager")),
			params.getAsInteger("batch"),
			repo.get(params.get("estimator")),
			repo.get(params.get("gradient")), conditionedInferenceBeam,
			alignmentGenlex, params.getAsBoolean("resume", false),
			keepEntries);
}
 
源代码4 项目: amr   文件: HybridDistributedBatchLearner.java
@Override
public HybridDistributedBatchLearner create(Parameters params,
		IResourceRepository repo) {

	final IDataCollection<LabeledAmrSentence> trainingData = repo
			.get(params.get("data"));
	final int numIterations = params.getAsInteger("iter");
	final int maxSentenceLength = params
			.getAsInteger("maxSentenceLength", Integer.MAX_VALUE);
	final boolean sortData = params.getAsBoolean("sortData", false);

	final ICategoryServices<LogicalExpression> categoryServices;
	final ILexiconGeneratorPrecise<LabeledAmrSentence, LogicalExpression, IJointModelImmutable<SituatedSentence<AMRMeta>, LogicalExpression, LogicalExpression>> genlex;
	if (params.contains("genlex")) {
		genlex = repo.get(params.get("genlex"));
		categoryServices = repo.get(
				ParameterizedExperiment.CATEGORY_SERVICES_RESOURCE);
	} else {
		genlex = null;
		categoryServices = null;
	}

	final IJointOutputLogger<LogicalExpression, LogicalExpression, LogicalExpression> parserOutputLogger;
	if (params.contains("parseLogger")) {
		parserOutputLogger = repo.get(params.get("parseLogger"));
	} else {
		parserOutputLogger = null;
	}

	final IJointInferenceFilterFactory<LabeledAmrSentence, LogicalExpression, LogicalExpression, LogicalExpression> filterFactory;
	if (params.contains("filterFactory")) {
		filterFactory = repo.get(params.get("filterFactory"));
	} else {
		filterFactory = new IJointInferenceFilterFactory<LabeledAmrSentence, LogicalExpression, LogicalExpression, LogicalExpression>() {
			private static final long serialVersionUID = -8410588783722286647L;

			@Override
			public Predicate<ParsingOp<LogicalExpression>> create(
					LabeledAmrSentence object) {
				return JointInferenceFilterUtils.stubTrue();
			}

			@Override
			public IJointInferenceFilter<LogicalExpression, LogicalExpression, LogicalExpression> createJointFilter(
					LabeledAmrSentence ibj) {
				return JointInferenceFilterUtils.stubTrue();
			}
		};

	}

	IntConsumer postIteration = (i) -> {
		return;
	};
	for (final String id : params.getSplit("postIteration")) {
		postIteration = postIteration.andThen(repo.get(id));
	}

	final BiFunction<Predicate<LexicalEntry<LogicalExpression>>, Map<LexicalEntry<LogicalExpression>, Double>, Set<LexicalEntry<LogicalExpression>>> votingProcedure;
	if (params.contains("voter")) {
		votingProcedure = repo.get(params.get("voter"));
	} else {
		votingProcedure = new StubVoting();
	}

	Integer conditionedInferenceBeam;
	if (params.contains("conditionedBeam")) {
		conditionedInferenceBeam = params
				.getAsInteger("conditionedBeam");
	} else {
		conditionedInferenceBeam = null;
	}

	final ILexiconGenerator<LabeledAmrSentence, LogicalExpression, IJointModelImmutable<SituatedSentence<AMRMeta>, LogicalExpression, LogicalExpression>> alignmentGenlex;
	if (params.contains("alignGenlex")) {
		alignmentGenlex = repo.get(params.get("alignGenlex"));
	} else {
		alignmentGenlex = null;
	}

	final ILexiconImmutable<LogicalExpression> keepEntries;
	if (params.contains("keepEntries")) {
		keepEntries = repo.get(params.get("keepEntries"));
	} else {
		keepEntries = new Lexicon<>();
	}

	return new HybridDistributedBatchLearner(numIterations,
			trainingData, sortData, maxSentenceLength,
			repo.get(ParameterizedExperiment.PARSER_RESOURCE),
			parserOutputLogger, categoryServices, genlex, filterFactory,
			postIteration, params.getAsBoolean("prune", false),
			votingProcedure, repo.get(params.get("manager")),
			repo.get(params.get("estimator")),
			repo.get(params.get("gradient")), conditionedInferenceBeam,
			alignmentGenlex, params.getAsBoolean("resume", false),
			keepEntries);
}
 
源代码评论
动弹
沙发等你来抢
 同类方法