Skip to main content

Extract and deduplicate customer questions from text data

Project description

Question Extractor

A Python package for extracting and deduplicating customer questions from text data (e.g., call center transcripts).

Features

  • Text Summarization: Remove fillers and extract key content from conversations
  • Question Extraction: Identify distinct customer questions and concerns using GPT-4o
  • Two-Tier Deduplication:
    • Fuzzy matching with RapidFuzz (75% similarity threshold)
    • Semantic clustering with OpenAI embeddings
  • Cost Estimation: Get estimated API costs and processing time before running
  • Analysis Reports: Auto-generated markdown and HTML reports with insights
  • Interactive Dashboard: Streamlit app for exploring results

Installation

pip install customer-question-extractor

Or install from source:

git clone https://github.com/dan-shah/question-extractor.git
cd question-extractor
pip install -e ".[dev]"

Quick Start

CLI Usage

# Set your OpenAI API key
export OPENAI_API_KEY=your-api-key

# Estimate cost and time
question-extractor estimate data.csv --text-col transcript --id-col call_id

# Run the full pipeline
question-extractor run data.csv --text-col transcript --id-col call_id --output-dir output/

# Launch the dashboard
question-extractor serve output/

Python API

from question_extractor import Config, Pipeline

# Configure
config = Config(
    openai_api_key="your-api-key",
    text_column="transcript",
    id_column="call_id",
    output_dir="output",
)

# Initialize and run
pipeline = Pipeline(config)

# Get cost estimate first
estimate = pipeline.estimate(input_path="data.csv")
print(estimate.format_summary())

# Run the pipeline
result = pipeline.run(input_path="data.csv")

# Access results
print(f"Processed {result.stats.input_rows} rows")
print(f"Extracted {result.stats.questions_extracted} questions")
print(f"Final unique questions: {result.stats.final_unique}")

Configuration

Parameter Default Description
text_column "text" Column containing text to process
id_column "row_id" Column with unique row identifier
fuzzy_threshold 0.75 RapidFuzz similarity threshold (0-1)
semantic_distance_threshold 0.7 Agglomerative clustering distance
top_questions_percentile 0.75 % of questions by volume for semantic clustering

Output Files

After running the pipeline, you'll find these files in the output directory:

  • clean.csv - Processed data with row_id, question, and semantic_cluster columns
  • cleansing.md - Summary statistics about the processing
  • analysis.md / analysis.html - LLM-generated insights report
  • app.py - Streamlit dashboard for interactive exploration

Requirements

  • Python 3.9+
  • OpenAI API key
  • Dependencies: openai, pandas, rapidfuzz, scikit-learn, streamlit, typer, rich

License

MIT License

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

customer_question_extractor-0.1.0.tar.gz (55.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

customer_question_extractor-0.1.0-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

Details for the file customer_question_extractor-0.1.0.tar.gz.

File metadata

File hashes

Hashes for customer_question_extractor-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5c48ac05a8b5aa24c0b0bb52bd977c63b6e298d4b6c558725105161809e947c4
MD5 589e086eeec80b26f8ab5487586faf48
BLAKE2b-256 8e250f0b27ace3cb2b6b5c08dd06945904179e85334fd5c6bcfdfd3d3718a5f1

See more details on using hashes here.

File details

Details for the file customer_question_extractor-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for customer_question_extractor-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a036ffd0f6b4ae61487624e6c6c7bb19e28afda7db403f1b7723cf0a80d58ba
MD5 4ba1e6cb9e5651a74a7db50ec2b2e5d7
BLAKE2b-256 8098fd28a2f209ed8ea47e5347469eb55de72d2b1b3022cd1525561b91716ca8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page