public class Chasen extends Object
Modifier and Type | Class and Description |
---|---|
class |
Chasen.Result
Result of the parsing of some text using the Chasen instance of the class.
|
Modifier and Type | Field and Description |
---|---|
static String |
EOP
End of path marker.
|
static String |
EOS
End of input line marker.
|
Constructor and Description |
---|
Chasen()
Starts a new chasen process using the default executable, no arguments and '\t' as field
separator.
|
Chasen(String args,
char separator)
Starts a new chasen process with the specified parameters, using the default executable.
|
Chasen(String chasenExecutable,
String args,
char separator)
Starts a new chasen process with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Terminates the chasen process.
|
protected void |
finalize()
Terminate Chasen process if still running.
|
protected String |
getChasenPlatformEncoding(String chasenExecutable)
Test which character encoding ChaSen uses for its input and output streams.
|
static String |
getDefaultExecutable()
Returns the path to the default ChaSen executable.
|
static boolean |
isChasenExecutable(String chasenExecutable)
Test if the chasen program is available at the specified path.
|
Chasen.Result |
parse(char[] text,
int start,
int length)
Parse some text using the chasen process of this instance.
|
static void |
setDefaultExecutable(String chasenExecutable)
Sets the path to the default ChaSen executable.
|
public static final String EOS
public static final String EOP
public Chasen() throws IOException
IOException
public Chasen(String args, char separator) throws IOException
IOException
public Chasen(String chasenExecutable, String args, char separator) throws IOException
executable
- Path to the chasen executable program.args
- Parameters passed to chasen. This can be used to customize the output format. Currently,
this implementation does not work with the "-j" (japanese sentence mode) flag.separator
- Separator char used in the format string to separate entry fields. If the
separator char is set to '\0', the list returned by
next
will contain the complete result line as
only entry.IOException
- If the chasen process can't be started.public static void setDefaultExecutable(String chasenExecutable)
public static String getDefaultExecutable()
public static boolean isChasenExecutable(String chasenExecutable)
chasenExecutable
- Full path to the chasen executable.public Chasen.Result parse(char[] text, int start, int length) throws IOException
next
method is called.
Iterating over the result set is not thread safe, if several threads use the same Chasen instance
for parsing, proper synchronization must be done:
Chasen chasen = new Chasen(...);
...
synchronized (chasen) {
Chasen.Result result = chasen.parse( text);
// iterate over result
while (result.hasNext())
...
}
text
- Text to parse. The array will be modified.IOException
- if communication with the chasen process failed.public void dispose()
protected String getChasenPlatformEncoding(String chasenExecutable)
null
if the test failed.Copyright © 2001-2013 the JGloss developers. All Rights Reserved.