public class InMemoryLexicalWeighting extends java.lang.Object implements LexicalWeighting
LexicalWeighting
interface that takes
its entries from the output of an external word aligner.
This output must follow the plain-text format used by GIZA++, which consists of one entry per line, with the token in the source language followed by the token in the target language followed by their lexical weight and separated by tabs. Entities should begin with the "enti_" prefix.
The provided implementation is immutable and, therefore, instances can be freely shared.
UNKNOWN_ALIGN
Constructor and Description |
---|
InMemoryLexicalWeighting(java.io.Reader in)
Creates a new instance based on the output of an external word aligner.
|
Modifier and Type | Method and Description |
---|---|
double |
getWeight(Token src,
Token trg)
Return the lexical weight for the given tokens, that is, a numerical
value that reflects how strongly aligned they are.
|
void |
writeEntityDictionary(LexicalWeighting reverseLexicalWeighting,
double threshold,
java.io.Writer out)
Writes a text dictionary that contains all the entity pairs with a
lexical weight equal or higher than the given threshold except those
whose both elements are equal.
|
public InMemoryLexicalWeighting(java.io.Reader in)
in
- the reader for some lexical weighting output in the plain-text format used by GIZA++.public double getWeight(Token src, Token trg)
LexicalWeighting
getWeight
in interface LexicalWeighting
src
- the token in the source language.trg
- the token in the target language.public void writeEntityDictionary(LexicalWeighting reverseLexicalWeighting, double threshold, java.io.Writer out) throws java.io.IOException
LexicalWeighting
TextDictionary
.writeEntityDictionary
in interface LexicalWeighting
reverseLexicalWeighting
- the reverse lexical weighting so that if this instance goes from source to target, the reverse one should go from target to source.threshold
- the minimum lexical weight for an entity pair to appear in the resulting dictionary.out
- the Writer
which with to write the dictionary.java.io.IOException
- if an I/O error occurs.