Giter Site home page Giter Site logo

cja5553 / autothemegenerator Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 398 KB

Code for Python package AutoThemeGenerator. Also part of codes for paper "GPT Models Can Perform Thematic Analysis in Public Health Studies, Akin to Qualitative Researchers"

Home Page: https://pypi.org/project/AutoThemeGenerator/

License: MIT License

Python 100.00%
gpt-4 qualitative-research thematic-analysis

autothemegenerator's Introduction

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

Y Yang, C Alba, C Wang, M Li, W Xi, A Jami, R An. "GPT Models Can Perform Thematic Analysis in Public Health Studies, Akin to Qualitative Researchers" Working paper.

Questions?

Contact me at [email protected]

autothemegenerator's People

Contributors

cja5553 avatar

Watchers

 avatar

Forkers

digeriuz77

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.