Tabnine Logo
Configurator.construct
Code IndexAdd Tabnine to your IDE (free)

How to use
construct
method
in
org.wikibrain.conf.Configurator

Best Java code snippets using org.wikibrain.conf.Configurator.construct (Showing top 8 results out of 315)

origin: shilad/wikibrain

@Override
public SRMetric create() {
  try {
    Map<String, String> runtimeParams = new HashMap<String, String>();
    runtimeParams.put("language", language.getLangCode());
    return configurator.construct(SRMetric.class, name, config, runtimeParams);
  } catch (ConfigurationException e) {
    throw new RuntimeException(e);
  }
}
origin: shilad/wikibrain

  @Override
  public PhraseAnalyzer get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException {
    if (!config.getString("type").equals("stanford")) {
      return null;
    }
    PhraseAnalyzerDao paDao = getConfigurator().construct(
        PhraseAnalyzerDao.class, name, config.getConfig("dao"),
        new HashMap<String, String>());
    LocalPageDao lpDao = getConfigurator().get(LocalPageDao.class, config.getString("localPageDao"));
    File path = new File(config.getString("path"));
    PrunedCounts.Pruner<String> phrasePruner = getConfigurator().construct(
        PrunedCounts.Pruner.class, null, config.getConfig("phrasePruner"), null);
    PrunedCounts.Pruner<Integer> pagePruner = getConfigurator().construct(
        PrunedCounts.Pruner.class, null, config.getConfig("pagePruner"), null);
    return new StanfordPhraseAnalyzer(paDao, lpDao, phrasePruner, pagePruner, path);
  }
}
origin: shilad/wikibrain

  @Override
  public PhraseAnalyzer get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException {
    if (!config.getString("type").equals("anchortext")) {
      return null;
    }
    PhraseAnalyzerDao paDao = getConfigurator().construct(
        PhraseAnalyzerDao.class, name, config.getConfig("dao"),
        new HashMap<String, String>());
    LocalPageDao lpDao = getConfigurator().get(LocalPageDao.class, config.getString("localPageDao"));
    LocalLinkDao llDao = getConfigurator().get(LocalLinkDao.class, config.getString("localLinkDao"));
    PrunedCounts.Pruner<String> phrasePruner = getConfigurator().construct(
        PrunedCounts.Pruner.class, null, config.getConfig("phrasePruner"), null);
    PrunedCounts.Pruner<Integer> pagePruner = getConfigurator().construct(
        PrunedCounts.Pruner.class, null, config.getConfig("pagePruner"), null);
    return new AnchorTextPhraseAnalyzer(paDao, lpDao, llDao, phrasePruner, pagePruner);
  }
}
origin: shilad/wikibrain

@Override
public SRMetric get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException {
  if (!config.getString("type").equals("sparsevector")) {
    return null;
  }
  if (runtimeParams == null || !runtimeParams.containsKey("language")){
    throw new IllegalArgumentException("Monolingual requires 'language' runtime parameter.");
  }
  Language language = Language.getByLangCode(runtimeParams.get("language"));
  Map<String, String> params = new HashMap<String, String>();
  params.put("language", language.getLangCode());
  SparseVectorGenerator generator = getConfigurator().construct(
      SparseVectorGenerator.class, null, config.getConfig("generator"), params);
  VectorSimilarity similarity = getConfigurator().construct(
      VectorSimilarity.class,  null, config.getConfig("similarity"), params);
  SparseVectorSRMetric sr = new SparseVectorSRMetric(
      name,
      language,
      getConfigurator().get(LocalPageDao.class,config.getString("pageDao")),
      getConfigurator().get(Disambiguator.class,config.getString("disambiguator"),"language", language.getLangCode()),
      generator,
      similarity
  );
  configureBase(getConfigurator(), sr, config);
  return sr;
}
origin: shilad/wikibrain

Map<String, String> params = new HashMap<String, String>();
params.put("language", language.getLangCode());
SparseVectorGenerator generator = getConfigurator().construct(
    SparseVectorGenerator.class, null, config.getConfig("generator"), params);
VectorSimilarity similarity = getConfigurator().construct(
    VectorSimilarity.class,  null, config.getConfig("similarity"), params);
FancyPhraseVectorBasedSRMetric sr = new FancyPhraseVectorBasedSRMetric(
    generator,
    similarity,
    getConfigurator().construct(
        PhraseVectorCreator.class, null, config.getConfig("phrases"), null)
);
origin: shilad/wikibrain

  @Override
  public Disambiguator get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException{
    if (!config.getString("type").equals("similarity")){
      return null;
    }
    if (runtimeParams == null || !runtimeParams.containsKey("language")){
      throw new IllegalArgumentException("SimpleMilneWitten requires 'language' runtime parameter.");
    }
    Language lang = Language.getByLangCode(runtimeParams.get("language"));
    PhraseAnalyzer pa = getConfigurator().get(PhraseAnalyzer.class, config.getString("phraseAnalyzer"));
    // Create override config for sr metric and load it.
    String srName = config.getString("metric");
    Config newConfig = getConfig().get().getConfig("sr.metric.local." + srName)
        .withValue("disambiguator", ConfigValueFactory.fromAnyRef("topResult"));
    Map<String, String> srRuntimeParams = new HashMap<String, String>();
    srRuntimeParams.put("language", lang.getLangCode());
    SRMetric sr = getConfigurator().construct(SRMetric.class, srName, newConfig, srRuntimeParams);
    SimilarityDisambiguator dab = new SimilarityDisambiguator(pa, sr);
    if (config.hasPath("criteria")) {
      dab.setCriteria(Criteria.valueOf(config.getString("criteria").toUpperCase()));
    }
    return dab;
  }
}
origin: shilad/wikibrain

@Override
public SRMetric get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException {
  if (!config.getString("type").equals("densevector")) {
    return null;
  }
  if (runtimeParams == null || !runtimeParams.containsKey("language")){
    throw new IllegalArgumentException("Monolingual requires 'language' runtime parameter.");
  }
  Language language = Language.getByLangCode(runtimeParams.get("language"));
  Map<String, String> params = new HashMap<String, String>();
  params.put("language", language.getLangCode());
  DenseVectorGenerator generator = getConfigurator().construct(
      DenseVectorGenerator.class, null, config.getConfig("generator"), params);
  DenseVectorSRMetric sr = new DenseVectorSRMetric(
      name,
      language,
      getConfigurator().get(LocalPageDao.class,config.getString("pageDao")),
      getConfigurator().get(Disambiguator.class,config.getString("disambiguator"),"language", language.getLangCode()),
      generator
  );
  configureBase(getConfigurator(), sr, config);
  return sr;
}
origin: shilad/wikibrain

  @Override
  public Disambiguator get(String name, Config config, Map<String, String> runtimeParams) throws ConfigurationException{
    if (!config.getString("type").equals("milnewitten")){
      return null;
    }
    if (runtimeParams == null || !runtimeParams.containsKey("language")){
      throw new IllegalArgumentException("SimpleMilneWitten requires 'language' runtime parameter.");
    }
    Language lang = Language.getByLangCode(runtimeParams.get("language"));
    PhraseAnalyzer pa = getConfigurator().get(PhraseAnalyzer.class, config.getString("phraseAnalyzer"));
    LocalPageDao pageDao = getConfigurator().get(LocalPageDao.class);
    // Create override config for sr metric and load it.
    String srName = config.getString("metric");
    Config newConfig = getConfig().get().getConfig("sr.metric.local." + srName)
        .withValue("disambiguator", ConfigValueFactory.fromAnyRef("topResult"));
    Map<String, String> srRuntimeParams = new HashMap<String, String>();
    srRuntimeParams.put("language", lang.getLangCode());
    SRMetric sr = getConfigurator().construct(SRMetric.class, srName, newConfig, srRuntimeParams);
    try {
      return new MilneWittenDisambiguator(pageDao, pa, sr);
    } catch (DaoException e) {
      throw new ConfigurationException(e);
    }
  }
}
org.wikibrain.confConfiguratorconstruct

Javadoc

Constructs an instance of the specified class with the passed in config. This bypasses the cache and the configuration object.

Popular methods of Configurator

  • get
    Get a specific named instance of the component with the specified class.
  • <init>
    Constructs a new configuration object with the specified configuration.
  • getConf
  • getConfig
    Returns the config object associated with the given class and name.
  • resolveComponentName
    If the component name is "default" or null, return the name of the default implementation of the com
  • close
    Tries to close all open components, clears the components map.
  • constructInternal
  • makeCacheKey
    Returns a unique string for the name and params
  • registerProvider
    Instantiates providers for the component.
  • registerProviders
    Registers all class that extend Providers

Popular in Java

  • Parsing JSON documents to java classes using gson
  • findViewById (Activity)
  • compareTo (BigDecimal)
  • getResourceAsStream (ClassLoader)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • LoggerFactory (org.slf4j)
    The LoggerFactory is a utility class producing Loggers for various logging APIs, most notably for lo
  • Best IntelliJ plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now