Package ca.phon.ipadictionary.impl
Class ImmutablePlainTextDictionary
java.lang.Object
ca.phon.ipadictionary.impl.ImmutablePlainTextDictionary
- All Implemented Interfaces:
GenerateSuggestions
,IPADictionarySPI
,LanguageInfo
,Metadata
,NameInfo
,OrthoKeyIterator
,PrefixSearch
public class ImmutablePlainTextDictionary
extends Object
implements IPADictionarySPI, LanguageInfo, NameInfo, GenerateSuggestions, OrthoKeyIterator, PrefixSearch, Metadata
Implements the basic dictionary format used by Phon.
The input file should bef a UTF-8 stream of
characters with a single orthography and ipa transcription
per line. The orthography and transcript can be
separated using a specified token (default '\p{Space}') -
regular expressions are allowed.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionString[]
generateSuggestions
(String orthography) Generate a list of suggestions for a given orthography.Return theContractionRule
used by this dictionary for generating suggested transcriptions.getFile()
Get the file used by this dictionary.Returns the language handled by this dictionary.getMetadataValue
(String key) Get value for a given metadata key.getName()
Returns a string identifier for this dictionary.void
install
(IPADictionary dict) Install this SPI into the given IPADictionaryiterator()
Return an iterator for the keys found in this dictionary.String[]
keysWithPrefix
(String prefix) Search for all instances of the given prefix in orthographic keys.Lazy-load the database.String[]
Lookup IPA transcriptions for a given orthographic string.Get the iteator for metadata keys.void
setContractionRules
(List<ContractionRule> ctrRuleList) Set the contraction rules used by this dictionary.
-
Constructor Details
-
ImmutablePlainTextDictionary
Default constructor.- Parameters:
dbFile
-
-
-
Method Details
-
lazyLoadDb
Lazy-load the database.- Throws:
IOException
-
getFile
Get the file used by this dictionary.- Returns:
- file
-
setContractionRules
Set the contraction rules used by this dictionary.- Parameters:
ctrRuleList
- a list ofContractionRule
-
getContractionRules
Return theContractionRule
used by this dictionary for generating suggested transcriptions.- Returns:
- the list of
ContractionRule
-
getLanguage
Description copied from interface:LanguageInfo
Returns the language handled by this dictionary.- Specified by:
getLanguage
in interfaceLanguageInfo
- Returns:
- the
Language
for this dictionary
-
getName
Description copied from interface:NameInfo
Returns a string identifier for this dictionary. While not required, the name should be unique to help users identify dictionaries which handle the same language. -
lookup
Description copied from interface:IPADictionarySPI
Lookup IPA transcriptions for a given orthographic string.- Specified by:
lookup
in interfaceIPADictionarySPI
- Returns:
- a list of IPA transcriptions associated with the given orthography
- Throws:
IPADictionaryExecption
-
generateSuggestions
Description copied from interface:GenerateSuggestions
Generate a list of suggestions for a given orthography. If the given orthography appears in the dictionary as-is this method returns the same as lookup.- Specified by:
generateSuggestions
in interfaceGenerateSuggestions
- Returns:
- a list of generated ipa suggestions
-
iterator
Description copied from interface:OrthoKeyIterator
Return an iterator for the keys found in this dictionary. Order of keys returned by the iterator is determined by dictionary implementation and is not guaranteed.- Specified by:
iterator
in interfaceOrthoKeyIterator
- Returns:
- the key iterator
-
keysWithPrefix
Description copied from interface:PrefixSearch
Search for all instances of the given prefix in orthographic keys.- Specified by:
keysWithPrefix
in interfacePrefixSearch
- Returns:
- a list of orthographic keys which have the specified prefix
-
getMetadataValue
Description copied from interface:Metadata
Get value for a given metadata key.- Specified by:
getMetadataValue
in interfaceMetadata
- Parameters:
key
- the metadata key. Common keys are 'provider' and 'website'- Returns:
- the value for the specified key or
null
if no data is available. SeeMetadata.metadataKeyIterator()
-
metadataKeyIterator
Description copied from interface:Metadata
Get the iteator for metadata keys.- Specified by:
metadataKeyIterator
in interfaceMetadata
- Returns:
- an iterator for the metadata keys available
-
install
Description copied from interface:IPADictionarySPI
Install this SPI into the given IPADictionary- Specified by:
install
in interfaceIPADictionarySPI
-