## edu.stanford.nlp.util
Class StringUtils

    java.lang.Object
      edu.stanford.nlp.util.StringUtils

    public class StringUtils

extends Object

StringUtils is a class for random String things, including output formatting and command line argument parsing.

Author:
  Dan Klein, Christopher Manning, Tim Grow (grow@stanford.edu), Chris Cox

Field Summary
`static String[]` `EMPTY_STRING_ARRAY`

Method Summary
`static Map<String,String[]>` `argsToMap(String[] args)` Parses command line arguments into a Map.
`static Map<String,String[]>` `argsToMap(String[] args, Map<String,Integer> flagsToNumArgs)` Parses command line arguments into a Map.
`static Properties` `argsToProperties(String[] args)` In this version each flag has zero or one argument.
`static Properties` `argsToProperties(String[] args, Map<String,Integer> flagsToNumArgs)` Analagous to `argsToMap(java.lang.String[])`.
`static String` `capitalize(String s)` Uppercases the first character of a string.
`static String` `chomp(Object o)` Returns the result of calling toString() on the supplied Object, but with any trailing '\n' removed.
`static String` `chomp(String s)` Returns the supplied string with any trailing '\n' removed.
`static boolean` `containsIgnoreCase(Collection<String> c, String s)` Convenience method: a case-insensitive variant of Collection.contains
`static int` `editDistance(String s, String t)` Computes the Levenshtein (edit) distance of the two given Strings.
`static String` `escapeString(String s, char[] charsToEscape, char escapeChar)`
`static String` `fileNameClean(String s)` Returns a "clean" version of the given filename in which spaces have been converted to dashes and all non-alphanumeric chars are underscores.
`static boolean` `find(String str, String regex)` Say whether this regular expression can be found inside this String.
`static String` `getBaseName(String fileName)` Strip directory from filename.
`static String` `getBaseName(String fileName, String suffix)` Strip directory and suffix from filename.
`static String` `getShortClassName(Object o)` Returns a short class name for an object.
`static boolean` `isAcronym(String s)` Given a String the method uses Regex to check if the String looks like an acronym
`static boolean` `isAlpha(String s)` Given a String the method uses Regex to check if the String only contains alphabet characters
`static boolean` `isAlphanumeric(String s)` Given a String the method uses Regex to check if the String only contains alphanumeric characters
`static boolean` `isCapitalized(String s)` Check if a string begins with an uppercase.
`static boolean` `isNumeric(String s)` Given a String the method uses Regex to check if the String only contains numeric characters
`static boolean` `isPunct(String s)` Given a String the method uses Regex to check if the String only contains punctuation characters
`static String` `join(Iterable<?> l)` Joins elems with a space.

`static

`<X> String`

`

`join(Iterable<X> l, String glue)`
Joins each elem in the `Collection` with the given glue.

