Examples of MagicWord


Examples of org.wikipediacleaner.api.data.MagicWord

      return contents;
    }

    // Get DEFAULTSORT name
    String defaultSort = "DEFAULTSORT:";
    MagicWord magicWord = analysis.getWikiConfiguration().getMagicWordByName(MagicWord.DEFAULT_SORT);
    if (magicWord != null) {
      String value = analysis.getWPCConfiguration().getString(WPCConfigurationString.DEFAULTSORT);
      if ((value != null) && (value.trim().length() > 0)) {
        value = value.trim();
        if (magicWord.isPossibleAlias(value)) {
          defaultSort = value;
        }
      }
    }
View Full Code Here

Examples of org.wikipediacleaner.api.data.MagicWord

   */
  public MagicWord getFunctionMagicWord(String text, boolean colon) {
    List<String> functionMagicWords = MagicWord.getFunctionMagicWords();
    String colonText = text + ":";
    for (String functionMagicWord : functionMagicWords) {
      MagicWord magicWord = getMagicWordByName(functionMagicWord);
      if (magicWord != null) {
        if (magicWord.isPossibleAlias(text)) {
          return magicWord;
        }
        if (colon && magicWord.isPossibleAlias(colonText)) {
          return magicWord;
        }
      }
    }
    return null;
View Full Code Here

Examples of org.wikipediacleaner.api.data.MagicWord

   * @return Matching Magic Word if the text is an alias for a Image Magic Word.
   */
  public MagicWord getImgMagicWord(String text) {
    List<String> imgMagicWords = MagicWord.getImgMagicWords();
    for (String imgMagicWord : imgMagicWords) {
      MagicWord magicWord = getMagicWordByName(imgMagicWord);
      if ((magicWord != null) && magicWord.isPossibleAlias(text)) {
        return magicWord;
      }
    }
    return null;
  }
View Full Code Here

Examples of org.wikipediacleaner.api.data.MagicWord

    if (analysis == null) {
      return false;
    }

    // Retrieve magic word for redirects
    MagicWord redirect = analysis.getWikiConfiguration().getMagicWordByName(MagicWord.REDIRECT);
    if ((redirect == null) ||
        (redirect.getAliases() == null) ||
        (redirect.getAliases().isEmpty())) {
      return false;
    }

    // Analysis of all article text
    boolean result = false;
    String contents = analysis.getContents();
    int currentIndex = 0;
    while (currentIndex < contents.length()) {

      // Check if we are at the beginning of a #REDIRECT
      String aliasFound = null;
      if (contents.charAt(currentIndex) == '#') {
        for (String alias : redirect.getAliases()) {
          int endIndex = currentIndex + alias.length();
          if ((endIndex < contents.length()) &&
              (alias.length() > 0) &&
              (alias.equalsIgnoreCase(contents.substring(currentIndex, endIndex)))) {
            char nextChar = contents.charAt(endIndex);
View Full Code Here

Examples of org.wikipediacleaner.api.data.MagicWord

        // Check for functions
        if (!done) {
          PageElementFunction function = analysis.isInFunction(currentIndex);
          if ((function != null) &&
              (function.getBeginIndex() == currentIndex)) {
            MagicWord magicWord = function.getMagicWord();
            String magicWordName = magicWord.getName();
            boolean isOk = false;
            if (MagicWord.DEFAULT_SORT.equals(magicWordName) ||
                MagicWord.FORMAT_NUM.equals(magicWordName) ||
                MagicWord.DISPLAY_TITLE.equals(magicWordName)) {
              isOk = true;
View Full Code Here

Examples of org.wikipediacleaner.api.data.MagicWord

          aliases.add(alias);
        }
        boolean caseSensitive = (currentNode.getAttribute("case-sensitive") != null);
        magicWords.put(
            magicWord,
            new MagicWord(magicWord, aliases, caseSensitive));
      }
      wikiConfiguration.setMagicWords(magicWords);
    } catch (JDOMException e) {
      log.error("Error loading namespaces", e);
      throw new APIException("Error parsing XML", e);
View Full Code Here

Examples of org.wikipediacleaner.api.data.MagicWord

      return false;
    }

    boolean result = false;
    EnumWikipedia wiki = analysis.getWikipedia();
    MagicWord magicWordImgAlt = wiki.getWikiConfiguration().getMagicWordByName(MagicWord.IMG_ALT);
    for (PageElementImage image : analysis.getImages()) {
      String description = image.getDescription();
      if ((description == null) || (description.trim().length() == 0)) {
        String alt = image.getAlternateDescription();
        if ((alt == null) || (alt.trim().length() == 0)) {
          if (errors == null) {
            return true;
          }
          result = true;
          CheckErrorResult errorResult = createCheckErrorResult(
              analysis, image.getBeginIndex(), image.getEndIndex());

          // Action: add a description
          StringBuilder prefixFull = new StringBuilder();
          prefixFull.append("[[");
          prefixFull.append(image.getNamespace());
          prefixFull.append(":");
          prefixFull.append(image.getImage());
          StringBuilder prefixShort = new StringBuilder(prefixFull);
          if (image.getParameters() != null) {
            for (PageElementImage.Parameter param : image.getParameters()) {
              prefixFull.append("|");
              prefixFull.append(param.getContents());
              if (!magicWordImgAlt.isPossibleAlias(param.getContents())) {
                prefixShort.append("|");
                prefixShort.append(param.getContents());
              }
            }
          }
View Full Code Here

Examples of org.wikipediacleaner.api.data.MagicWord

      String namespace = (colonIndex > 0) ? templateName.substring(0, colonIndex) : null;
      if ((colonIndex > 0) &&
          (templateNamespace.isPossibleName(namespace))) {

        // Test for special situations (functions)
        MagicWord magicWord = null;
        if (templateName.length() > colonIndex + 1) {
          String afterColon = templateName.substring(colonIndex + 1);
          colonIndex = afterColon.indexOf(':');
          if (colonIndex < 0) {
            magicWord = config.getFunctionMagicWord(afterColon, false);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.