Package org.languagetool.rules.patterns.bitext

Examples of org.languagetool.rules.patterns.bitext.BitextPatternRuleLoader


   */
  public static List<BitextRule> getBitextRules(final Language source,
      final Language target) throws IOException, ParserConfigurationException, SAXException {
    final List<BitextRule> bRules = new ArrayList<>();
    //try to load the bitext pattern rules for the language...
    final BitextPatternRuleLoader ruleLoader = new BitextPatternRuleLoader();         
    final String name = "/" + target.getShortName() + "/bitext.xml";
    final InputStream is = JLanguageTool.getDataBroker().getFromRulesDirAsStream(name);
    if (is != null) {
      bRules.addAll(ruleLoader.getRules(is, name));
    }
   
    //load the false friend rules in the bitext mode:
    final FalseFriendsAsBitextLoader fRuleLoader = new FalseFriendsAsBitextLoader();
    final String falseFriendsFile = "/false-friends.xml";
View Full Code Here


  private void testBitextRulesFromXML(final Set<Language> ignoredLanguages) throws IOException {
    for (final Language lang : Language.LANGUAGES) {
      if (ignoredLanguages != null && ignoredLanguages.contains(lang)) {
        continue;
      }
      final BitextPatternRuleLoader ruleLoader = new BitextPatternRuleLoader();
      final String name = "/" + lang.getShortName() + "/bitext.xml";
      final InputStream is;
      try {
        is = JLanguageTool.getDataBroker().getFromRulesDirAsStream(name);
      } catch (RuntimeException ignored) {
        // thrown if there is no bitext.xml file
        continue;
      }
      System.out.println("Running tests for " + lang.getName() + "...");
      final JLanguageTool languageTool = new JLanguageTool(lang);
      final List<BitextPatternRule> rules = ruleLoader.getRules(is, name);
      testBitextRulesFromXML(rules, languageTool, lang);
    }
  }
View Full Code Here

  private void testBitextRulesFromXML(final Set<Language> ignoredLanguages) throws IOException {
    for (final Language lang : Language.LANGUAGES) {
      if (ignoredLanguages != null && ignoredLanguages.contains(lang)) {
        continue;
      }
      final BitextPatternRuleLoader ruleLoader = new BitextPatternRuleLoader();
      final String name = "/" + lang.getShortName() + "/bitext.xml";
      final InputStream is;
      try {
        is = JLanguageTool.getDataBroker().getFromRulesDirAsStream(name);
      } catch (RuntimeException ignored) {
        // thrown if there is no bitext.xml file
        continue;
      }
      System.out.println("Running tests for " + lang.getName() + "...");
      final JLanguageTool languageTool = new JLanguageTool(lang);
      final List<BitextPatternRule> rules = ruleLoader.getRules(is, name);
      testBitextRulesFromXML(rules, languageTool, lang);
    }
  }
View Full Code Here

   */
  public static List<BitextRule> getBitextRules(final Language source,
      final Language target) throws IOException, ParserConfigurationException, SAXException {
    final List<BitextRule> bRules = new ArrayList<>();
    //try to load the bitext pattern rules for the language...
    final BitextPatternRuleLoader ruleLoader = new BitextPatternRuleLoader();         
    final String name = "/" + target.getShortName() + "/bitext.xml";
    final InputStream is = JLanguageTool.getDataBroker().getFromRulesDirAsStream(name);
    if (is != null) {
      bRules.addAll(ruleLoader.getRules(is, name));
    }
   
    //load the false friend rules in the bitext mode:
    final FalseFriendsAsBitextLoader fRuleLoader = new FalseFriendsAsBitextLoader();
    final String falseFriendsFile = "/false-friends.xml";
View Full Code Here

TOP

Related Classes of org.languagetool.rules.patterns.bitext.BitextPatternRuleLoader

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.