public class TextDictionary extends java.lang.Object implements Dictionary
Dictionary
that takes its entries from plain text. The exact format
is one entry per line, with the lemma of the entity in the source language
followed by a tab followed by the lemma of the entity in the target language.
The provided implementation is immutable and, therefore, instances can be freely shared.
DUMMY_DICTIONARY
Constructor and Description |
---|
TextDictionary(java.io.Reader in)
Constructs a new dictionary reading its entries from the given
Reader . |
Modifier and Type | Method and Description |
---|---|
boolean |
containsEntry(Entity src,
Entity trg)
Checks whether this bilingual dictionary contains the specified entry.
|
boolean |
equals(java.lang.Object obj) |
int |
hashCode() |
java.lang.String |
translate(Entity entity)
Translates the specified
Entity . |
public TextDictionary(java.io.Reader in)
Reader
.in
- the Reader
to read the entries from, which should follow the above specified format.public java.lang.String translate(Entity entity)
Dictionary
Entity
.translate
in interface Dictionary
entity
- the Entity
to translate.Entity
, or null
if the dictionary doesn't contain any entry for it.public boolean containsEntry(Entity src, Entity trg)
Dictionary
containsEntry
in interface Dictionary
src
- the Entity
in the source language.trg
- the Entity
in the target language.trg
is a valid translation of src
according to this dictionary.public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object