|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecthultig.util.Toolkit
public class Toolkit
The Toolkit class contains various static methods being used within this library. It gathers a set of auxiliary functions, ranging from string manipulation to basic mathematical functions, that are used in a variety of classes, throughout the library.
University of Beira Interior (UBI)
Centre For Human Language Technology and Bioinformatics (HULTIG)
| Field Summary | |
|---|---|
static PrintStream |
out
A shortcut for the standard output. |
| Constructor Summary | |
|---|---|
Toolkit()
Default constructor. |
|
Toolkit(String encoding)
Constructor with encoding definition. |
|
| Method Summary | |
|---|---|
static int |
countLines(String filename)
Counts the number of lines in a given file. |
static long |
countPattern(String pattern,
String filename)
Counts the occurrence of a regular expression in a given text file. |
static int[] |
createRandomSample(int size,
int max)
Creates an ordered random sample of integers, between 0 and max, uniformly distributed. |
static double |
dotProduct(double[] u,
double[] v)
Computes the dot product between two vectors, represented by two arrays. |
static boolean |
execute(String command)
Executes a specific command in the operating system. |
static double |
Fmeasure(double precision,
double recall)
Computes the F-measure, for a given precision and recall. |
static double |
Fmeasure(double precision,
double recall,
double beta)
Computes the F-measure, for a given precision, recall, and beta parameter. |
static void |
formatedWrite(String s,
int nmx,
String sleft,
String sright)
Outputs a string with a maximum number of columns. |
static String |
joinStrings(String[] vs)
Concatenates the strings contained in an array, joining them through the space character, as a string separator. |
static String |
joinStrings(String[] vs,
char separator)
Concatenates the strings contained in an array, joining them through a given separator character. |
static double |
log(double x,
double base)
Computes the log value in a given base. |
static double |
log2(double x)
Gives the logarithm in base 2. |
static double |
maximum(double a,
double b,
double c)
The maximum, among three values. |
static int |
maximum(int a,
int b,
int c)
The maximum, among three values. |
static int |
minGreaterThan(int infimum,
int[] v)
Gives the smallest value from an array, which is greater than a given infimum value. |
static float |
minimum(float a,
float b,
float c)
The minimum, among three values. |
static int |
minimum(int a,
int b,
int c)
The minimum, among three values. |
static String |
moment()
Gives a string containing the current moment, in terms of year, month, day, hour, minute, and second. |
static boolean |
nulity(Object... oset)
Tests the nullity of an array of objects. |
static String |
padLeft(String s,
int n)
Transforms a string into one with a given length, by filling its left hand side with spaces. |
static String |
padRight(String s,
int n)
Transforms a string into one with a given length, by filling its right hand side with spaces. |
static void |
pause()
Makes a pause in the standard output flow, waiting for the user to hit the RETURN key. |
static void |
pause(String message)
Makes a pause in the standard output flow, waiting for the user to hit the RETURN key, and prompting him with a message. |
static void |
print(double[] v)
Outputs an array of double values. |
static void |
print(int[] v)
Outputs an array of integer values. |
static void |
print(String s)
A shortcut for the standard print. |
static void |
print(String[] v)
Outputs a static array of strings. |
static void |
print(String[] v,
boolean indexes)
Outputs a static array of strings. |
static void |
printf(String format,
Object... args)
A shortcut for the printf function. |
static void |
printHistogram(int[] v,
int maxbars)
Outputs the histogram corresponding to a given array of integers. |
static void |
println(String s)
A shortcut for the standard println. |
static void |
printVector(String prefix,
int[] v)
Outputs an array of integers. |
static double |
probGoodText(String s)
Computes the likelihood to have text, for a given string. |
static String[] |
readFile(String filename,
String encoding,
int limit)
Reads a certain number of lines from a given file, through a specific encoding format. |
static String |
readLn()
A static method for reading a string from the standard input. |
static void |
sclean(String[] vs,
String chset)
Cleans all strings in a given array, by eliminating any character from a given set. |
static String |
sclean(String s,
String chset)
Cleans a string by eliminating any character contained in a givens set of characters. |
static String |
sline(char c,
int size)
Constructs a string of repeated characters, with a given size. |
static String |
sline(int size)
Generates a '-' string with a given size. |
static String |
sprintf(String format,
Object... args)
The sprintf function, similar to the one existing in the C language. |
static double |
sqr(double x)
Gives the square of a value. |
static String |
underscore(int size)
Generates a string of underscores, with a given length. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static PrintStream out
| Constructor Detail |
|---|
public Toolkit()
public Toolkit(String encoding)
| Method Detail |
|---|
public static String readLn()
public static void pause()
public static void pause(String message)
message - The pause prompt message.public static void print(String s)
s - The string to be written.public static void println(String s)
s - The string to be written.
public static String sprintf(String format,
Object... args)
format - The format string.args - The array of objects to be inserted in the corresponding
positions, defined by the format string.
public static void printf(String format,
Object... args)
format - The format string.args - The array of objects to be inserted in the corresponding
positions, defined by the format string.
public static void print(String[] v,
boolean indexes)
v - String[] The array of strings to be printed.indexes - If true, array indexes will be printed.public static void print(String[] v)
v - The array of strings to be printed.public static void print(int[] v)
v - The array to be printed.public static void print(double[] v)
v - The array to be printed.
public static void printVector(String prefix,
int[] v)
prefix - The prefix string.v - The array to be printed.
public static String sline(char c,
int size)
c - The string character.size - The string length.
public static String sline(int size)
size - The string length.
public static String underscore(int size)
size - The length of the generated string
public static String padLeft(String s,
int n)
s - The string to be transformed.n - The string's output length.
public static String padRight(String s,
int n)
s - The string to be transformed.n - The string's output length.
public static String joinStrings(String[] vs)
vs - The array of strings
public static String joinStrings(String[] vs,
char separator)
vs - The array of strings.separator - The separator.
public static String sclean(String s,
String chset)
s - The string to be cleaned.chset - The set of characters to eliminate.
public static void sclean(String[] vs,
String chset)
vs - The array of strings to be cleaned.chset - The character set to eliminate.public static String moment()
public static void formatedWrite(String s,
int nmx,
String sleft,
String sright)
s - The string to be writtennmx - The maximum number of columns.sleft - The left context string, possibly a sequence of spaces.sright - The right context string.
public static long countPattern(String pattern,
String filename)
pattern - The regular expression to be counted.filename - The name of the text file.
public static String[] readFile(String filename,
String encoding,
int limit)
filename - The name of the file to be read.encoding - The encoding string.limit - The number of lines.
public static int countLines(String filename)
filename - The file name.
public static int[] createRandomSample(int size,
int max)
size - int The sample size.max - int The sample maximum value.
public static boolean execute(String command)
command - The command string to be executed.public static boolean nulity(Object... oset)
oset - The variable array of objects.
public static int minimum(int a,
int b,
int c)
a - valueb - valuec - value
public static float minimum(float a,
float b,
float c)
a - valueb - valuec - value
public static int maximum(int a,
int b,
int c)
a - valueb - valuec - value
public static double maximum(double a,
double b,
double c)
a - valueb - valuec - value
public static int minGreaterThan(int infimum,
int[] v)
infimum - The infimum value.v - The array from which to extract the value.
public static double dotProduct(double[] u,
double[] v)
u - Represents one vector.v - Represents the other vector.
public static double probGoodText(String s)
s - The string to be measured.
public static double sqr(double x)
x - The value to be squared.
public static double log(double x,
double base)
x - The input value.base - The base value.
public static double log2(double x)
x - The input value.
public static double Fmeasure(double precision,
double recall)
precision - The precision value.recall - the recall value.
public static double Fmeasure(double precision,
double recall,
double beta)
precision - The precision value;recall - The recall valuebeta - The beta parameter.
public static void printHistogram(int[] v,
int maxbars)
v - The array of values for the histogram.maxbars - The maximum number of bars printed. That is,
for the maximum value of maxbars bars will be
printed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||