`static String` `join(Object[] elements)` Joins elems with a space.
`static String` `join(Object[] elements, String glue)` Joins each elem in the array with the given glue.
`static int` `longestCommonContiguousSubstring(String s, String t)` Computes the longest common contiguous substring of s and t.
`static int` `longestCommonSubstring(String s, String t)` Computes the longest common substring of s and t.
`static boolean` `lookingAt(String str, String regex)` Say whether this regular expression can be found at the beginning of this String.
`static void` `main(String[] args)` Tests the string edit distance function.
`static String` `makeAsciiTable(Object[][] table, Object[] rowLabels, Object[] colLabels, int padLeft, int padRight, boolean tsv)` Returns an text table containing the matrix of Strings passed in.
`static String` `makeHTMLTable(String[][] table, String[] rowLabels, String[] colLabels)` Returns an HTML table containing the matrix of Strings passed in.
`static String[]` `mapStringToArray(String map)` Takes a string of the form "x1=y1,x2=y2,..." such that each y is an integer and each x is a key.
`static boolean` `matches(String str, String regex)` Say whether this regular expression matches this String.
`static int` `nthIndex(String s, char ch, int n)` Returns the index of the nth occurrence of ch in s, or -1 if there are less than n occurrences of ch.
`static String` `pad(Object obj, int totalChars)` Pads the toString value of the given Object.
`static String` `pad(String str, int totalChars)` Return a String of length a minimum of totalChars characters by padding the input String str at the right end with spaces.
`static String` `padLeft(double d, int totalChars)`
`static String` `padLeft(int i, int totalChars)`
`static String` `padLeft(Object obj, int totalChars)`
`static String` `padLeft(String str, int totalChars)` Pads the given String to the left with spaces to ensure that it's at least totalChars long.
`static String` `padLeft(String str, int totalChars, char ch)` Pads the given String to the left with the given character to ensure that it's at least totalChars long.
`static String` `padLeftOrTrim(String str, int num)` Pad or trim so as to produce a string of exactly a certain length.
`static String` `padOrTrim(Object obj, int totalChars)` Pad or trim the toString value of the given Object.
`static String` `padOrTrim(String str, int num)` Pad or trim so as to produce a string of exactly a certain length.
`static Map<String,String>` `parseCommandLineArguments(String[] args)` A simpler form of command line argument parsing.
`static Map<String,Object>` `parseCommandLineArguments(String[] args, boolean parseNumbers)` A simpler form of command line argument parsing.
`static String` `pennPOSToWordnetPOS(String s)` Computes the WordNet 2.0 POS tag corresponding to the PTB POS tag s.
`static void` `printErrInvocationString(String cls, String[] args)`
`static void` `printStringOneCharPerLine(String s)`
`static void` `printToFile(File file, String message)` Prints to a file.
`static void` `printToFile(File file, String message, boolean append)` Prints to a file.
`static void` `printToFile(File file, String message, boolean append, boolean printLn, String encoding)` Prints to a file.
`static void` `printToFile(String filename, String message)` Prints to a file.
`static void` `printToFile(String filename, String message, boolean append)` Prints to a file.
`static void` `printToFileLn(File file, String message, boolean append)` Prints to a file.
`static void` `printToFileLn(String filename, String message, boolean append)` Prints to a file.
`static String` `repeat(String s, int times)`
`static String` `searchAndReplace(String text, String from, String to)`
`static List<String>` `split(String s)` Splits on whitespace (\\s+).
`static List<String>` `split(String str, String regex)` Splits the given string using the given regex as delimiters.
`static String[]` `splitOnCharWithQuoting(String s, char splitChar, char quoteChar, char escapeChar)` This function splits the String s into multiple Strings using the splitChar.
`static Properties` `stringToProperties(String str)` This method converts a comma-separated String (with whitespace optionally allowed after the comma) representing properties to a Properties object.
`static Properties` `stringToProperties(String str, Properties props)` This method updates a Properties object based on a comma-separated String (with whitespace optionally allowed after the comma) representing properties to a Properties object.
`static String` `stripNonAlphaNumerics(String orig)`
`static String` `stripSGML(String orig)`
`static String` `toAscii(String s)`
`static String` `toCSVString(String[] fields)`
`static String` `toInvocationString(String cls, String[] args)`
`static String` `tr(String input, String from, String to)` Swap any occurances of any characters in the from String in the input String with the corresponding character from the to String.
`static String` `trim(Object obj, int maxWidth)`
`static String` `trim(String s, int maxWidth)` Returns s if it's at most maxWidth chars, otherwise chops right side to fit.
`static String` `truncate(int n, int smallestDigit, int biggestDigit)` This returns a string from decimal digit smallestDigit to decimal digit biggest digit.
`static List<String>` `valueSplit(String str, String valueRegex, String separatorRegex)` Split a string into tokens.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### EMPTY_STRING_ARRAY

    public static final String[] EMPTY_STRING_ARRAY

Method Detail

### find

    public static boolean find(String str,
                               String regex)

  Say whether this regular expression can be found inside this String. This method provides one of the two "missing" convenience methods for regular expressions in the String class in JDK1.4. This is the one you'll want to use all the time if you're used to Perl. What were they smoking?

  Parameters:
    `str` - String to search for match in
    `regex` - String to compile as the regular expression
  Returns:
    Whether the regex can be found in str

### containsIgnoreCase

    public static boolean containsIgnoreCase(Collection<String> c,
                                             String s)

  Convenience method: a case-insensitive variant of Collection.contains

  Parameters:
    `c` - Collection<String>
    `s` - String
  Returns:
    true if s case-insensitively matches a string in c

### lookingAt

    public static boolean lookingAt(String str,
                                    String regex)

  Say whether this regular expression can be found at the beginning of this String. This method provides one of the two "missing" convenience methods for regular expressions in the String class in JDK1.4.

  Parameters:
    `str` - String to search for match at start of
    `regex` - String to compile as the regular expression
  Returns:
    Whether the regex can be found at the start of str

