public class PartOfSpeechImpl extends Object implements PartOfSpeech
PartOfSpeech
that reads the info
from a file. The format of the file is as follows:
word pos word pos word pos ...Where
word
is the word and pos
is the
part of speech for the word. The part of speech is implementation
dependent.Modifier and Type | Field and Description |
---|---|
private String |
defaultPartOfSpeech
Default part of speech.
|
private int |
lineCount
Used for informational purposes if there's a bad line in the
file.
|
private Map |
partOfSpeechMap
A map from words to their part of speech.
|
Constructor and Description |
---|
PartOfSpeechImpl(URL url,
String defaultPartOfSpeech)
Creates a new PartOfSpeechImpl by reading from the given URL.
|
Modifier and Type | Method and Description |
---|---|
String |
getPartOfSpeech(String word)
Returns a description of the part of speech given a word.
|
private void |
parseAndAdd(String line)
Creates a word from the given input line and adds it to the map.
|
private int lineCount
private Map partOfSpeechMap
private String defaultPartOfSpeech
public PartOfSpeechImpl(URL url, String defaultPartOfSpeech) throws IOException
url
- the input sourcedefaultPartOfSpeech
- the default part of speechIOException
- if an error occursprivate void parseAndAdd(String line)
line
- the input linepublic String getPartOfSpeech(String word)
defaultPartOfSpeech
parameter passed to the constructor.getPartOfSpeech
in interface PartOfSpeech
word
- the word to classifyWebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses