upstream version 1.2.2
[debian/freetts] / com / sun / speech / freetts / Tokenizer.java
1 /**
2  * Portions Copyright 2001 Sun Microsystems, Inc.
3  * Portions Copyright 1999-2001 Language Technologies Institute, 
4  * Carnegie Mellon University.
5  * All Rights Reserved.  Use is subject to license terms.
6  * 
7  * See the file "license.terms" for information on usage and
8  * redistribution of this file, and for a DISCLAIMER OF ALL 
9  * WARRANTIES.
10  */
11 package com.sun.speech.freetts;
12
13 import java.io.Reader;
14
15 /**
16  * Chops a string or text file into Token instances.
17  */
18 public interface Tokenizer {
19     /**
20      * Sets the text to be tokenized by this tokenizer.
21      *
22      * @param textToTokenize  the text to tokenize
23      */
24     void setInputText(String textToTokenize);
25
26     /**
27      * Sets the input reader.
28      *
29      * @param  reader the input source
30      */
31     void setInputReader(Reader reader);
32     
33     
34     /**
35      * Returns the next token.
36      *
37      * @return  the next token if it exists; otherwise null
38      */
39     Token getNextToken();
40
41
42     /**
43      * Returns true if there are more tokens, false otherwise.
44      *
45      * @return true if there are more tokens; otherwise false
46      */
47     boolean hasMoreTokens();
48
49     /**
50      * Returns true if there were errors while reading tokens.
51      *
52      * @return true if there were errors; otherwise false
53      */
54     boolean hasErrors();
55
56     /**
57      * If hasErrors returns true, returns a description of the error
58      * encountered.  Otherwise returns null.
59      *
60      * @return a description of the last error that occurred
61      */
62     String getErrorDescription();
63
64     /**
65      * Sets the whitespace symbols of this Tokenizer to the given
66      * symbols.
67      * 
68      * @param symbols the whitespace symbols
69      */
70     void setWhitespaceSymbols(String symbols);
71
72     /**
73      * Sets the single character symbols of this Tokenizer to the given
74      * symbols.
75      *
76      * @param symbols the single character symbols
77      */
78     void setSingleCharSymbols(String symbols);
79
80     /**
81      * Sets the prepunctuation symbols of this Tokenizer to the given
82      * symbols.
83      *
84      * @param symbols the prepunctuation symbols
85      */
86     void setPrepunctuationSymbols(String symbols);
87
88     /**
89      * Sets the postpunctuation symbols of this Tokenizer to the given
90      * symbols.
91      *
92      * @param symbols the postpunctuation symbols
93      */
94     void setPostpunctuationSymbols(String symbols);
95
96     /**
97      * Determines if the current token should start a new sentence.
98      *
99      * @return true if a new sentence should be started
100      */
101     boolean isBreak();
102 }