### mapStringToArray

    public static String[] mapStringToArray(String map)

  Takes a string of the form "x1=y1,x2=y2,..." such that each y is an integer and each x is a key. A String[] s is returned such that s[yn]=xn

  Parameters:
    `map` - A string of the form "x1=y1,x2=y2,..." such that each y is an integer and each x is a key.
  Returns:
    A String[] s is returned such that s[yn]=xn

### matches

    public static boolean matches(String str,
                                  String regex)

  Say whether this regular expression matches this String. This method is the same as the String.matches() method, and is included just to give a call that is parallel to the other static regex methods in this class.

  Parameters:
    `str` - String to search for match at start of
    `regex` - String to compile as the regular expression
  Returns:
    Whether the regex matches the whole of this str

### join

    public static <X> String join(Iterable<X> l,
                                  String glue)

  Joins each elem in the `Collection` with the given glue. For example, given a list of `Integers`, you can create a comma-separated list by calling `join(numbers, ", ")`.

### join

    public static String join(Object[] elements,
                              String glue)

  Joins each elem in the array with the given glue. For example, given a list of ints, you can create a comma-separated list by calling `join(numbers, ", ")`.

### join

    public static String join(Iterable<?> l)

  Joins elems with a space.

### join

    public static String join(Object[] elements)

  Joins elems with a space.

### split

    public static List<String> split(String s)

  Splits on whitespace (\\s+).

  Parameters:
    `s` - String to split
  Returns:
    List<String> of split strings

### split

    public static List<String> split(String str,
                                     String regex)

  Splits the given string using the given regex as delimiters. This method is the same as the String.split() method (except it throws the results in a List), and is included just to give a call that is parallel to the other static regex methods in this class.

  Parameters:
    `str` - String to split up
    `regex` - String to compile as the regular expression
  Returns:
    List of Strings resulting from splitting on the regex

### valueSplit

    public static List<String> valueSplit(String str,
                                          String valueRegex,
                                          String separatorRegex)

  Split a string into tokens. Because there is a tokenRegex as well as a separatorRegex (unlike for the conventional split), you can do things like correctly split quoted strings or parenthesized arguments. However, it doesn't do the unquoting of quoted Strings for you. An empty String argument is returned at the beginning, if valueRegex accepts the empty String and str begins with separatorRegex. But str can end with either valueRegex or separatorRegex and this does not generate an empty String at the end (indeed, valueRegex need not even accept the empty String in this case. However, if it does accept the empty String and there are multiple trailing separators, then empty values will be returned.

  Parameters:
    `str` - The String to split
    `valueRegex` - Must match a token. You may wish to let it match the empty String
    `separatorRegex` - Must match a separator
  Returns:
    The List of tokens
  Throws:
    `IllegalArgumentException` - if str cannot be tokenized by the two regex

### pad

    public static String pad(String str,
                             int totalChars)

  Return a String of length a minimum of totalChars characters by padding the input String str at the right end with spaces. If str is already longer than totalChars, it is returned unchanged.

### pad

    public static String pad(Object obj,
                             int totalChars)

  Pads the toString value of the given Object.

### padOrTrim

    public static String padOrTrim(String str,
                                   int num)

  Pad or trim so as to produce a string of exactly a certain length.

  Parameters:
    `str` - The String to be padded or truncated
    `num` - The desired length

### padLeftOrTrim

    public static String padLeftOrTrim(String str,
                                       int num)

  Pad or trim so as to produce a string of exactly a certain length.

  Parameters:
    `str` - The String to be padded or truncated
    `num` - The desired length

### padOrTrim

    public static String padOrTrim(Object obj,
                                   int totalChars)

  Pad or trim the toString value of the given Object.

### padLeft

    public static String padLeft(String str,
                                 int totalChars,
                                 char ch)

  Pads the given String to the left with the given character to ensure that it's at least totalChars long.

### padLeft

    public static String padLeft(String str,
                                 int totalChars)

  Pads the given String to the left with spaces to ensure that it's at least totalChars long.

### padLeft

    public static String padLeft(Object obj,
                                 int totalChars)

### padLeft

    public static String padLeft(int i,
                                 int totalChars)

### padLeft

    public static String padLeft(double d,
                                 int totalChars)

