Skip to content

perspective.py v0.3.2

Compare
Choose a tag to compare
@Yilmaz4 Yilmaz4 released this 19 Jan 16:18
· 46 commits to main since this release

A random idea came to my mind whilst I was in school and I decided to add it to the library. While I was adding the feature, I noticed some bugs and fixed them too at the mean time. You can see what the idea was and the bugs that I've fixed below. Other than that, I literally have no idea to add to the library so I would appreciate if you give me some ideas in the Issues tab of the repository.

New features

  • Added save_data function which can be used to save the response that the analyze function returned to a SQLite3 database file. I know it's already pretty easy to do this by yourself but here is an easier way.
  • Added EmptyResponse exception type to perspective.errors class which gets raised when there is no attribute in the dictionary that was passed to the response argument in any of the functions of perspective.utils class.
  • Added EmptyFileName exception type to perspective.errors class which gets raised when an empty string was provided as the filename argument of save_graph and/or save_data functions of perspective.utils class.

Changes

  • Changed the way the analyze function of perspective.Client object and all other functions in perspective.utils class (only if raw response was provided) fetch score values of attributes from the raw response that was directly returned from the API. They now get the score values from summaryScore nested-dictionary which contains the average score value instead of spanScores which shall contain score values of each sentence of the text requested to the API in the future.

Bug fixes

  • Fixed TypeError exception when attempting to use format_response or save_data in perspective.utils class by providing raw response to the response argument and setting sort_by argument to something other than None.
  • Fixed TOXICITY attribute appearing as toxicity instead of Toxicity (first letter is not capital) when True is passed to the align_right argument of format_response function in perspective.utils class.
  • Fixed ModuleNotFoundError exception when importing the package (perspective.py) on a machine with no matplotlib library installed, as the library was missing in install_requires list of setup.py file.

Code changes

  • Fixed some typos in function comments.
  • Added function annotations to every single function in the library.