Class WikiTool

java.lang.Object
org.getalp.dbnary.wiki.WikiTool

public class WikiTool extends Object
  • Constructor Details

    • WikiTool

      public WikiTool()
  • Method Details

    • parseArgs

      @Deprecated public static Map<String,String> parseArgs(String argsString)
      Deprecated.
      Parse the args of a Template, e.g., parses a string like xxx=yyy|zzz=ttt It can handle nested parentheses, e.g., xxx=yyy|zzz={{aaa=bbb|ccc=ddd}}|kkk=hhh and xxx=yyy|zzz=[[aaa|bbb|ccc]]|kkk=hhh.
      Parameters:
      argsString - the String containing all the args (the part of a template contained after the first pipe).
      Returns:
      a Map associating each argument name with its value.
    • parseArgs

      @Deprecated public static Map<String,String> parseArgs(String argsString, boolean withTemplateName)
      Deprecated.
      use WikiText package
      Parse the args of a Template, e.g., parses a string like xxx=yyy|zzz=ttt It can handle nested parentheses, e.g., xxx=yyy|zzz={{aaa=bbb|ccc=ddd}}|kkk=hhh and xxx=yyy|zzz=[[aaa|bbb|ccc]]|kkk=hhh. If withTemplateName is true, the first argument will be considered as the template name and added to the parseArgs under key "0"
      Parameters:
      argsString - the String containing all the args (the part of a template contained after the first pipe).
      withTemplateName - pass true if the argString starts with the template name
      Returns:
      a Map associating each argument name with its value.
    • removeReferencesIn

      public static String removeReferencesIn(String definition)
    • removeTablesIn

      public static String removeTablesIn(String s)
    • removeTextWithinParenthesesIn

      public static String removeTextWithinParenthesesIn(String s)
    • locateEnclosedString

      public static ArrayList<Span> locateEnclosedString(String s, String enclosingStringStart, String enclosingStringEnd)
      This function locates the start and end position of two symbols (enclosingStringStart and enclosingStringEnd) in input String s. It can handle nested symbols e.g., locateEnclosedString("string {{at}}","{{","}}") returns (7,13) e.g., locateEnclosedString("string {{at {{position}} }}","{{","}}") returns (7,27)
      Parameters:
      s - the string to be parsed, this function returns the position of the second parameter enclosingStringStart and the position of the third parameter enclosingStringEnd in string s
      enclosingStringStart - this function returns the position of the String enclosingStringStart in String s
      enclosingStringEnd - this function returns the position of the String enclosingStringEn in String s
      Returns:
      an ArrayList with the start and ens positions of the enclosing Strings in input String s
    • splitUnlessInTemplateOrLink

      public static ArrayList<String> splitUnlessInTemplateOrLink(String s, char c)
      Parameters:
      s - String
      c - character
      Returns:
      an ArrayList of String This function takes as input a String s and a character or separator c, and splits s into an ArrayList of Strings using separator c, unless character c falls inside a wiki link or a wiki template
    • toParameterString

      public static String toParameterString(Map<String,String> parameterMap)