### trim

    public static String trim(String s,
                              int maxWidth)

  Returns s if it's at most maxWidth chars, otherwise chops right side to fit.

### trim

    public static String trim(Object obj,
                              int maxWidth)

### repeat

    public static String repeat(String s,
                                int times)

### fileNameClean

    public static String fileNameClean(String s)

  Returns a "clean" version of the given filename in which spaces have been converted to dashes and all non-alphanumeric chars are underscores.

### nthIndex

    public static int nthIndex(String s,
                               char ch,
                               int n)

  Returns the index of the nth occurrence of ch in s, or -1 if there are less than n occurrences of ch.

### truncate

    public static String truncate(int n,
                                  int smallestDigit,
                                  int biggestDigit)

  This returns a string from decimal digit smallestDigit to decimal digit biggest digit. Smallest digit is labeled 1, and the limits are inclusive.

### argsToMap

    public static Map<String,String[]> argsToMap(String[] args)

  Parses command line arguments into a Map. Arguments of the form

  -flag1 arg1a arg1b ... arg1m -flag2 -flag3 arg3a ... arg3n

  will be parsed so that the flag is a key in the Map (including the hyphen) and its value will be a `String`[] containing the optional arguments (if present). The non-flag values not captured as flag arguments are collected into a String[] array and returned as the value of `null` in the Map. In this invocation, flags cannot take arguments, so all the `String` array values other than the value for `null` will be zero-length.

  Parameters:
    `args` - A command-line arguments array
  Returns:
    a `Map` of flag names to flag argument `String` arrays.

### argsToMap

    public static Map<String,String[]> argsToMap(String[] args,
                                                 Map<String,Integer> flagsToNumArgs)

  Parses command line arguments into a Map. Arguments of the form

  -flag1 arg1a arg1b ... arg1m -flag2 -flag3 arg3a ... arg3n

  will be parsed so that the flag is a key in the Map (including the hyphen) and its value will be a `String`[] containing the optional arguments (if present). The non-flag values not captured as flag arguments are collected into a String[] array and returned as the value of `null` in the Map. In this invocation, the maximum number of arguments for each flag can be specified as an `Integer` value of the appropriate flag key in the `flagsToNumArgs` `Map` argument. (By default, flags cannot take arguments.)

  Example of usage:

  `Map flagsToNumArgs = new HashMap(); flagsToNumArgs.put("-x",new Integer(2)); flagsToNumArgs.put("-d",new Integer(1)); Map result = argsToMap(args,flagsToNumArgs);`

  If a given flag appears more than once, the extra args are appended to the String[] value for that flag.

  Parameters:
    `args` - the argument array to be parsed
    `flagsToNumArgs` - a `Map` of flag names to `Integer` values specifying the maximum number of allowed arguments for that flag (default 0).
  Returns:
    a `Map` of flag names to flag argument `String` arrays.

### argsToProperties

    public static Properties argsToProperties(String[] args)

  In this version each flag has zero or one argument. It has one argument if there is a thing following a flag that does not begin with '-'. See `argsToProperties(String[], Map)` for full documentation.

  Parameters:
    `args` - Command line arguments
  Returns:
    A Properties object representing the arguments.

### argsToProperties

    public static Properties argsToProperties(String[] args,
                                              Map<String,Integer> flagsToNumArgs)

  Analagous to `argsToMap(java.lang.String[])`. However, there are several key differences between this method and `argsToMap(java.lang.String[])`:
  - Hyphens are stripped from flag names
  - Since Properties objects are String to String mappings, the default number of arguments to a flag is assumed to be 1 and not 0.
  - Furthermore, the list of arguments not bound to a flag is mapped to the "" property, not null
  - The special flags "-prop", "-props", or "-properties" will load the property file specified by its argument.
  - The value for flags without arguments is set to "true"
  - If a flag has multiple arguments, the value of the property is all of the arguments joined together with a space (" ") character between them.
  - The value strings are trimmed so trailing spaces do not stop you from loading a file

  Parameters:
    `args` - Command line arguments
    `flagsToNumArgs` - Map of how many arguments flags should have. The keys are without the minus signs.
  Returns:
    A Properties object representing the arguments.

### stringToProperties

    public static Properties stringToProperties(String str)

  This method converts a comma-separated String (with whitespace optionally allowed after the comma) representing properties to a Properties object. Each property is "property=value". The value for properties without an explicitly given value is set to "true". This can be used for a 2nd level of properties, for example, when you have a comamndline argument like "-outputOptions style=xml,tags".

