Skip navigation links
simplenlg.lexicon

Class Lexicon

    • Constructor Detail

      • Lexicon

        public Lexicon()
    • Method Detail

      • getDefaultLexicon

        public static Lexicon getDefaultLexicon()
        returns the default built-in lexicon
        Returns:
        default lexicon
      • createWord

        protected WordElement createWord(String baseForm,
                                         LexicalCategory category)
        create a default WordElement. May be overridden by specific types of lexicon
        Parameters:
        baseForm - - base form of word
        category - - category of word
        Returns:
        WordElement entry for specified info
      • createWord

        protected WordElement createWord(String baseForm)
        create a default WordElement. May be overridden by specific types of lexicon
        Parameters:
        baseForm - - base form of word
        Returns:
        WordElement entry for specified info
      • lookupWord

        public WordElement lookupWord(String baseForm,
                                      LexicalCategory category)
        General word lookup method, tries base form, variant, ID (in this order) Creates new word if can't find existing word
        Returns:
        word
      • lookupWord

        public WordElement lookupWord(String baseForm)
        General word lookup method, tries base form, variant, ID (in this order) Creates new word if can't find existing word
        Returns:
        word
      • getWords

        public abstract List<WordElement> getWords(String baseForm,
                                                   LexicalCategory category)
        returns all Words which have the specified base form and category
        Parameters:
        baseForm - - base form of word, eg "be" or "dog" (not "is" or "dogs")
        category - - syntactic category of word (ANY for unknown)
        Returns:
        collection of all matching Words (may be empty)
      • getWord

        public WordElement getWord(String baseForm,
                                   LexicalCategory category)
        get a WordElement which has the specified base form and category
        Parameters:
        baseForm - - base form of word, eg "be" or "dog" (not "is" or "dogs")
        category - - syntactic category of word (ANY for unknown)
        Returns:
        if Lexicon contains such a WordElement, it is returned (the first match is returned if there are several matches). If the Lexicon does not contain such a WordElement, a new WordElement is created and returned
      • hasWord

        public boolean hasWord(String baseForm,
                               LexicalCategory category)
        return true if the lexicon contains a WordElement which has the specified base form and category
        Parameters:
        baseForm - - base form of word, eg "be" or "dog" (not "is" or "dogs")
        category - - syntactic category of word (ANY for unknown)
        Returns:
        true if Lexicon contains such a WordElement
      • getWords

        public List<WordElement> getWords(String baseForm)
        returns all Words which have the specified base form
        Parameters:
        baseForm - - base form of word, eg "be" or "dog" (not "is" or "dogs")
        Returns:
        collection of all matching Words (may be empty)
      • getWord

        public WordElement getWord(String baseForm)
        get a WordElement which has the specified base form (of any category)
        Parameters:
        baseForm - - base form of word, eg "be" or "dog" (not "is" or "dogs")
        Returns:
        if Lexicon contains such a WordElement, it is returned (the first match is returned if there are several matches). If the Lexicon does not contain such a WordElement, a new WordElement is created and returned
      • hasWord

        public boolean hasWord(String baseForm)
        return true if the lexicon contains a WordElement which has the specified base form (in any category)
        Parameters:
        baseForm - - base form of word, eg "be" or "dog" (not "is" or "dogs")
        Returns:
        true if Lexicon contains such a WordElement
      • getWordsByID

        public abstract List<WordElement> getWordsByID(String id)
        returns a List of WordElement which have this ID. IDs are lexicon-dependent, and should be unique. Therefore the list should contain either zero elements (if no such word exists) or one element (if the word is found)
        Parameters:
        id - - internal lexicon ID for a word
        Returns:
        either empty list (if no word with this ID exists) or list containing the matching word
      • getWordByID

        public WordElement getWordByID(String id)
        get a WordElement with the specified ID
        Parameters:
        id - internal lexicon ID for a word
        Returns:
        WordElement with this ID if found; otherwise a new WordElement is created with the ID as the base form
      • hasWordByID

        public boolean hasWordByID(String id)
        return true if the lexicon contains a WordElement which the specified ID
        Parameters:
        id - - internal lexicon ID for a word
        Returns:
        true if Lexicon contains such a WordElement
      • getWordsFromVariant

        public abstract List<WordElement> getWordsFromVariant(String variant,
                                                              LexicalCategory category)
        returns Words which have an inflected form and/or spelling variant that matches the specified variant, and are in the specified category.
        Note: the returned word list may not be complete, it depends on how it is implemented by the underlying lexicon
        Parameters:
        variant - - base form, inflected form, or spelling variant of word
        category - - syntactic category of word (ANY for unknown)
        Returns:
        list of all matching Words (empty list if no matching WordElement found)
      • getWordFromVariant

        public WordElement getWordFromVariant(String variant,
                                              LexicalCategory category)
        returns a WordElement which has the specified inflected form and/or spelling variant that matches the specified variant, of the specified category
        Parameters:
        variant - - base form, inflected form, or spelling variant of word
        category - - syntactic category of word (ANY for unknown)
        Returns:
        a matching WordElement (if found), otherwise a new word is created using thie variant as the base form
      • hasWordFromVariant

        public boolean hasWordFromVariant(String variant,
                                          LexicalCategory category)
        return true if the lexicon contains a WordElement which matches the specified variant form and category
        Parameters:
        variant - - base form, inflected form, or spelling variant of word
        category - - syntactic category of word (ANY for unknown)
        Returns:
        true if Lexicon contains such a WordElement
      • getWordsFromVariant

        public List<WordElement> getWordsFromVariant(String variant)
        returns Words which have an inflected form and/or spelling variant that matches the specified variant, of any category.
        Note: the returned word list may not be complete, it depends on how it is implemented by the underlying lexicon
        Parameters:
        variant - - base form, inflected form, or spelling variant of word
        Returns:
        list of all matching Words (empty list if no matching WordElement found)
      • getWordFromVariant

        public WordElement getWordFromVariant(String variant)
        returns a WordElement which has the specified inflected form and/or spelling variant that matches the specified variant, of any category.
        Parameters:
        variant - - base form, inflected form, or spelling variant of word
        Returns:
        a matching WordElement (if found), otherwise a new word is created using thie variant as the base form
      • hasWordFromVariant

        public boolean hasWordFromVariant(String variant)
        return true if the lexicon contains a WordElement which matches the specified variant form (in any category)
        Parameters:
        variant - - base form, inflected form, or spelling variant of word
        Returns:
        true if Lexicon contains such a WordElement
      • close

        public void close()
        close the lexicon (if necessary) if lexicon does not need to be closed, this does nothing

Copyright © 2020. All Rights Reserved.