Skip to main content

A Basic Library For Perspective API Usage

Project description

PyPerspective

A Simple Perspective API Library.

Why PyPerspective

  • Simple Requests
  • Auto Rate Limiter
  • Class Orianted
  • Handles Errors

Example Usages

from PyPerspective.Perspective import Perspective
perspective = Perspective("API KEY",ratelimit=True,default_not_store=True) # Default Do Not Store Option Is True.
# Default Not Store Option Is For Not Providing Do_Not_Store Kwarg In Get Score Function
# You Can Overwrite Default If You Gave Kwarg In Get Score Func

scores = perspective.get_score("Hello What Are You Doing?",tests=["TOXICITY"],langs=["en"]) # Tests Default Setted To TOXICITY, Langs Default Setted To English
# Scores Variable Is A Comment Class

# Usage Of Comment Class:
print(scores.text) # Sended Text
print(scores.raw_data) # Result That Sended By API
print(scores.detected_langs) # Detected Langs By API
print(scores.requests_langs) # Requested Langs
print(str(scores)) # Equals To scores.tedt
print(scores["TOXICITY"]) # Returns Test Attribute Class

# Usage Of Attribute Class:
My_Attribute = scores["TOXICITY"] # Gets Class Of Provided Test
print(My_Attribute.name)  # Name Of Test
print(My_Attribute.score) # Score Of Test
print(My_Attribute.score_type) # Score Type Of Test
print(My_Attribute.spans) # Returns List Of Span Class

# Usage Of Span Class:
My_Span = scores["TOXICITY"].spans[0] # Gets First Span
print(My_Span.start) # Span Start Index
print(My_Span.end) # Span End Index
print(My_Span.score) # Span Score
print(My_Span.score_type) # Span Score Type
print(str(My_Span)) # Returns Text Between Start Index And End Index (Both Is Included)

This Package Still On Development

PyPerspective Package Still On Development. Bugs And Errors Can Be Found In Usage. Report This Bugs And Errors On Github Or Discord

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

PyPerspective-1.0.4-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file PyPerspective-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: PyPerspective-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for PyPerspective-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6761bf4d1b0c60a12ca82ce902df4949d0869221bed599e967a11d8eea97db34
MD5 a7194f9d836e35859e993e9efaec7839
BLAKE2b-256 82c442a4a8670ae167dfc097b0911536953c3bcb94b1d973e2b73eda1ac756ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page