### stringToProperties

    public static Properties stringToProperties(String str,
                                                Properties props)

  This method updates a Properties object based on a comma-separated String (with whitespace optionally allowed after the comma) representing properties to a Properties object. Each property is "property=value". The value for properties without an explicitly given value is set to "true".

### printToFile

    public static void printToFile(File file,
                                   String message,
                                   boolean append,
                                   boolean printLn,
                                   String encoding)

  Prints to a file. If the file already exists, appends if `append=true`, and overwrites if `append=false`.

### printToFileLn

    public static void printToFileLn(File file,
                                     String message,
                                     boolean append)

  Prints to a file. If the file already exists, appends if `append=true`, and overwrites if `append=false`.

### printToFile

    public static void printToFile(File file,
                                   String message,
                                   boolean append)

  Prints to a file. If the file already exists, appends if `append=true`, and overwrites if `append=false`.

### printToFile

    public static void printToFile(File file,
                                   String message)

  Prints to a file. If the file does not exist, rewrites the file; does not append.

### printToFile

    public static void printToFile(String filename,
                                   String message,
                                   boolean append)

  Prints to a file. If the file already exists, appends if `append=true`, and overwrites if `append=false`

### printToFileLn

    public static void printToFileLn(String filename,
                                     String message,
                                     boolean append)

  Prints to a file. If the file already exists, appends if `append=true`, and overwrites if `append=false`

### printToFile

    public static void printToFile(String filename,
                                   String message)

  Prints to a file. If the file does not exist, rewrites the file; does not append.

### parseCommandLineArguments

    public static Map<String,String> parseCommandLineArguments(String[] args)

  A simpler form of command line argument parsing. Dan thinks this is highly superior to the overly complexified code that comes before it. Parses command line arguments into a Map. Arguments of the form -flag1 arg1 -flag2 -flag3 arg3 will be parsed so that the flag is a key in the Map (including the hyphen) and the optional argument will be its value (if present).

  Returns:
    A Map from keys to possible values (String or null)

### parseCommandLineArguments

    public static Map<String,Object> parseCommandLineArguments(String[] args,
                                                               boolean parseNumbers)

  A simpler form of command line argument parsing. Dan thinks this is highly superior to the overly complexified code that comes before it. Parses command line arguments into a Map. Arguments of the form -flag1 arg1 -flag2 -flag3 arg3 will be parsed so that the flag is a key in the Map (including the hyphen) and the optional argument will be its value (if present). In this version, if the argument is numeric, it will be a Double value in the map, not a String.

  Returns:
    A Map from keys to possible values (String or null)

### stripNonAlphaNumerics

    public static String stripNonAlphaNumerics(String orig)

### stripSGML

    public static String stripSGML(String orig)

### printStringOneCharPerLine

    public static void printStringOneCharPerLine(String s)

### escapeString

    public static String escapeString(String s,
                                      char[] charsToEscape,
                                      char escapeChar)

### splitOnCharWithQuoting

    public static String[] splitOnCharWithQuoting(String s,
                                                  char splitChar,
                                                  char quoteChar,
                                                  char escapeChar)

  This function splits the String s into multiple Strings using the splitChar. However, it provides a quoting facility: it is possible to quote strings with the quoteChar. If the quoteChar occurs within the quotedExpression, it must be prefaced by the escapeChar

  Parameters:
    `s` - The String to split
    `splitChar` - The character to split on
    `quoteChar` - The character to quote items with
    `escapeChar` - The character to escape the quoteChar with
  Returns:
    An array of Strings that s is split into

### longestCommonSubstring

    public static int longestCommonSubstring(String s,
                                             String t)

  Computes the longest common substring of s and t. The longest common substring of a and b is the longest run of characters that appear in order inside both a and b. Both a and b may have other extraneous characters along the way. This is like edit distance but with no substitution and a higher number means more similar. For example, the LCS of "abcD" and "aXbc" is 3 (abc).

### longestCommonContiguousSubstring

    public static int longestCommonContiguousSubstring(String s,
                                                       String t)

  Computes the longest common contiguous substring of s and t. The LCCS is the longest run of characters that appear consecutively in both s and t. For instance, the LCCS of "color" and "colour" is 4, because of "colo".

