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 columnscleansing.md- Summary statistics about the processinganalysis.md/analysis.html- LLM-generated insights reportapp.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file customer_question_extractor-0.1.0.tar.gz.
File metadata
- Download URL: customer_question_extractor-0.1.0.tar.gz
- Upload date:
- Size: 55.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c48ac05a8b5aa24c0b0bb52bd977c63b6e298d4b6c558725105161809e947c4
|
|
| MD5 |
589e086eeec80b26f8ab5487586faf48
|
|
| BLAKE2b-256 |
8e250f0b27ace3cb2b6b5c08dd06945904179e85334fd5c6bcfdfd3d3718a5f1
|
File details
Details for the file customer_question_extractor-0.1.0-py3-none-any.whl.
File metadata
- Download URL: customer_question_extractor-0.1.0-py3-none-any.whl
- Upload date:
- Size: 38.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a036ffd0f6b4ae61487624e6c6c7bb19e28afda7db403f1b7723cf0a80d58ba
|
|
| MD5 |
4ba1e6cb9e5651a74a7db50ec2b2e5d7
|
|
| BLAKE2b-256 |
8098fd28a2f209ed8ea47e5347469eb55de72d2b1b3022cd1525561b91716ca8
|