Class Dictionary


  • public final class Dictionary
    extends Object
    A dictionary combines FSA automaton and DictionaryMetadata describing the way terms are encoded in the automaton.

    A dictionary consists of two files:

    • an actual compressed FSA file,
    • DictionaryMetadata, describing the way terms are encoded.
    • Field Detail

      • fsa

        public final FSA fsa
        FSA automaton with the compiled dictionary data.
      • metadata

        public final DictionaryMetadata metadata
        Metadata associated with the dictionary.
    • Constructor Detail

      • Dictionary

        public Dictionary​(FSA fsa,
                          DictionaryMetadata metadata)
        It is strongly recommended to use static methods in this class for reading dictionaries.
        Parameters:
        fsa - An instantiated FSA instance.
        metadata - A map of attributes describing the compression format and other settings not contained in the FSA automaton. For an explanation of available attributes and their possible values, see DictionaryMetadata.
    • Method Detail

      • read

        public static Dictionary read​(Path location)
                               throws IOException
        Attempts to load a dictionary using the path to the FSA file and the expected metadata extension.
        Parameters:
        location - The location of the dictionary file (*.dict).
        Returns:
        An instantiated dictionary.
        Throws:
        IOException - if an I/O error occurs.
      • read

        public static Dictionary read​(URL dictURL)
                               throws IOException
        Attempts to load a dictionary using the URL to the FSA file and the expected metadata extension.
        Parameters:
        dictURL - The URL pointing to the dictionary file (*.dict).
        Returns:
        An instantiated dictionary.
        Throws:
        IOException - if an I/O error occurs.
      • read

        public static Dictionary read​(InputStream fsaStream,
                                      InputStream metadataStream)
                               throws IOException
        Attempts to load a dictionary from opened streams of FSA dictionary data and associated metadata. Input streams are not closed automatically.
        Parameters:
        fsaStream - The stream with FSA data
        metadataStream - The stream with metadata
        Returns:
        Returns an instantiated Dictionary.
        Throws:
        IOException - if an I/O error occurs.