本文整理汇总了Java中play.inject.Injector.instanceOf方法的典型用法代码示例。如果您正苦于以下问题:Java Injector.instanceOf方法的具体用法?Java Injector.instanceOf怎么用?Java Injector.instanceOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.inject.Injector
的用法示例。
在下文中一共展示了Injector.instanceOf方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPredictorConfig
import play.inject.Injector; //导入方法依赖的package包/类
public static PredictorConfig getPredictorConfig(Configuration predictorConfig,
Injector injector) {
FeaturizerConfigParser parser = injector.instanceOf(
FeatureExtractorListConfigParser.class);
Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENTITY_DAOS_CONFIG.get());
List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig
.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(predictorConfig);
double alpha = 0.1;
if (predictorConfig.asMap().containsKey("alpha")) {
alpha = predictorConfig.getDouble("alpha");
}
double lambda = 1.0;
if (predictorConfig.asMap().containsKey("lambda")) {
lambda = predictorConfig.getDouble("lambda");
}
return new LinearUCBPredictorConfig(predictorConfig.getString("modelName"),
feaExtConfigs, predictorConfig.getStringList("features"),
predictorConfig.getInt("numMainFeatures"),
predictorConfig.getString("labelName"),
predictorConfig.getString("weightName"), daoConfigs, expanders, injector,
predictorConfig.getConfig("onlineOptimizationMethod"),
predictorConfig.getString("modelFile"),
predictorConfig.getString("daoConfigKey"), lambda, alpha,
predictorConfig.getStringList("evaluatorNames"), predictorConfig);
}
示例2: getPredictorConfig
import play.inject.Injector; //导入方法依赖的package包/类
public static PredictorConfig getPredictorConfig(Configuration predictorConfig,
Injector injector) {
FeaturizerConfigParser parser = injector.instanceOf(
FeatureExtractorListConfigParser.class);
Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENTITY_DAOS_CONFIG.get());
List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig
.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(predictorConfig);
int maxIter = predictorConfig.getInt("maxNumTrees");
StandardBoostingMethod boostingMethod = new StandardBoostingMethod(maxIter);
return new GBDTPredictorConfig(predictorConfig.getString("modelName"),
feaExtConfigs, predictorConfig.getStringList("features"),
predictorConfig.getString("labelName"),
predictorConfig.getString("weightName"), daoConfigs, expanders, injector,
injector.instanceOf(TreeLearningMethod.class),
predictorConfig.getStringList("groupKeys"),
predictorConfig.getString("modelFile"),
predictorConfig.getConfig("objectiveConfig"), boostingMethod,
predictorConfig.getString("daoConfigKey"),
predictorConfig);
}
示例3: getPredictorConfig
import play.inject.Injector; //导入方法依赖的package包/类
public static PredictorConfig getPredictorConfig(Configuration predictorConfig,
Injector injector) {
FeaturizerConfigParser parser = injector.instanceOf(
FeatureExtractorListConfigParser.class);
Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENTITY_DAOS_CONFIG.get());
List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(predictorConfig);
List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig
.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
return new RegressionTreePredictorConfig(predictorConfig.getString("modelName"),
feaExtConfigs, predictorConfig.getStringList("features"),
predictorConfig.getString("labelName"),
predictorConfig.getString("weightName"), daoConfigs, expanders, injector,
injector.instanceOf(TreeLearningMethod.class),
predictorConfig.getString("modelFile"),
predictorConfig.getString("daoConfigKey"), predictorConfig);
}
示例4: beforeStart
import play.inject.Injector; //导入方法依赖的package包/类
public void beforeStart(Application application) {
Injector injector = application.injector();
Configuration configuration = application.configuration();
SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.class);
List<String> enabledEngines = configuration.getStringList(ConfigKey.ENGINES_ENABLED.get());
Configuration samanthaConfig = configuration.getConfig(ConfigKey.SAMANTHA_BASE.get());
for (String engine : enabledEngines) {
Configuration engineConfig = samanthaConfig.getConfig(engine);
List<String> schedulerNames = engineConfig.getStringList(ConfigKey.ENGINE_BEFORE_START_SCHEDULERS.get());
if (schedulerNames != null) {
for (String scheduler : schedulerNames) {
RequestContext peudoReq = new RequestContext(Json.newObject(), engine);
configService.getSchedulerConfig(scheduler, peudoReq).runJobs();
}
}
}
}
示例5: getIndexerConfig
import play.inject.Injector; //导入方法依赖的package包/类
static public IndexerConfig getIndexerConfig(Configuration indexerConfig,
Injector injector) {
ElasticSearchService elasticSearchService = injector
.instanceOf(ElasticSearchService.class);
String elasticSearchIndex = indexerConfig.getString("elasticSearchIndex");
Configuration settingConfig = indexerConfig.getConfig("elasticSearchSetting");
if (!elasticSearchService.existsIndex(elasticSearchIndex).isExists()) {
elasticSearchService.createIndex(elasticSearchIndex, settingConfig);
}
Configuration mappingConfig = indexerConfig.getConfig("elasticSearchMapping");
for (String typeName : mappingConfig.subKeys()) {
if (!elasticSearchService.existsType(elasticSearchIndex, typeName)
.isExists()) {
elasticSearchService.putMapping(elasticSearchIndex, typeName,
mappingConfig.getConfig(typeName));
}
}
return new ESBasedIndexerConfig(indexerConfig.getConfig(ConfigKey.ENTITY_DAOS_CONFIG.get()),
elasticSearchIndex, indexerConfig.getString("indexTypeKey"),
indexerConfig.getString("indexType"),
indexerConfig.getStringList("uniqueFields"),
injector, indexerConfig.getString("daoConfigKey"),
indexerConfig);
}
示例6: getExpander
import play.inject.Injector; //导入方法依赖的package包/类
public static EntityExpander getExpander(Configuration expanderConfig,
Injector injector, RequestContext requestContext) {
String predictorName = expanderConfig.getString("predictorName");
SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.class);
Predictor predictor = configService.getPredictor(predictorName, requestContext);
return new PredictorBasedExpander(predictor, expanderConfig.getString("scoreAttr"),
expanderConfig.getString("scoresAttr"));
}
示例7: getExpander
import play.inject.Injector; //导入方法依赖的package包/类
public static EntityExpander getExpander(Configuration expanderConfig,
Injector injector, RequestContext requestContext) {
String retrieverName = expanderConfig.getString("retrieverName");
SamanthaConfigService configService = injector.instanceOf(SamanthaConfigService.class);
Retriever retriever = configService.getRetriever(retrieverName, requestContext);
boolean exclude = true;
if (expanderConfig.asMap().containsKey("exclude")) {
exclude = expanderConfig.getBoolean("exclude");
}
return new RetrieverBasedItemFilterExpander(retriever, expanderConfig.getStringList("itemAttrs"),
exclude);
}
示例8: getPredictorConfig
import play.inject.Injector; //导入方法依赖的package包/类
public static PredictorConfig getPredictorConfig(Configuration predictorConfig,
Injector injector) {
FeaturizerConfigParser parser = injector.instanceOf(
FeatureExtractorListConfigParser.class);
Configuration daosConfig = predictorConfig.getConfig(ConfigKey.ENTITY_DAOS_CONFIG.get());
List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig
.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(predictorConfig);
return new RegressionTreeGBCentPredictorConfig(predictorConfig.getString("modelName"),
predictorConfig.getString("svdfeaModelName"), predictorConfig.getString("svdfeaPredictorName"),
predictorConfig.getStringList("treeFeatures"), predictorConfig.getStringList("groupKeys"),
feaExtConfigs, daosConfig, expanders,
predictorConfig.getConfig("methodConfig"), injector, predictorConfig.getString("modelFile"),
predictorConfig.getString("daoConfigKey"), predictorConfig);
}
示例9: getPredictorConfig
import play.inject.Injector; //导入方法依赖的package包/类
static public PredictorConfig getPredictorConfig(Configuration predictorConfig,
Injector injector)
throws ConfigurationException {
FeaturizerConfigParser parser = injector.instanceOf(
FeatureExtractorListConfigParser.class);
Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENTITY_DAOS_CONFIG.get());
List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig
.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(predictorConfig);
List<String> evaluatorNames = new ArrayList<>();
if (predictorConfig.asMap().containsKey("evaluatorNames")) {
evaluatorNames = predictorConfig.getStringList("evaluatorNames");
}
return new TensorFlowPredictorConfig(
predictorConfig.getStringList("groupKeys"),
predictorConfig.getStringList("indexKeys"),
evaluatorNames,
predictorConfig.getString("modelFile"),
predictorConfig.getString("modelName"),
feaExtConfigs, daoConfigs,
predictorConfig.getConfig("methodConfig"),
predictorConfig.getConfig("onlineMethodConfig"),
injector, expanders,
predictorConfig.getString("daoConfigKey"),
predictorConfig.getString("outputOperationName"),
predictorConfig.getString("updateOperationName"),
predictorConfig.getString("lossOperationName"),
predictorConfig.getString("initOperationName"),
predictorConfig.getString("graphDefFilePath"),
predictorConfig);
}
示例10: getPredictorConfig
import play.inject.Injector; //导入方法依赖的package包/类
static public PredictorConfig getPredictorConfig(Configuration predictorConfig,
Injector injector)
throws ConfigurationException {
FeaturizerConfigParser parser = injector.instanceOf(
FeatureExtractorListConfigParser.class);
Configuration daoConfigs = predictorConfig.getConfig(ConfigKey.ENTITY_DAOS_CONFIG.get());
String dependPredictorName = null, dependPredictorModelName = null;
if (predictorConfig.asMap().containsKey("dependPredictorName")) {
dependPredictorName = predictorConfig.getString("dependPredictorName");
dependPredictorModelName = predictorConfig.getString("dependPredictorModelName");
}
List<FeatureExtractorConfig> feaExtConfigs = parser.parse(predictorConfig
.getConfig(ConfigKey.PREDICTOR_FEATURIZER_CONFIG.get()));
List<Configuration> expanders = ExpanderUtilities.getEntityExpandersConfig(predictorConfig);
List<String> evaluatorNames = new ArrayList<>();
if (predictorConfig.asMap().containsKey("evaluatorNames")) {
evaluatorNames = predictorConfig.getStringList("evaluatorNames");
}
return new SVDFeaturePredictorConfig(
predictorConfig.getStringList("biasFeas"),
predictorConfig.getStringList("ufactFeas"),
predictorConfig.getStringList("ifactFeas"),
predictorConfig.getStringList("groupKeys"),
evaluatorNames,
predictorConfig.getString("modelFile"),
predictorConfig.getString("modelName"),
predictorConfig.getString("labelName"),
predictorConfig.getString("weightName"),
predictorConfig.getInt("factDim"),
predictorConfig.getConfig("onlineOptimizationMethod"),
predictorConfig.getConfig("optimizationMethod"),
predictorConfig.getConfig("objectiveConfig"),
feaExtConfigs, daoConfigs,
dependPredictorName,
dependPredictorModelName, injector, expanders,
predictorConfig.getString("daoConfigKey"),
predictorConfig);
}
示例11: getRetrieverConfig
import play.inject.Injector; //导入方法依赖的package包/类
static public RetrieverConfig getRetrieverConfig(Configuration retrieverConfig,
Injector injector)
throws ConfigurationException {
ElasticSearchService elasticSearchService = injector
.instanceOf(ElasticSearchService.class);
String elasticSearchIndex = retrieverConfig.getString("elasticSearchIndex");
Configuration settingConfig = retrieverConfig.getConfig("elasticSearchSetting");
if (!elasticSearchService.existsIndex(elasticSearchIndex).isExists()) {
elasticSearchService.createIndex(elasticSearchIndex, settingConfig);
}
String elasticSearchScoreName = retrieverConfig.getString("elasticSearchScoreName");
List<String> retrieveFields = retrieverConfig.getStringList("retrieveFields");
Configuration mappingConfig = retrieverConfig.getConfig("elasticSearchMapping");
for (String typeName : mappingConfig.subKeys()) {
if (!elasticSearchService.existsType(elasticSearchIndex, typeName)
.isExists()) {
elasticSearchService.putMapping(elasticSearchIndex, typeName,
mappingConfig.getConfig(typeName));
}
}
Boolean defaultMatchAll = retrieverConfig.getBoolean("defaultMatchAll", false);
return new ESQueryBasedRetrieverConfig(retrieverConfig.getString("elasticSearchIndex"),
elasticSearchScoreName, retrieverConfig.getString("retrieveType"),
retrieveFields, retrieverConfig.getString("elasticSearchReqKey"),
retrieverConfig.getString("setScrollKey"), defaultMatchAll,
injector, retrieverConfig, retrieverConfig.getString("queryKey"),
retrieverConfig.getStringList("matchFields"));
}
示例12: getExpander
import play.inject.Injector; //导入方法依赖的package包/类
public static EntityExpander getExpander(Configuration expanderConfig,
Injector injector, RequestContext requestContext) {
return new ESBasedJoinExpander(injector.instanceOf(ElasticSearchService.class),
expanderConfig.getString("elasticSearchIndex"),
expanderConfig.getConfigList("expandFields"));
}
示例13: getExpander
import play.inject.Injector; //导入方法依赖的package包/类
public static EntityExpander getExpander(Configuration expanderConfig,
Injector injector,
RequestContext requestContext) {
return new RedisBasedJoinExpander(expanderConfig.getConfigList("expandFields"),
injector.instanceOf(RedisService.class));
}