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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]generateSuggestions(String orthography) Generate a list of suggestions for a given orthography.Return theContractionRuleused 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.voidinstall(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.voidsetContractionRules(List<ContractionRule> ctrRuleList) Set the contraction rules used by this dictionary.
-
Constructor Details
-
ImmutablePlainTextDictionary
-
-
Method Details
-
lazyLoadDb
Lazy-load the database.- Throws:
IOException
-
getFile
-
setContractionRules
Set the contraction rules used by this dictionary.- Parameters:
ctrRuleList- a list ofContractionRule
-
getContractionRules
Return theContractionRuleused by this dictionary for generating suggested transcriptions.- Returns:
- the list of
ContractionRule
-
getLanguage
Description copied from interface:LanguageInfoReturns the language handled by this dictionary.- Specified by:
getLanguagein interfaceLanguageInfo- Returns:
- the
Languagefor this dictionary
-
getName
Description copied from interface:NameInfoReturns 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:IPADictionarySPILookup IPA transcriptions for a given orthographic string.- Specified by:
lookupin interfaceIPADictionarySPI- Parameters:
orthography-- Returns:
- a list of IPA transcriptions associated with the given orthography
- Throws:
IPADictionaryException
-
generateSuggestions
Description copied from interface:GenerateSuggestionsGenerate 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:
generateSuggestionsin interfaceGenerateSuggestions- Parameters:
orthography-- Returns:
- a list of generated ipa suggestions
-
iterator
Description copied from interface:OrthoKeyIteratorReturn 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:
iteratorin interfaceOrthoKeyIterator- Returns:
- the key iterator
-
keysWithPrefix
Description copied from interface:PrefixSearchSearch for all instances of the given prefix in orthographic keys.- Specified by:
keysWithPrefixin interfacePrefixSearch- Parameters:
prefix-- Returns:
- a list of orthographic keys which have the specified prefix
-
getMetadataValue
Description copied from interface:MetadataGet value for a given metadata key.- Specified by:
getMetadataValuein interfaceMetadata- Parameters:
key- the metadata key. Common keys are 'provider' and 'website'- Returns:
- the value for the specified key or
nullif no data is available. SeeMetadata.metadataKeyIterator()
-
metadataKeyIterator
Description copied from interface:MetadataGet the iteator for metadata keys.- Specified by:
metadataKeyIteratorin interfaceMetadata- Returns:
- an iterator for the metadata keys available
-
install
Description copied from interface:IPADictionarySPIInstall this SPI into the given IPADictionary- Specified by:
installin interfaceIPADictionarySPI
-