org.annolab.tt4j
Class Util

java.lang.Object
  extended by org.annolab.tt4j.Util

public final class Util
extends Object

Utility functions.

Author:
Richard Eckart de Castilho

Method Summary
static void close(Closeable aClosable)
          Close the given Closeable.
static List<String> getSearchPaths(List<String> aAdditionalPaths, String aSubPath)
          Get the search paths for a model or executable.
static String join(Collection<String> aStrings, String aSeparator)
          Join the given strings into a single string separated by the given separator.
static String join(String[] aStrings, String aSeparator)
          Join the given strings into a single string separated by the given separator.
static boolean matches(String tokenSent, String tokenReturned)
          Checks if a token returned by TreeTagger corresponds to the token sent to TreeTagger.
protected static String readFile(File aFile, String aEncoding)
          For tests only.
protected static String[] tokenize(String aText, Locale aLocale)
          For tests only.
protected static void writeFile(String aText, File aFile, String aEncoding)
          For tests only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getSearchPaths

public static List<String> getSearchPaths(List<String> aAdditionalPaths,
                                          String aSubPath)
Get the search paths for a model or executable. Using the aSubPath argument, executables and models can be searched for in different locations, e.g. executables in executable and models in models.
The returned list contains the additional search paths, the value of the system property treetagger.home and the environment variables TREETAGGER_HOME and TAGDIR in this order.

Parameters:
aAdditionalPaths - additional paths to search in.
aSubPath - search in the given sub-directory of the search paths.
Returns:
a list of search paths.

join

public static String join(String[] aStrings,
                          String aSeparator)
Join the given strings into a single string separated by the given separator.

Parameters:
aStrings - strings to join.
aSeparator - a separator.
Returns:
the joined string.

join

public static String join(Collection<String> aStrings,
                          String aSeparator)
Join the given strings into a single string separated by the given separator.

Parameters:
aStrings - strings to join.
aSeparator - a separator.
Returns:
the joined string.

matches

public static boolean matches(String tokenSent,
                              String tokenReturned)
Checks if a token returned by TreeTagger corresponds to the token sent to TreeTagger. This method does not check for strict equality, because if TreeTagger does not know a character, it will return "?" instead. So this method interprets an "?" returned by TreeTagger as a single-character wildcard.

Parameters:
tokenSent - token sent to TreeTagger
tokenReturned - token returned from TreeTagger
Returns:
if the token returned matches the token sent.

close

public static void close(Closeable aClosable)
Close the given Closeable.

Parameters:
aClosable - a closable object.

readFile

protected static String readFile(File aFile,
                                 String aEncoding)
                          throws IOException
For tests only.

Throws:
IOException

writeFile

protected static void writeFile(String aText,
                                File aFile,
                                String aEncoding)
                         throws IOException
For tests only.

Throws:
IOException

tokenize

protected static String[] tokenize(String aText,
                                   Locale aLocale)
For tests only.



Copyright © 2012. All Rights Reserved.