Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.PageAnalysis


    String okTemplate = configuration.getString(WPCConfigurationString.DAB_OK_TEMPLATE);
    if ((okTemplate == null) || okTemplate.trim().isEmpty()) {
      return;
    }
    okTemplate = okTemplate.trim();
    PageAnalysis analysis = page.getAnalysis(page.getContents(), false);
    List<PageElementTemplate> templates = analysis.getTemplates(okTemplate);
    if ((templates == null) || templates.isEmpty()) {
      return;
    }
    for (PageElementTemplate template : templates) {
      boolean done = false;
View Full Code Here


  /* (non-Javadoc)
   * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) {
    String contents = textComponent.getText();
    PageAnalysis analysis = page.getAnalysis(contents, true);
    contents = algorithm.fix(fixName, analysis, textComponent);
    textComponent.setText(contents);
    if (button != null) {
      button.doClick();
      textComponent.setModified(true);
View Full Code Here

      }
    } else {
      api.retrieveSectionContents(getWikipedia(), page, section.intValue());
    }
    if (doAnalysis) {
      PageAnalysis analysis = page.getAnalysis(page.getContents(), true);
      analysis.performFullPageAnalysis();
    }
    return returnPage;
  }
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;
          for (PageElementTag smallTag : smallTags) {
View Full Code Here

            image.getWiki(),
            Collections.singletonList(imagePage), false, false);

        // Use image description on the wiki
        if (Boolean.TRUE.equals(imagePage.isExisting())) {
          PageAnalysis pageAnalysis = imagePage.getAnalysis(imagePage.getContents(), true);
          for (PageElementTemplate template : pageAnalysis.getTemplates()) {
            if (Page.areSameTitle("Information", template.getTemplateName())) {
              String description = template.getParameterValue("Description");
              if ((description != null) && (description.trim().length() > 0)) {
                result.add(description.trim());
              }
            }
          }
        }

        // Retrieve image description on Commons
        Page commonsPage = DataManager.getPage(
            EnumWikipedia.COMMONS,
            "File:" + image.getImage(),
            null, null, null);
        api.retrieveContents(
            EnumWikipedia.COMMONS,
            Collections.singletonList(commonsPage), false, false);
        if (Boolean.TRUE.equals(commonsPage.isExisting())) {
          PageAnalysis pageAnalysis = commonsPage.getAnalysis(commonsPage.getContents(), true);
          for (PageElementTemplate template : pageAnalysis.getTemplates()) {
            if (Page.areSameTitle("Information", template.getTemplateName())) {
              String global = template.getParameterValue("Description");
              if ((global != null) && (global.trim().length() > 0)) {
                PageAnalysis descAnalysis = commonsPage.getAnalysis(global, true);
                for (PageElementTemplate template2 : descAnalysis.getTemplates()) {
                  if (Page.areSameTitle(image.getWiki().getSettings().getCode(), template2.getTemplateName())) {
                    String description = template2.getParameterValue("1");
                    if ((description != null) && (description.trim().length() > 0)) {
                      result.add(description.trim());
                    }
View Full Code Here

      window.actionSelectErrorType();
      return;
    }
    textPage.setText(page.getContents());
    textPage.setModified(false);
    PageAnalysis pageAnalysis = page.getAnalysis(textPage.getText(), true);
    List<CheckErrorPage> errorsFound = CheckError.analyzeErrors(
        window.allAlgorithms, pageAnalysis, false);
    modelErrors.clear();
    initialErrors = new ArrayList<CheckErrorPage>();
    boolean errorFound = false;
View Full Code Here

        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

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.