### editDistance

    public static int editDistance(String s,
                                   String t)

  Computes the Levenshtein (edit) distance of the two given Strings.

### pennPOSToWordnetPOS

    public static String pennPOSToWordnetPOS(String s)

  Computes the WordNet 2.0 POS tag corresponding to the PTB POS tag s.

  Parameters:
    `s` - a Penn TreeBank POS tag.

### getShortClassName

    public static String getShortClassName(Object o)

  Returns a short class name for an object. This is the class name stripped of any package name.

  Returns:
    The name of the class minus a package name, for example `ArrayList`

### capitalize

    public static String capitalize(String s)

  Uppercases the first character of a string.

  Parameters:
    `s` - a string to capitalize
  Returns:
    a capitalized version of the string

### isCapitalized

    public static boolean isCapitalized(String s)

  Check if a string begins with an uppercase.

  Parameters:
    `s` - a string
  Returns:
    true if the string is capitalized false otherwise

### searchAndReplace

    public static String searchAndReplace(String text,
                                          String from,
                                          String to)

### makeHTMLTable

    public static String makeHTMLTable(String[][] table,
                                       String[] rowLabels,
                                       String[] colLabels)

  Returns an HTML table containing the matrix of Strings passed in. The first dimension of the matrix should represent the rows, and the second dimension the columns.

### makeAsciiTable

    public static String makeAsciiTable(Object[][] table,
                                        Object[] rowLabels,
                                        Object[] colLabels,
                                        int padLeft,
                                        int padRight,
                                        boolean tsv)

  Returns an text table containing the matrix of Strings passed in. The first dimension of the matrix should represent the rows, and the second dimension the columns.

### main

    public static void main(String[] args)

  Tests the string edit distance function.

### toAscii

    public static String toAscii(String s)

### toCSVString

    public static String toCSVString(String[] fields)

### tr

    public static String tr(String input,
                            String from,
                            String to)

  Swap any occurances of any characters in the from String in the input String with the corresponding character from the to String. As Perl tr, for example, tr("chris", "irs", "mop").equals("chomp"), except it does not support regular expression character ranges.

  Note: This is now optimized to not allocate any objects if the input is returned unchanged.

### chomp

    public static String chomp(String s)

  Returns the supplied string with any trailing '\n' removed.

### chomp

    public static String chomp(Object o)

  Returns the result of calling toString() on the supplied Object, but with any trailing '\n' removed.

### printErrInvocationString

    public static void printErrInvocationString(String cls,
                                                String[] args)

### toInvocationString

    public static String toInvocationString(String cls,
                                            String[] args)

### getBaseName

    public static String getBaseName(String fileName)

  Strip directory from filename. Like Unix 'basename'.

  Example: `getBaseName("/u/wcmac/foo.txt") ==> "foo.txt"`

### getBaseName

    public static String getBaseName(String fileName,
                                     String suffix)

  Strip directory and suffix from filename. Like Unix 'basename'.

  Example: `getBaseName("/u/wcmac/foo.txt", "") ==> "foo.txt"`
  Example: `getBaseName("/u/wcmac/foo.txt", ".txt") ==> "foo"`
  Example: `getBaseName("/u/wcmac/foo.txt", ".pdf") ==> "foo.txt"`

### isAlpha

    public static boolean isAlpha(String s)

  Given a String the method uses Regex to check if the String only contains alphabet characters

  Parameters:
    `s` - a String to check using regex
  Returns:
    true if the String is valid

### isNumeric

    public static boolean isNumeric(String s)

  Given a String the method uses Regex to check if the String only contains numeric characters

  Parameters:
    `s` - a String to check using regex
  Returns:
    true if the String is valid

### isAlphanumeric

    public static boolean isAlphanumeric(String s)

  Given a String the method uses Regex to check if the String only contains alphanumeric characters

  Parameters:
    `s` - a String to check using regex
  Returns:
    true if the String is valid

### isPunct

    public static boolean isPunct(String s)

  Given a String the method uses Regex to check if the String only contains punctuation characters

  Parameters:
    `s` - a String to check using regex
  Returns:
    true if the String is valid

### isAcronym

    public static boolean isAcronym(String s)

  Given a String the method uses Regex to check if the String looks like an acronym

  Parameters:
    `s` - a String to check using regex
  Returns:
    true if the String is valid

Stanford NLP Group