Package org.wikipediacleaner.api.data

Examples of org.wikipediacleaner.api.data.Page


    // Initialization
    String fullName = wikipedia.getWikiConfiguration().getPageTitle(
        Namespace.CATEGORY,
        category.getName());
    Page page = DataManager.getPage(wikipedia, fullName, null, null, null);

    // Menu creation
    BasicMenuCreator menu = new BasicMenuCreator();
    JPopupMenu popup = menu.createPopupMenu(GT._(
        "Category: {0}",
View Full Code Here


    // Initialization
    String fullName = wikipedia.getWikiConfiguration().getPageTitle(
        Namespace.TEMPLATE,
        template.getTemplateName());
    Page page = DataManager.getPage(wikipedia, fullName, null, null, null);

    // Menu creation
    BasicMenuCreator menu = new BasicMenuCreator();
    JPopupMenu popup = menu.createPopupMenu(GT._(
        "Template: {0}",
View Full Code Here

          List<String> suggestionIgnore = getStringList(WPCConfigurationStringList.SUGGESTION_IGNORE);
          for (String[] elements : suggestionPages) {
            if (elements.length >= 4) {
              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");
View Full Code Here

    fullList.addAll(elements);
    if (comparator != null) {
      Collections.sort(fullList, comparator);
    }
    for (int i = 0; i < fullList.size(); i++) {
      Page page = fullList.get(i);
      if (filterPage(page)) {
        filteredList.add(page);
      }
    }
    if (!filteredList.isEmpty()) {
View Full Code Here

  
   * @param element The component to be added.
   */
  public void addElement(Object element) {
    if (element instanceof Page) {
      Page page = (Page) element;
      boolean added = false;
      if (comparator != null) {
        for (int i = 0; !added && (i < fullList.size()); i++) {
          if (comparator.compare(page, fullList.get(i)) < 0) {
            fullList.add(i, page);
View Full Code Here

            Map<Page, List<String>> anchorsRedirectMap = new HashMap<Page, List<String>>();
            p.getLinksWithRedirect(anchorsRedirectMap);
           
            Iterator<Page> iter = p.getRedirectIteratorWithPage();
            while (iter.hasNext()) {
              Page pageTmp = iter.next();
              List<String> anchors = anchorsRedirectMap.get(pageTmp);

              addItem(
                  submenu1, pageTmp, null, true,
                  new ReplaceLinkAction(page.getTitle(), pageTmp.getTitle(), text, element, textPane, false));

              addItem(
                  submenu2, pageTmp, null, true,
                  new ReplaceLinkAction(page.getTitle(), pageTmp.getTitle(), text, element, textPane, true));

              addItem(
                  submenu3, pageTmp, null, true,
                  new ChangePreferredDisambiguationAction(
                      page.getWikipedia(), page.getTitle(), pageTmp.getTitle(), true));

              if ((anchors != null) && (anchors.size() > 0)) {
                for (String anchor : anchors) {
                  addItem(
                      submenu1, pageTmp, anchor, true,
View Full Code Here

          PageListTableModel model = (PageListTableModel) table.getModel();
          int column = table.columnAtPoint(e.getPoint());
          int row = table.rowAtPoint(e.getPoint());
          if ((column >= 0) && (row >= 0)) {
            row = Utilities.convertRowIndexToModel(table, row);
            Page page = model.getPage(row);
            if (Boolean.TRUE.equals(page.isDisambiguationPage())) {
              Controller.runDisambiguationAnalysis(page.getTitle(), page.getWikipedia());
            } else {
              Controller.runFullAnalysis(page.getTitle(), null, page.getWikipedia());
            }
            e.consume();
          }
        }
      }
View Full Code Here

              Map<Page, List<String>> anchorsRedirectMap = new HashMap<Page, List<String>>();
              p.getLinksWithRedirect(anchorsRedirectMap);
             
              Iterator<Page> iter = p.getRedirectIteratorWithPage();
              while (iter.hasNext()) {
                Page pageTmp = iter.next();
                List<String> anchors = anchorsRedirectMap.get(pageTmp);

                addItem(
                    submenu1, pageTmp, null, true,
                    new ReplaceTextAction(
                        matcher.getReplacement(page, template, indexReplacement, pageTmp.getTitle()),
                        element, textPane));
       
                if ((anchors != null) && (anchors.size() > 0)) {
                  for (String anchor : anchors) {
                    addItem(
View Full Code Here

          int maxErrors = error.getPageCount();
          for (int numPage = 0;
              (error.getPageCount() > 0) && shouldContinue();
              numPage++) {
            try {
              Page page = error.getPage(0);
              error.remove(page);
              analyzePage(
                  page, algorithm,
                  algorithm.getErrorNumberString() + " - " + (numPage + 1) + "/" + maxErrors);
            } catch (APIException e) {
View Full Code Here

    for (PageElementInternalLink link : links) {
      String linkDest = link.getLink();
      if ((linkDest != null) &&
          (linkDest.trim().length() > 0) &&
          (linkDest.indexOf(':') >= 0)) {
        Page page = DataManager.getPage(wiki, linkDest, null, null, null);
        Integer namespace = page.getNamespace();
        if ((namespace != null) &&
            ((namespace.intValue() == Namespace.USER) ||
             (namespace.intValue() == Namespace.USER_TALK))) {
          if (errors == null) {
            return true;
View Full Code Here

TOP

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

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.