Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create new command functions for dictionary & thesaurus #32

Open
GeorgeCiesinski opened this issue Feb 25, 2020 · 3 comments
Open

Create new command functions for dictionary & thesaurus #32

GeorgeCiesinski opened this issue Feb 25, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@GeorgeCiesinski
Copy link
Owner

Create new command functions such as:

  • !syn:word
  • !def:word

Where word is the word being passed to these functions.

The exact command structure can be changed if a better alternative is found.

!syn:word would erase the command and paste the first synonym. The command would remain in progress and the up/down arrow would shuffle through the other synonyms up to a certain limit. Pressing space, tab, or enter would exit the command.

!def:word would erase the command and paste the definition of the word.

@GeorgeCiesinski GeorgeCiesinski added the enhancement New feature or request label Feb 25, 2020
@GeorgeCiesinski GeorgeCiesinski added this to the 2.0 Release milestone Feb 25, 2020
@GeorgeCiesinski GeorgeCiesinski self-assigned this Feb 25, 2020
@GeorgeCiesinski
Copy link
Owner Author

Found the library nltk (https://nltk.org) and below instructions:

https://www.guru99.com/wordnet-nltk.html

@GeorgeCiesinski
Copy link
Owner Author

This needs to be moved to a future update. This is a much larger feature than I anticipated and may require a functional GUI first.

The below class can be added once this feature is ready to be created.

import nltk
from Logger import Logger
from nltk.corpus import wordnet


class WordTools:

    def __init__(self, _log):

        nltk_dir = './nltk/'

        nltk.download('wordnet', download_dir=nltk_dir)

        nltk.data.path.append(nltk_dir)

    def get_synonym_list(self, word):

        _synsets = wordnet.synsets(word)

        _synonyms = []

        for syn in _synsets:
            for item in syn.lemmas():
                _synonyms.append(item.name())

        # Todo: Determine some sort of sorting. Sort by popularity would be ideal. Otherwise, alphabetical is another option

        return _synonyms


if __name__ == "__main__":

    # Debugging

    # Creates instance of Logger
    L = Logger()
    L.log.debug("Program started from WordTools.py. Debugging.")

    word = WordTools(L)
    word.get_synonym_list("fall")

@GeorgeCiesinski
Copy link
Owner Author

After consideration, I decided to save this feature for after the GUI has successfully been implemented to take advantage of GUI features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant