Class Dictionary


  • public final class Dictionary
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      FSA fsa
      FSA automaton with the compiled dictionary data.
      DictionaryMetadata metadata
      Metadata associated with the dictionary.
    • Constructor Summary

      Constructors 
      Constructor Description
      Dictionary​(FSA fsa, DictionaryMetadata metadata)
      It is strongly recommended to use static methods in this class for reading dictionaries.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Dictionary read​(java.io.InputStream fsaStream, java.io.InputStream metadataStream)
      Attempts to load a dictionary from opened streams of FSA dictionary data and associated metadata.
      static Dictionary read​(java.net.URL dictURL)
      Attempts to load a dictionary using the URL to the FSA file and the expected metadata extension.
      static Dictionary read​(java.nio.file.Path location)
      Attempts to load a dictionary using the path to the FSA file and the expected metadata extension.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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​(java.nio.file.Path location)
                               throws java.io.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:
        java.io.IOException - if an I/O error occurs.
      • read

        public static Dictionary read​(java.net.URL dictURL)
                               throws java.io.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:
        java.io.IOException - if an I/O error occurs.
      • read

        public static Dictionary read​(java.io.InputStream fsaStream,
                                      java.io.InputStream metadataStream)
                               throws java.io.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:
        java.io.IOException - if an I/O error occurs.