Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

PyPI version codecov Life cycle downloads License: MIT

totolo

This repository contains a Python package, totolo, for working with data from the Theme Ontology theming repository.

Installation

pip install totolo

Or clone this repository and copy the totolo directory wherever you need it. No package dependencies are required.

Basic Usage

    #: import package
    >>> import totolo

    #: get the latest main branch version of the ontology
    >>> ontology = totolo.remote()
    >>> print(ontology)
<2945 themes, 4475 stories>

    #: write it or read it locally
    >>> ontology.write("/home/mo/themes")
    >>> ontology = totolo.files("/home/mo/themes")
    >>> print(ontology)
<2945 themes, 4475 stories>

Explore the themes

    #: go over all the themes and find the ones you want
    >>> for theme in ontology.themes():
    ...     if "romantic love" in theme.name:
    ...         print(theme)
b'personal freedom vs. romantic love'[3]
b'romantic love'[3]

    #: check the definition of a theme
    >>> love = ontology.theme["love"]
    >>> love.print()
    (...)

Explore the stories

    >>> for weight, theme in story.iter_themes():
    ...     print(f"{weight:<15} {theme.name}")
Choice Themes   betrayal
Choice Themes   the lust for power
(...)

Convert it to a pandas dataframe

    >>> df = ontology.dataframe()
    >>> df
                                 story_id             title        date                      theme        weight
0                 theamericanshortstory01  The Music School        1974      human self-reflection  Major Themes
1                 theamericanshortstory01  The Music School        1974                     murder  Major Themes
...                                   ...               ...         ...                        ...           ...
52453  videogame: Final Fantasy VI (1994)  Final Fantasy VI  1994-04-02  feral children in society  Minor Themes
52454  videogame: Final Fantasy VI (1994)  Final Fantasy VI  1994-04-02             father and son  Minor Themes

[52455 rows x 5 columns]

Snippets

List official versioned releases of the ontology

    list(totolo.remote.versions())

Load the v2023.06 release

    ontology = totolo.remote.version('v2023.06')

Create an excel sheet with all the usages of the theme "loyalty" as well as any child theme of the same

    df = ontology.theme['loyalty'].descendants().dataframe(motivation=True, descriptions=True)
    df.to_excel("/mnt/d/repos/themelist-loyalty.xlsx", "loyalty")

Find theme entries in stories according to some criteria. For example, find empty motivations

    empty_motivations = [
        (story, weight, part)
        for story in ontology.stories()
        for weight, part in story.iter_theme_entries()
        if part.motivation.strip() == ""
    ]

Getting Help

If you encounter a bug, please file a minimal reproducible example on GitHub issues. For feature requests and other matters, please post on the GitHub discussions board.

Code Test Coverage

codecov

License

All code in this repository is published with the MIT license.

Metadata

Release files for totolo 1.7.0.dev202409041433

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

Source distribution (sdist)

Source distribution for totolo 1.7.0.dev202409041433
File Size Uploaded
totolo-1.7.0.dev202409041433.tar.gz 1.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for totolo 1.7.0.dev202409041433
File Interpreter ABI Platform
totolo-1.7.0.dev202409041433-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 1.4 MB

Release files / totolo-1.7.0.dev202409041433.tar.gz

Download URL totolo-1.7.0.dev202409041433.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
719762e54af73c94624c2f4b1559fe903a50f3e715574a9c40252fc95e3356db
BLAKE2b-256 checksum
How to use checksums
e392952fc034181e5dd36eda772542e14e439a5cd20068c5cfc90c5bdbf4162f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.5

Release files / totolo-1.7.0.dev202409041433-py2.py3-none-any.whl

Download URL totolo-1.7.0.dev202409041433-py2.py3-none-any.whl
Size 26.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0b57e5e6de37f8c62b31989e0e89450b8fa78698c6785993660b3f287ba5093f
BLAKE2b-256 checksum
How to use checksums
3c4c43dbcfc4513bb01ca8c55737394ec118b4cc6579dea0c494b9a00c1b0d14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.5
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