Skip to main content

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')

Metadata

Release files for Augmented-Criticism-Lab-Toolkit 1.1.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Augmented-Criticism-Lab-Toolkit 1.1.9
File Size Uploaded
Augmented Criticism Lab Toolkit-1.1.9.tar.gz 14.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Augmented-Criticism-Lab-Toolkit 1.1.9
File Interpreter ABI Platform
Augmented_Criticism_Lab_Toolkit-1.1.9-py3-none-any.whl Python 3 none any Details

Total release size: 33.1 kB

Release files / Augmented Criticism Lab Toolkit-1.1.9.tar.gz

Download URL Augmented Criticism Lab Toolkit-1.1.9.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c04736e208f3b93ced312d29ff9eca742d6c6884886c67bb7a33b8909dbd0c9c
BLAKE2b-256 checksum
How to use checksums
c688cf60bff228af052b35d1dee4aad69757c822c3186cee93a31c0b59ca08ad
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / Augmented_Criticism_Lab_Toolkit-1.1.9-py3-none-any.whl

Download URL Augmented_Criticism_Lab_Toolkit-1.1.9-py3-none-any.whl
Size 19.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c337c7db4deeb34c44df8c3fe778ca954881384158914218180ab6bb644e757c
BLAKE2b-256 checksum
How to use checksums
9f288c808b537743bd90ef7aa73623e905471041dbb71181b4d2fe4922035161
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

1.1.9 This release

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page