BlameGame is a Python package for detecting internal/external (dispositional/situational) attributions in text.
Project description
BlameGame: Sentence-Level Attribution Detection
BlameGame is a Python package for detecting internal/external (dispositional/situational) attributions in text at the sentence level. Whether you're exploring psychological patterns or analyzing narrative frameworks, BlameGame leverages a fine-tuned RoBERTa model to classify attribution types with high accuracy.
🎯 Features
- Sentence-Level Attribution: Detects situational and dispositional attributions within individual sentences.
- Transformer-Based Predictions: Utilizes a fine-tuned RoBERTa model for robust and context-aware classification.
- Seamless Processing: Handles large datasets with ease and outputs results in CSV format.
- Pretrained NLP Model: Leverages a Hugging Face-hosted model (
ryanboyd/AttributioNet) for precise attribution analysis. Model details can be found at https://huggingface.co/ryanboyd/AttributioNet
🚀 Installation
Install BlameGame directly via pip:
pip install blamegame
🔍 Usage
1. Import and Initialize
from blamegame.BlameGame import AttributionAnalyzer
analyzer = AttributionAnalyzer()
After importing the package and initializing the AttributionAnalyzer() class, you can process individual texts:
2a. Analyze Text
text = "She failed the test because she was unlucky."
sentence_results, overall_results = analyzer.process_text(text)
print(sentence_results)
... or batch process texts in a CSV file:
2b. Analyze a CSV File
analyzer.process_csv(input_csv="data.csv", row_id_col="ID", text_col="Text", output_dir="attribution-results/")
📜 How It Works
BlameGame tokenizes input text into sentences and uses a fine-tuned RoBERTa model to classify each sentence into one (or more) of four attribution types:
- Self-Dispositional (attributing the cause of one's own behavior to their traits/personality)
- Self-Situational (attributing the cause of one's own behavior to situational/circumstantial factors)
- Other-Dispositional (attributing the cause of someone else's behavior to their traits/personality)
- Other-Situational (attributing the cause of someone else's behavior to situational/circumstantial factors)
The model outputs both classification labels (0 or 1) and probability scores for each sentence, which are then also aggregated to provide an overall attribution summary for the input text. The classification labels reflect whether a sentence did (1) or did not (0) contain at least one attribution of each given type.
📌 Example Output
Sentence-Level Probabilities
| Sentence | Self-Disp. (Probability) | Self-Sit. (Probability) | Other-Disp. (Probability) | Other-Sit. (Probability) |
|---|---|---|---|---|
| "She failed the test because she was unlucky." | 0.00 | 0.00 | 0.41 | 0.75 |
| "I failed the exam because I didn't try hard enough." | 0.99 | 0.05 | 0.00 | 0.00 |
Overall/Average Predictions
| Text | Num Sentences | Self-Disp. (M. Prediction) | Self-Sit. (M. Prediction) | Other-Disp. (M. Prediction) | Other-Sit. (M. Prediction) |
|---|---|---|---|---|---|
| "She failed the test because she was unlucky. I failed the exam because I didn't try hard enough." | 2 | 0.50 | 0.00 | 0.00 | 0.50 |
📖 Dependencies
BlameGame relies on the following libraries:
transformers(for RoBERTa model loading)torch(for deep learning computations)nltk(for sentence tokenization)tqdm(for progress tracking)
These dependencies are installed automatically when using pip install blamegame.
🎓 Citation
Coming soon 😄
🤝 Contributing
Feel free to contribute to BlameGame! Open a pull request or file an issue on GitHub.
Enjoy using BlameGame for attribution detection!
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 blamegame-0.9.2.tar.gz.
File metadata
- Download URL: blamegame-0.9.2.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a4c2055b888156c77576fdab1b3e1d157ae491da0faae0300c91e3601f69263
|
|
| MD5 |
9083214ab77954e58a8790d12fceb410
|
|
| BLAKE2b-256 |
2dc36a20503e2f0ee6c1d5a080adcee5bbf7edeb51ab14cbb7b0c1fd9dfdf579
|
File details
Details for the file blamegame-0.9.2-py3-none-any.whl.
File metadata
- Download URL: blamegame-0.9.2-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd29ba2502ca8fe153314f7b8b73eb03948957e858583a68630961ccb1ea3ead
|
|
| MD5 |
1b039429ee1f924f6b9028f4ff6995d1
|
|
| BLAKE2b-256 |
bab42804123215d22c5c0bec34e21f865ae4a05dbb115b22e90b3b3514bebcd1
|