Package org.getalp.dbnary.wiki
Class WikiTool
- java.lang.Object
-
- org.getalp.dbnary.wiki.WikiTool
-
public class WikiTool extends Object
-
-
Constructor Summary
Constructors Constructor Description WikiTool()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description 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.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.static Map<String,String>
parseArgs(String argsString, boolean withTemplateName)
Deprecated.use WikiText packagestatic String
removeReferencesIn(String definition)
static String
removeTablesIn(String s)
static String
removeTextWithinParenthesesIn(String s)
static ArrayList<String>
splitUnlessInTemplateOrLink(String s, char c)
static String
toParameterString(Map<String,String> parameterMap)
-
-
-
Method Detail
-
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 packageParse 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.
-
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 senclosingStringStart
- this function returns the position of the String enclosingStringStart in String senclosingStringEnd
- 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
- Stringc
- 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
-
-