|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.process.Morphology
public class Morphology
Morphology computes the base form of English words, by removing just
inflections (not derivational morphology). That is, it only does noun
plurals, pronoun case, and verb endings, and not things like comparative adjectives
or derived nominals. It is based on a finite-state
transducer implemented by John Carroll et al., written in flex and publicly
available.
See: http://www.informatics.susx.ac.uk/research/nlp/carroll/morph.html .
There are several ways of invoking Morphology. One is by calling the static
methods
WordTag stemStatic(String word, String tag) or
WordTag stemStatic(WordTag wordTag).
If we have created a Morphology object already we can use the methods
WordTag stem(String word, string tag) or WordTag stem(WordTag wordTag).
Another way of using Morphology is to run it on an input file by running
java Morphology filename
. In this case, POS tags must be
separated from words by an underscore ("_").
Note that a single instance of Morphology is not thread-safe, as
the underlying lexer object is not built to be re-entrant. What
you can do to get around this is build a new Morphology object for
each set of calls to the Morphology. For example, the
MorphaAnnotator builds a Morphology for each document it annotates.
Constructor Summary | |
---|---|
Morphology()
|
|
Morphology(Reader in)
Process morphologically words from a Reader. |
|
Morphology(String filename)
|
Method Summary | |
---|---|
Object |
apply(Object in)
Converts a T1 to a different T2. |
WordLemmaTag |
lemmatize(WordTag wT)
Lemmatize returning a WordLemmaTag . |
static WordLemmaTag |
lemmatizeStatic(WordTag wT)
|
static void |
main(String[] args)
Run the morphological analyzer. |
Word |
next()
|
void |
stem(CoreLabel label)
Adds the LemmaAnnotation to the given CoreLabel. |
void |
stem(CoreLabel label,
Class<? extends CoreAnnotation<String>> ann)
Adds annotation ann to the given CoreLabel. |
String |
stem(String word)
|
WordTag |
stem(String word,
String tag)
|
static WordTag |
stem(String word,
String tag,
edu.stanford.nlp.process.Morpha lexer,
boolean lowercase)
Lemmatize the word, being sensitive to the tag, using the passed in lexer. |
Word |
stem(Word w)
|
WordTag |
stem(WordTag wT)
|
static WordTag |
stemStatic(String word,
String tag)
Return a new WordTag which has the lemma as the value of word(). |
static WordTag |
stemStatic(String word,
String tag,
boolean lowercase)
|
static WordTag |
stemStatic(WordTag wT)
Return a new WordTag which has the lemma as the value of word(). |
static WordTag |
stemStaticSynchronized(String word,
String tag)
|
static WordTag |
stemStaticSynchronized(String word,
String tag,
boolean lowercase)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Morphology()
public Morphology(Reader in)
in
- The Reader to read frompublic Morphology(String filename)
Method Detail |
---|
public Word next() throws IOException
IOException
public Word stem(Word w)
public String stem(String word)
public WordTag stem(WordTag wT)
public WordTag stem(String word, String tag)
public void stem(CoreLabel label)
public void stem(CoreLabel label, Class<? extends CoreAnnotation<String>> ann)
ann
to the given CoreLabel.
public static WordTag stem(String word, String tag, edu.stanford.nlp.process.Morpha lexer, boolean lowercase)
lowercase
- If this is true, words other than proper nouns will
be changed to all lowercase.public static WordTag stemStatic(String word, String tag)
public static WordTag stemStatic(String word, String tag, boolean lowercase)
public static WordTag stemStaticSynchronized(String word, String tag)
public static WordTag stemStaticSynchronized(String word, String tag, boolean lowercase)
public static WordTag stemStatic(WordTag wT)
public Object apply(Object in)
Function
apply
in interface Function
in
- The function's argument
public WordLemmaTag lemmatize(WordTag wT)
WordLemmaTag
.
public static WordLemmaTag lemmatizeStatic(WordTag wT)
public static void main(String[] args) throws IOException
IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |