Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.PageAnalysis$Result


        new Object[] { page.getTitle(), Integer.toString(error.getErrorNumber())})) != JOptionPane.YES_OPTION) {
      return;
    }

    // Check if error is still present
    PageAnalysis pageAnalysis = page.getAnalysis(textPage.getText(), true);
    CheckErrorPage errorPage = CheckError.analyzeError(
        error.getAlgorithm(), pageAnalysis);
    if ((errorPage.getResults() != null) &&
        (!errorPage.getResults().isEmpty())) {
      String message =
View Full Code Here


  /**
   * @return Errors fixed.
   */
  private List<CheckErrorAlgorithm> computeErrorsFixed() {
    final List<CheckErrorAlgorithm> errorsFixed = new ArrayList<CheckErrorAlgorithm>();
    PageAnalysis pageAnalysis = null;
    if (initialErrors != null) {
      for (CheckErrorPage initialError : initialErrors) {
        if (pageAnalysis == null) {
          pageAnalysis = initialError.getPage().getAnalysis(textPage.getText(), true);
        }
View Full Code Here

  /**
   * Validate current text and recompute errors.
   */
  private void actionValidate() {
    // Check for new errors
    PageAnalysis pageAnalysis = page.getAnalysis(textPage.getText(), true);
    List<CheckErrorPage> errorsFound = CheckError.analyzeErrors(
        window.allAlgorithms, pageAnalysis, false);
    if (errorsFound != null) {
      for (CheckErrorPage tmpError : errorsFound) {
        boolean errorFound = false;
View Full Code Here

   * @param algorithms Algorithms.
   */
  protected void initializeInitialErrors(
      Collection<CheckErrorAlgorithm> algorithms) {
    if (page != null) {
      PageAnalysis pageAnalysis = page.getAnalysis(page.getContents(), false);
      pageAnalysis.shouldCheckSpelling(shouldCheckSpelling());
      List<CheckErrorPage> errorsFound = CheckError.analyzeErrors(
          algorithms, pageAnalysis, false);
      initialErrors = new ArrayList<CheckErrorPage>();
      if (errorsFound != null) {
        for (CheckErrorPage tmpError : errorsFound) {
View Full Code Here

  /**
   * @return Errors fixed.
   */
  protected List<CheckErrorAlgorithm> computeErrorsFixed() {
    final List<CheckErrorAlgorithm> errorsFixed = new ArrayList<CheckErrorAlgorithm>();
    PageAnalysis pageAnalysis = null;
    if ((initialErrors != null) && (initialErrors.size() > 0)) {
      String contents = getTextContents().getText();
      for (CheckErrorPage initialError : initialErrors) {
        if (pageAnalysis == null) {
          pageAnalysis = initialError.getPage().getAnalysis(contents, true);
          pageAnalysis.shouldCheckSpelling(shouldCheckSpelling());
        }
        CheckErrorPage errorPage = CheckError.analyzeError(
            initialError.getAlgorithm(), pageAnalysis);
        if ((errorPage.getErrorFound() == false) ||
            (errorPage.getActiveResultsCount() < initialError.getActiveResultsCount())) {
View Full Code Here

    boolean oldState = isInInternalModification;
    isInInternalModification = true;

    // First remove MediaWiki styles
    String contents = getText();
    PageAnalysis pageAnalysis = (page != null) ? page.getAnalysis(contents, true) : null;
    formatter.format(this, pageAnalysis);

    isInInternalModification = oldState;

    if (!isInInternalModification) {
View Full Code Here

      return;
    }

    // Create popup menu
    Page originalPage = textPane.getWikiPage();
    PageAnalysis pageAnalysis = originalPage.getAnalysis(textPane.getText(), true);
    JPopupMenu popup = createPopup(textPane, position, pageAnalysis);
    if (popup == null) {
      popup = createDefaultPopup(textPane, position, pageAnalysis);
    }
View Full Code Here

  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
    String originalText = textPane.getText();
    PageAnalysis analysis = textPane.getWikiPage().getAnalysis(originalText, true);
    StringBuilder buffer = new StringBuilder();
    int lastPosition = 0;
    Collection<PageElementInternalLink> links = analysis.getInternalLinks();
    for (PageElementInternalLink link : links) {
      if (Page.areSameTitle(from.getTitle(), link.getLink())) {
        buffer.append(originalText.substring(lastPosition, link.getBeginIndex()));
        lastPosition = link.getBeginIndex();
        buffer.append(link.getDisplayedText());
View Full Code Here

              String pageName = elements[0];
              String[] elementsReplacement = elements[3].split(",");
              Page page = pages.get(pageName);
              if ((page != null) && (page.getContents() != null)) {
                String contents = page.getContents();
                PageAnalysis analysis = page.getAnalysis(contents, true);
                Collection<PageElementTemplate> templates = analysis.getTemplates(elements[1]);
                for (PageElementTemplate template : templates) {
                  String chapterId = PageAnalysisUtils.getCurrentChapterId(analysis, template.getBeginIndex());
                  if ((suggestionIgnore == null) || (!suggestionIgnore.contains(chapterId))) {
                    String patternText = template.getParameterValue(elements[2]);
                    Suggestion suggestion = tmpMap.get(patternText);
                    if (suggestion == null) {
                      String chapter = PageAnalysisUtils.getCurrentChapterId(analysis, template.getBeginIndex());
                      suggestion = Suggestion.createSuggestion(patternText, false, chapter);
                      if (suggestion != null) {
                        tmpMap.put(patternText, suggestion);
                      }
                    }
                    if (suggestion != null) {
                      boolean automatic = false;
                      if (elements.length > 4) {
                        suggestion.setComment(template.getParameterValue(elements[4]));
                        if (elements.length > 6) {
                          if (elements[6].equalsIgnoreCase(template.getParameterValue(elements[5]))) {
                            automatic = true;
                          }
                        }
                      }
                      for (String elementReplacement : elementsReplacement) {
                        String replacementText = template.getParameterValue(elementReplacement);
                        if ((replacementText != null) &&
                            (replacementText.length() > 0)) {
                          suggestion.addReplacement(replacementText, automatic);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }

        // Construct suggestions from AWB format
        if (suggestionTypoPages != null) {
          List<String> suggestionIgnore = getStringList(WPCConfigurationStringList.SUGGESTION_IGNORE);
          for (String suggestionPage : suggestionTypoPages) {
            Page page = pages.get(suggestionPage);
            if ((page != null) && (page.getContents() != null)) {
              String contents = page.getContents();
              PageAnalysis analysis = page.getAnalysis(contents, true);
              Collection<PageElementTag> tags = analysis.getTags(PageElementTag.TAG_OTHER_TYPO);
              for (PageElementTag tag : tags) {
                String chapterId = PageAnalysisUtils.getCurrentChapterId(analysis, tag.getBeginIndex());
                if ((suggestionIgnore == null) || (!suggestionIgnore.contains(chapterId))) {
                  Parameter word = tag.getParameter("word");
                  Parameter find = tag.getParameter("find");
View Full Code Here

      if (answer != JOptionPane.YES_OPTION) {
        return;
      }
    }
    String originalText = textPane.getText();
    PageAnalysis analysis = textPane.getWikiPage().getAnalysis(originalText, true);
    StringBuilder buffer = new StringBuilder();
    int lastPosition = 0;
    Collection<PageElementInternalLink> links = analysis.getInternalLinks();
    for (PageElementInternalLink link : links) {
      if (Page.areSameTitle(from.getTitle(), link.getLink())) {
        buffer.append(originalText.substring(lastPosition, link.getBeginIndex()));
        lastPosition = link.getBeginIndex();
        buffer.append(PageElementInternalLink.createInternalLink(to, link.getDisplayedText()));
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.api.data.PageAnalysis$Result

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.