Skip to main content

Performing thematic analysis with OpenAI's GPT-4 models

Project description

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

Requirements

Required packages

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

  • openai

  • docx

  • tqdm

  • nltk

  • nltk.tokenize

  • python-docx

  • textract

  • zipfile

  • shutil

  • requests

  • json

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

pip install openai docx tqdm nltk nltk.tokenize python-docx textract zipfile shutil requests json

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.

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 GPT4QualitativeAnalysis 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 *



# 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

    "... ..." 

    )







# Specify the folders containing your transcript

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"





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





# optional (load your saved themes)

overall_synthesized_themes = load_results_from_json(

    os.path.join(save_results_path, "themes_overall.json"))



# 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

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

autothemegenerator-0.0.2.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

AutoThemeGenerator-0.0.2-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file autothemegenerator-0.0.2.tar.gz.

File metadata

  • Download URL: autothemegenerator-0.0.2.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.5

File hashes

Hashes for autothemegenerator-0.0.2.tar.gz
Algorithm Hash digest
SHA256 94a042dc74e8ec47fb3b633dca0467b59c82d7a1f14dfb1e5b79188ea0157de9
MD5 059bf0035bd6d8c3171d52633ef09bca
BLAKE2b-256 e7763cc94dc81a512ee7ba0d8eb97375520489be696090206edb3cbf04d0de21

See more details on using hashes here.

File details

Details for the file AutoThemeGenerator-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for AutoThemeGenerator-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b0ea195b4bd64630f763bf893cec48345aed4703e94aae3185f380c99e3a3846
MD5 45f8a384130091c0daaabe2166d19603
BLAKE2b-256 fd42bb47b9944ff25f59c3e969f450146c5ba73f7ebeff3b53d863cae5be1006

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