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 Details

    • ImmutablePlainTextDictionary

      public ImmutablePlainTextDictionary(URL dbFile)
      Default constructor.
      Parameters:
      dbFile -
  • Method Details

    • lazyLoadDb

      protected ca.hedlund.tst.TernaryTree<List<String>> lazyLoadDb() throws IOException
      Lazy-load the database.
      Throws:
      IOException
    • getFile

      public URL getFile()
      Get the file used by this dictionary.
      Returns:
      file
    • setContractionRules

      public void setContractionRules(List<ContractionRule> ctrRuleList)
      Set the contraction rules used by this dictionary.
      Parameters:
      ctrRuleList - a list of ContractionRule
    • getContractionRules

      public List<ContractionRule> getContractionRules()
      Return the ContractionRule used by this dictionary for generating suggested transcriptions.
      Returns:
      the list of ContractionRule
    • getLanguage

      public Language getLanguage()
      Description copied from interface: LanguageInfo
      Returns the language handled by this dictionary.
      Specified by:
      getLanguage in interface LanguageInfo
      Returns:
      the Language for this dictionary
    • getName

      public String 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.
      Specified by:
      getName in interface NameInfo
      Returns:
      the dictionary name
    • lookup

      public String[] lookup(String orthography) throws IPADictionaryExecption
      Description copied from interface: IPADictionarySPI
      Lookup IPA transcriptions for a given orthographic string.
      Specified by:
      lookup in interface IPADictionarySPI
      Returns:
      a list of IPA transcriptions associated with the given orthography
      Throws:
      IPADictionaryExecption
    • generateSuggestions

      public String[] generateSuggestions(String orthography)
      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 interface GenerateSuggestions
      Returns:
      a list of generated ipa suggestions
    • iterator

      public Iterator<String> 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 interface OrthoKeyIterator
      Returns:
      the key iterator
    • keysWithPrefix

      public String[] keysWithPrefix(String prefix)
      Description copied from interface: PrefixSearch
      Search for all instances of the given prefix in orthographic keys.
      Specified by:
      keysWithPrefix in interface PrefixSearch
      Returns:
      a list of orthographic keys which have the specified prefix
    • getMetadataValue

      public String getMetadataValue(String key)
      Description copied from interface: Metadata
      Get value for a given metadata key.
      Specified by:
      getMetadataValue in interface Metadata
      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. See Metadata.metadataKeyIterator()
    • metadataKeyIterator

      public Iterator<String> metadataKeyIterator()
      Description copied from interface: Metadata
      Get the iteator for metadata keys.
      Specified by:
      metadataKeyIterator in interface Metadata
      Returns:
      an iterator for the metadata keys available
    • install

      public void install(IPADictionary dict)
      Description copied from interface: IPADictionarySPI
      Install this SPI into the given IPADictionary
      Specified by:
      install in interface IPADictionarySPI