Class Dictionary

java.lang.Object
morfologik.stemming.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 Summary

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

    Constructors
    Constructor
    Description
    It is strongly recommended to use static methods in this class for reading dictionaries.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Dictionary
    read(InputStream fsaStream, InputStream metadataStream)
    Attempts to load a dictionary from opened streams of FSA dictionary data and associated metadata.
    static Dictionary
    read(URL dictURL)
    Attempts to load a dictionary using the URL to the FSA file and the expected metadata extension.
    static Dictionary
    read(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 Details

    • fsa

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

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

    • 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 Details

    • 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.