Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.PageAnalysis


  /**
   * @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

    setText(prefix + " - " + GT._("Analyzing page {0}", page.getTitle()));

    // Retrieve page content
    API api = APIFactory.getAPI();
    api.retrieveContents(getWikipedia(), Collections.singletonList(page), true, false);
    PageAnalysis analysis = page.getAnalysis(page.getContents(), true);

    // Check that robots are authorized to change this page
    if (saveModifications) {
      WPCConfiguration config = getWikipedia().getConfiguration();
      List<String[]> nobotTemplates = config.getStringArrayList(
          WPCConfigurationStringList.NOBOT_TEMPLATES);
      if ((nobotTemplates != null) && (!nobotTemplates.isEmpty())) {
        for (String[] nobotTemplate : nobotTemplates) {
          String templateName = nobotTemplate[0];
          List<PageElementTemplate> templates = analysis.getTemplates(templateName);
          if ((templates != null) && (!templates.isEmpty())) {
            if (analyzeNonFixed) {
              Controller.runFullAnalysis(page.getTitle(), null, getWikipedia());
            }
            return;
View Full Code Here

    List<PageElementImage> images = analysis.getImages();
    for (PageElementImage image : images) {
      String description = image.getDescription();
      if (description != null) {
        description = description.trim();
        PageAnalysis descAnalysis = analysis.getPage().getAnalysis(description, false);
        List<PageElementTag> smallTags = descAnalysis.getTags(PageElementTag.TAG_HTML_SMALL);
        if ((smallTags != null) && (!smallTags.isEmpty())) {
          int lastTest = 0;
          int currentDepth = 0;
          boolean onlySmall = true;
          StringBuilder innerText = new StringBuilder();
View Full Code Here

      return;
    }

    // Update warning
    for (Page page : pages) {
      PageAnalysis pageAnalysis = page.getAnalysis(page.getContents(), true);
      boolean updated = updateWarning(
          pageAnalysis, page.getRevisionId(),
          mapTalkPages.get(page),
          mapTodoSubpages.get(page),
          (creators != null) ? creators.get(page.getTitle()) : null,
View Full Code Here

    // Search warning in the "To do" sub-page
    String contents = todoSubpage.getContents();
    if (contents == null) {
      contents = "";
    }
    PageAnalysis analysis = todoSubpage.getAnalysis(contents, true);
    PageElementTemplate templateWarning = getFirstWarningTemplate(analysis);

    // If warning is missing, add it
    if (templateWarning == null) {
      if (!createWarning) {
View Full Code Here

TOP

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

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.