Skip to main content

A set of tools for connecting to the Augmented Criticism Lab

Project description

Augmented Criticism Lab Toolkit and Connectors

This set of tools is designed for interfacing with the Augmented Criticism Lab's API, https://acriticismlab.org. The toolkit can be installed with pip:

pip install Augmented-Criticism-Lab-Toolkit

Using the Connectors

Connectors are used to pull data from the database over the API. Here are some examples:

from connectors.poem import Poem

# To get a list of all poems:
all_poems = Poem().all()

# To get a specific poem by database id:
single_poem = Poem().by_id(1)

from connectors.book import Book

# To get a list of all books:
all_books = Book().all()

# To get a specific book by database id:
single_book = Book().by_id(1)

The included connectors are book, poem, and section. Each connector works on the same principle.

Using the Tools

API based tools:

from tools.api import Tools
# Lemmatize text:
lemmas = Tools().lemmatize("text to lemmatize")

# Part of speech tags:
tags = Tools().pos_tag("text to tag")

# Frequency distribution:
freqdist = Tools().frequency_distribution("text to get distribution for")

# Topic model:
model = Tools().topic_model("text to model")

Note: Topic models take about a minute to run.

Python based tools:

Rhyme Scheme Analyzer:

from tools.rhyme import Rhyme
from tools.rhyme import classify_sonnet

# Initialize a Rhyme object with the text you want to analyze.
# The text must be separated into lines, you can define a delimiter
# the default is '\\n'. This returns a list of rhyme pairs:
# ['A','B','B','A','C','D','D','C','E','F','E','F','G,'G']
rhyme = Rhyme("text\n broken\n into lines", delimiter='\n').find_rhyme_scheme()

# To classify the rhyme scheme (only works for sonnets) run:
# Returns a tuple such that (each number represents a probability
# the sonnet of the type listed):
#(Petrarchan 1, Petrarchan 2, Petrarchan 3, Shakespearean,  Spenserian)
sonnet_type = classify_sonnet(rhyme)

Syllable Counter:

from tools.syllable import SyllableCounter

# Initialize a counter:
syllable_counter = SyllableCounter()

# Run a line of poetry through the counter:
syllable_count_for_line = syllable_counter.count_syllables_by_line("line of text")

It is also possible to run the syllable counter on a poem from the ACL database directly:

from tools.syllable import SyllableCounter
from connectors.poem import Poem

# Initialize a counter:
syllable_counter = SyllableCounter()

# Get a poem:
poem = Poem().by_id(1)

# Get counts for the poem:
counts = syllable_counter.count_syllables_poem(poem)

Extend the OUTLIERS: (i.e. words that don't give correct syllable counts)

Create a csv file formatted as:

WORD, NUMBER_OF_SYLLABES

# Example
apple, 2
orange, 2

You then load the csv file:

from tools.syllable import SyllableCounter

# Initialize a SyllableCounter.
syllable_counter = SyllableCounter()

# Load the custom outliers file into the counter.
syllable_counter.load_custom_outliers('PATH_TO_FILE')

Project details


Download files

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

Source Distribution

Augmented Criticism Lab Toolkit-1.1.9.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file Augmented Criticism Lab Toolkit-1.1.9.tar.gz.

File metadata

  • Download URL: Augmented Criticism Lab Toolkit-1.1.9.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for Augmented Criticism Lab Toolkit-1.1.9.tar.gz
Algorithm Hash digest
SHA256 c04736e208f3b93ced312d29ff9eca742d6c6884886c67bb7a33b8909dbd0c9c
MD5 95fca497ce1a47765a22bb9e6ca0d38d
BLAKE2b-256 c688cf60bff228af052b35d1dee4aad69757c822c3186cee93a31c0b59ca08ad

See more details on using hashes here.

File details

Details for the file Augmented_Criticism_Lab_Toolkit-1.1.9-py3-none-any.whl.

File metadata

  • Download URL: Augmented_Criticism_Lab_Toolkit-1.1.9-py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.1 setuptools/40.6.2 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.3

File hashes

Hashes for Augmented_Criticism_Lab_Toolkit-1.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 c337c7db4deeb34c44df8c3fe778ca954881384158914218180ab6bb644e757c
MD5 42c1ae3c7f811de74c332c51db951230
BLAKE2b-256 9f288c808b537743bd90ef7aa73623e905471041dbb71181b4d2fe4922035161

See more details on using hashes here.

Supported by

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