Skip to main content

AutoThemeGenerator is a package that allows you to perform thematic analysis in qualitative studies using OpenAI's GPT models.

Documentation pypi package GitHub Source Code Colab Example

User inputs

Users are only required to specify the folder location where their interview transcripts are stored. Accepted formats of transcripts include PDF, .docx, and .txt (prefered). AutoThemeGenerator assumes that each document is a transcript of one interviewed participant.

Requirements

Required packages

To use AutoThemeGenerator, you are required to have the following packages installed:

  • openai

  • docx

  • tqdm

  • nltk

  • nltk.tokenize (submodule of nltk)

  • python-docx

  • textract

  • requests

  • zipfile (Python standard library)

  • shutil (Python standard library)

  • json (Python standard library)

  • pprint (Python standard library)

If you do not have these packages installed in python, you can do the following:

pip install openai==1.12.0 python-docx docx tqdm nltk textract requests

OpenAI API key

You also need an OpenAI key to be able to use this package. If you do not have one, you can apply for an OpenAI API key at platform.openai.com/api-keys.

pip version

The package could only be installed with version older than 24.1. Newer versions of pip will not work due to compatability issues with textract. To downgrade to a version older than 24.1, please do the following:

pip install "pip<24.1"

Installation

To install in python, simply do the following:

pip install AutoThemeGenerator

Quick Start

Here we provide a quick example on how you can execute AutoThemeGenerator to conveniently perform qualitative analysis from your transcript. For details towards each of the package's functions and parameters, refer to the documention.

from AutoThemeGenerator import analyze_and_synthesize_transcripts



# Specify the folders containing your transcript

# This is the folder containing transcripts in .docx, .PDF or .txt format

directory_path = "my_transcript_folder"

# specify your OpenAI API key

api_key = "<insert your API key>"

# specify the folder you wish to save your themes. 

save_results_path = "folder_of_my_saved_results"



# specify the context of your study

context = (

    "Physical inactivity is a major risk factor for developing several chronic illness. "

    "However, university students and staff in the UK are found to be more physically inactive "

    "compared the general UK population. "

    )

# specify your research questions

research_questions = (

    "This study seeks to understand the barriers and enablers "

    "of physical activity (PA) among university staff and students in "

    "the UK under the university setting, using the Theoretical "

    "Domain Framework (TDF) to guide the investigation. "

    )

# specify your survey script

survey_script = (

    "Knowledge\n "

    "What do you know about physical activity? How might you define physical activity? "

    "... ..." # note: truncated to save space

    "... ..." 

    )



# Analyze and synthesize transcripts

initial_themes, individual_synthesized_themes, overall_synthesized_themes = \

analyze_and_synthesize_transcripts(

    directory_path = directory_path, context = context,

    research_questions = research_questions, script = survey_script,

    api_key = api_key, save_results_path = save_results_path)



# display your study-level themes

print(overall_synthesized_themes)

You can now view the themes in the form of a topic sentence, a detailed explaination and a relevant quote

Citation

Yuyi Yang, Charles Alba, Chenyu Wang, Xi Wang, Jami Anderson, and Ruopeng An. "GPT Models Can Perform Thematic Analysis in Public Health Studies, Akin to Qualitative Researchers." Journal of Social Computing, vol. 5, no. 4, (2024): 293-312. doi: 10.23919/JSC.2024.0024

Questions?

Contact me at alba@wustl.edu

Metadata

Release files for AutoThemeGenerator 0.2.1

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

Source distribution (sdist)

Source distribution for AutoThemeGenerator 0.2.1
File Size Uploaded
autothemegenerator-0.2.1.tar.gz 12.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for AutoThemeGenerator 0.2.1
File Interpreter ABI Platform
AutoThemeGenerator-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 24.3 kB

Release files / autothemegenerator-0.2.1.tar.gz

Download URL autothemegenerator-0.2.1.tar.gz
Size 12.3 kB
Tags Source
SHA-256 checksum
How to use checksums
ad03ae1f6d2b47e89ddb1254e1b3121a7952cf5d5e8672e4da4b9de052a179bb
BLAKE2b-256 checksum
How to use checksums
ac08a1ddd0a85cdf086f449e8f1f797ca4d7b46db80776fe1eb90f0d9de0a0de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release files / AutoThemeGenerator-0.2.1-py3-none-any.whl

Download URL AutoThemeGenerator-0.2.1-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b0f4fd205e1562ac0b3cfd11fa3a7a749216f26660605735565c700d1ac6a33f
BLAKE2b-256 checksum
How to use checksums
c8acb0fbfdc0c20246d0b1e04b23459479a72fea3932f57f0651b1a70398bb84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

1 release file

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

1 release file

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