Package org.languagetool.tools

Examples of org.languagetool.tools.RuleAsXmlSerializer


  private String getXmlResponse(String text, Language lang, Language motherTongue, List<RuleMatch> matches) {
    if (afterTheDeadlineMode) {
      AtDXmlSerializer serializer = new AtDXmlSerializer();
      return serializer.ruleMatchesToXml(matches, text);
    } else {
      RuleAsXmlSerializer serializer = new RuleAsXmlSerializer();
      return serializer.ruleMatchesToXml(matches, text, CONTEXT_SIZE, lang, motherTongue);
    }
  }
View Full Code Here


    for (RuleMatch r : ruleMatches) {
      r.setLine(r.getLine() + lineOffset);
      r.setEndLine(r.getEndLine() + lineOffset);
    }
    if (apiFormat) {
      final RuleAsXmlSerializer serializer = new RuleAsXmlSerializer();
      final String xml = serializer.ruleMatchesToXml(ruleMatches, contents,
              contextSize, lt.getLanguage());
      final PrintStream out = new PrintStream(System.out, true, "UTF-8");
      out.print(xml);
    } else {
      printMatches(ruleMatches, prevMatches, contents, contextSize);
View Full Code Here

    final long startTime = System.currentTimeMillis();
    final int contextSize = DEFAULT_CONTEXT_SIZE;
    final List<RuleMatch> ruleMatches = new ArrayList<>();
    int matchCount = 0;
    int sentCount = 0;
    final RuleAsXmlSerializer serializer = new RuleAsXmlSerializer();
    final PrintStream out = new PrintStream(System.out, true, "UTF-8");
    if (apiFormat) {
      out.print(serializer.getXmlStart(null, null));
    }
    for (StringPair srcAndTrg : reader) {
      final List<RuleMatch> curMatches = Tools.checkBitext(
              srcAndTrg.getSource(), srcAndTrg.getTarget(),
              srcLt, trgLt, bRules);
      final List<RuleMatch> fixedMatches = new ArrayList<>();
      for (RuleMatch thisMatch : curMatches) {
        fixedMatches.add(
                trgLt.adjustRuleMatchPos(thisMatch,
                        reader.getSentencePosition(),
                        reader.getColumnCount(),
                        reader.getLineCount(),
                        reader.getCurrentLine(), null));
      }
      ruleMatches.addAll(fixedMatches);
      if (fixedMatches.size() > 0) {
        if (apiFormat) {
          final String xml = serializer.ruleMatchesToXmlSnippet(fixedMatches,
                  reader.getCurrentLine(), contextSize);
          out.print(xml);
        } else {
          printMatches(fixedMatches, matchCount, reader.getCurrentLine(), contextSize);
          matchCount += fixedMatches.size();
        }
      }
      sentCount++;
    }
    displayTimeStats(startTime, sentCount, apiFormat);
    if (apiFormat) {
      out.print(serializer.getXmlEnd());
    }
    return ruleMatches.size();
  }
View Full Code Here

TOP

Related Classes of org.languagetool.tools.RuleAsXmlSerializer

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.