edu.stanford.nlp.parser.lexparser
Class PetrovLexicon

java.lang.Object
  extended by edu.stanford.nlp.parser.lexparser.PetrovLexicon
All Implemented Interfaces:
Lexicon, Serializable

public class PetrovLexicon
extends Object
implements Lexicon

See Also:
Serialized Form

Field Summary
 
Fields inherited from interface edu.stanford.nlp.parser.lexparser.Lexicon
BOUNDARY, BOUNDARY_TAG
 
Constructor Summary
PetrovLexicon()
           
 
Method Summary
 int getSignature(int word, int loc)
           
 String getSignature(String word, int loc)
           
protected  void initRulesWithWord()
           
 boolean isKnown(int word)
          Checks whether a word is in the lexicon.
 boolean isKnown(String word)
          Checks whether a word is in the lexicon.
 int numRules()
          Returns the number of rules (tag rewrites as word) in the Lexicon.
 void readData(BufferedReader in)
          Read the lexicon from the BufferedReader in the format written by writeData.
 Iterator<IntTaggedWord> ruleIteratorByWord(int word, int loc)
          Get an iterator over all rules (pairs of (word, POS)) for this word.
 float score(IntTaggedWord iTW, int loc)
          Computes an estimate of log P(word | tag).
 void train(Collection<Tree> trees)
          Trains this lexicon on the Collection of trees.
 void writeData(Writer w)
          Write the lexicon in human-readable format to the Writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PetrovLexicon

public PetrovLexicon()
Method Detail

isKnown

public boolean isKnown(int word)
Description copied from interface: Lexicon
Checks whether a word is in the lexicon.

Specified by:
isKnown in interface Lexicon
Parameters:
word - The word as an int
Returns:
Whether the word is in the lexicon

isKnown

public boolean isKnown(String word)
Description copied from interface: Lexicon
Checks whether a word is in the lexicon.

Specified by:
isKnown in interface Lexicon
Parameters:
word - The word as a String
Returns:
Whether the word is in the lexicon

ruleIteratorByWord

public Iterator<IntTaggedWord> ruleIteratorByWord(int word,
                                                  int loc)
Description copied from interface: Lexicon
Get an iterator over all rules (pairs of (word, POS)) for this word.

Specified by:
ruleIteratorByWord in interface Lexicon
Parameters:
word - The word, represented as an integer in Numberer
loc - The position of the word in the sentence (counting from 0). Implementation note: The BaseLexicon class doesn't actually make use of this position information.
Returns:
An Iterator over a List ofIntTaggedWords, which pair the word with possible taggings as integer pairs. (Each can be thought of as a tag -> word rule.)

initRulesWithWord

protected void initRulesWithWord()

numRules

public int numRules()
Returns the number of rules (tag rewrites as word) in the Lexicon. This method assumes that the lexicon has been initialized.

Specified by:
numRules in interface Lexicon

train

public void train(Collection<Tree> trees)
Description copied from interface: Lexicon
Trains this lexicon on the Collection of trees.

Specified by:
train in interface Lexicon

score

public float score(IntTaggedWord iTW,
                   int loc)
Computes an estimate of log P(word | tag).

Specified by:
score in interface Lexicon
Parameters:
iTW - An IntTaggedWord pairing a word and POS tag
loc - The position in the sentence. In the default implementation this is used only for unknown words to change their probability distribution when sentence initial.
Returns:
A double valued score, usually - log P(word|tag)

writeData

public void writeData(Writer w)
               throws IOException
Description copied from interface: Lexicon
Write the lexicon in human-readable format to the Writer. (An optional operation.)

Specified by:
writeData in interface Lexicon
Parameters:
w - The writer to output to
Throws:
IOException

readData

public void readData(BufferedReader in)
              throws IOException
Description copied from interface: Lexicon
Read the lexicon from the BufferedReader in the format written by writeData. (An optional operation.)

Specified by:
readData in interface Lexicon
Parameters:
in - The BufferedReader to read from
Throws:
IOException

getSignature

public int getSignature(int word,
                        int loc)

getSignature

public String getSignature(String word,
                           int loc)


Stanford NLP Group