Package org.languagetool.databroker

Examples of org.languagetool.databroker.ResourceDataBroker


  private void init() {
    if (chinesdJF == null) {
      chinesdJF = CJFBeanFactory.getChineseJF();
    }
    if (seg == null) {
      final ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
      final InputStream coreDictIn = dataBroker.getFromResourceDirAsStream("/zh/coreDict.dct");
      final InputStream bigramDictIn = dataBroker.getFromResourceDirAsStream("/zh/BigramDict.dct");
      final InputStream personTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/nr.dct");
      final InputStream personTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/nr.ctx");
      final InputStream transPersonTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/tr.dct");
      final InputStream transPersonTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/tr.ctx");
      final InputStream placeTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/ns.dct");
      final InputStream placeTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/ns.ctx");
      final InputStream lexTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/lexical.ctx");
      seg = new SegTag(1, coreDictIn, bigramDictIn, personTaggerDctIn, personTaggerCtxIn,
          transPersonTaggerDctIn, transPersonTaggerCtxIn, placeTaggerDctIn, placeTaggerCtxIn,
          lexTaggerCtxIn);
    }
  }
View Full Code Here


      setForeground(list.getForeground());
    }
    setText(getTranslatedName(value));
    String langTag = value.getLocaleWithCountry().toLanguageTag();
    String country = value.getLocaleWithCountry().getCountry().toLowerCase();
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
   
    String filename = "flags/bytag/" + langTag + ".png";
    if (!dataBroker.resourceExists(filename)) {
      filename = "flags/" + country + ".png";
    }
    if (!dataBroker.resourceExists(filename)) {
      filename = "flags/empty.png";
    }
   
    ImageIcon icon = new ImageIcon(dataBroker.getFromResourceDirAsUrl(filename));
    setIcon(icon);
    setEnabled(list.isEnabled());
    setFont(list.getFont());
    setBorder(BORDER);
    return this;
View Full Code Here

  /**
   * Get the location of the rule file(s).
   */
  public List<String> getRuleFileNames() {
    final List<String> ruleFiles = new ArrayList<>();
    final ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    ruleFiles.add(dataBroker.getRulesDir()
            + "/" + getShortName() + "/" + JLanguageTool.PATTERN_FILE);
    if (getShortNameWithVariant().length() > 2) {
      final String fileName = getShortName() + "/"
              + getShortNameWithVariant()
              + "/" + JLanguageTool.PATTERN_FILE;
      if (dataBroker.ruleFileExists(fileName)) {
        ruleFiles.add(dataBroker.getRulesDir() + "/" + fileName);
      }
    }
    return ruleFiles;
  }
View Full Code Here

      runTestForLanguage(lang);
    }
  }

  private boolean skipCountryVariant(Language lang) {
    final ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    return !dataBroker.ruleFileExists(getGrammarFileName(lang)) && Language.REAL_LANGUAGES.length > 1;
  }
View Full Code Here

  private void init() {
    if (chinesdJF == null) {
      chinesdJF = CJFBeanFactory.getChineseJF();
    }
    if (seg == null) {
      final ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
      final InputStream coreDictIn = dataBroker.getFromResourceDirAsStream("/zh/coreDict.dct");
      final InputStream bigramDictIn = dataBroker.getFromResourceDirAsStream("/zh/BigramDict.dct");
      final InputStream personTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/nr.dct");
      final InputStream personTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/nr.ctx");
      final InputStream transPersonTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/tr.dct");
      final InputStream transPersonTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/tr.ctx");
      final InputStream placeTaggerDctIn = dataBroker.getFromResourceDirAsStream("/zh/ns.dct");
      final InputStream placeTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/ns.ctx");
      final InputStream lexTaggerCtxIn = dataBroker.getFromResourceDirAsStream("/zh/lexical.ctx");
      seg = new SegTag(1, coreDictIn, bigramDictIn, personTaggerDctIn, personTaggerCtxIn,
          transPersonTaggerDctIn, transPersonTaggerCtxIn, placeTaggerDctIn, placeTaggerCtxIn,
          lexTaggerCtxIn);
    }
  }
View Full Code Here

      setForeground(list.getForeground());
    }
    setText(getTranslatedName(lang));
    String langTag = lang.getLocaleWithCountryAndVariant().toLanguageTag();
    String country = lang.getLocaleWithCountryAndVariant().getCountry().toLowerCase();
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();

    String filename = "flags/bytag/" + langTag + ".png";
    if (!dataBroker.resourceExists(filename)) {
      filename = "flags/" + country + ".png";
    }
    if (!dataBroker.resourceExists(filename)) {
      filename = "flags/empty.png";
    }

    ImageIcon icon = new ImageIcon(dataBroker.getFromResourceDirAsUrl(filename));
    setIcon(icon);
    setEnabled(list.isEnabled());
    setFont(list.getFont());
    setBorder(BORDER);
    return this;
View Full Code Here

    }
    runTestForLanguage(lang);
  }

  private boolean skipCountryVariant(Language lang) {
    final ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    boolean hasGrammarFiles = false;
    for (String grammarFile : getGrammarFileNames(lang)) {
      if (dataBroker.ruleFileExists(grammarFile)) {
        hasGrammarFiles = true;
      }
    }
    return !hasGrammarFiles && Language.REAL_LANGUAGES.length > 1;
  }
View Full Code Here

   * Get the location of the rule file(s) in a form like {@code /org/languagetool/rules/de/grammar.xml}.
   */
  public List<String> getRuleFileNames() {
    final List<String> ruleFiles = new ArrayList<>();
    ruleFiles.addAll(getExternalRuleFiles());
    final ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    ruleFiles.add(dataBroker.getRulesDir()
            + "/" + getShortName() + "/" + JLanguageTool.PATTERN_FILE);
    if (getShortNameWithCountryAndVariant().length() > 2) {
      final String fileName = getShortName() + "/"
              + getShortNameWithCountryAndVariant()
              + "/" + JLanguageTool.PATTERN_FILE;
      if (dataBroker.ruleFileExists(fileName)) {
        ruleFiles.add(dataBroker.getRulesDir() + "/" + fileName);
      }
    }
    return ruleFiles;
  }
View Full Code Here

  }

  @Override
  public List<String> getRuleFileNames() {
    List<String> ruleFileNames = super.getRuleFileNames();
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    String dirBase = dataBroker.getRulesDir() + "/" + getShortName() + "/";

    for(String ruleFile: RULE_FILES) {
      ruleFileNames.add(dirBase + ruleFile);
    }
View Full Code Here

  public abstract String getMessage(String suggestion);

  public ConfusionProbabilityRule(ResourceBundle messages, LanguageModel languageModel, Language language) throws IOException {
    super(messages);
    ResourceDataBroker dataBroker = JLanguageTool.getDataBroker();
    String prefix = "/" + language.getShortName() + "/";
    InputStream homophonesInfoStream = dataBroker.getFromResourceDirAsStream(prefix + HOMOPHONES_INFO);
    ConfusionSetLoader confusionSetLoader = new ConfusionSetLoader(homophonesInfoStream, MIN_SENTENCES, MAX_ERROR_RATE);
    InputStream homophonesStream = dataBroker.getFromResourceDirAsStream(prefix + HOMOPHONES);
    this.wordToSet = confusionSetLoader.loadConfusionSet(homophonesStream);
    this.languageModel = languageModel;
  }
View Full Code Here

TOP

Related Classes of org.languagetool.databroker.ResourceDataBroker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.