A Python module for detecting dangling prepositions and other grammatical constructs.
Project description
Bennie
A Python module for detecting dangling prepositions and other grammatical constructs that your English teacher warned you about.
Motivation
This module is dedicated to my mom, an English teacher of 30 years, who would always catch me when I'd end a sentence with a preposition. Bennie helps you identify these constructions - not to judge, but to give you the tools to make informed decisions about what you want to end your sentences with.
What is it?
Bennie is a modular Python package designed to detect various "dangling" grammatical elements in English text. Currently, it focuses on dangling prepositions, but it's built to expand to other constructs like dangling participles and modifiers.
Note: We don't judge here! Sometimes ending with a preposition is perfectly fine and more natural. This tool simply helps you identify these patterns so you can decide what to do about them.
Installation
# Install from PyPI
pip install bennie
# Install the required spaCy language model
python -m spacy download en_core_web_sm
Development Installation:
# Clone the repository
git clone https://github.com/willwillis/bennie.git
cd bennie
# Install with uv (recommended)
uv sync
# Or install with pip
pip install -e .
# Install the spaCy model
python -m spacy download en_core_web_sm
Quick Start
from bennie import find_dangling_prepositions
# Test some sentences (with intentional dangling prepositions for irony)
text = "What are you looking at?"
found, sentences = find_dangling_prepositions(text)
if found:
print("Found dangling prepositions in:")
for sentence in sentences:
print(f" - {sentence}")
Examples
Here are some examples of what Bennie can help you identify:
from bennie import find_dangling_prepositions
test_cases = [
"What are you looking at?", # ✓ Dangling preposition detected
"This is what I was talking about.", # ✓ Dangling preposition detected
"Where did you come from?", # ✓ Dangling preposition detected
"She gave the book to him.", # ✗ No dangling preposition
"The house that Jack built.", # ✗ No dangling preposition
]
for text in test_cases:
found, _ = find_dangling_prepositions(text)
status = "🔍 Found" if found else "✅ Clean"
print(f"{status}: {text}")
Testing
Run the test suite to see Bennie in action:
uv run python run_tests.py
Architecture
Bennie is designed with modularity in mind, making it easy to add new detectors for different grammatical constructs:
bennie/
├── __init__.py # Public interface
├── core.py # Shared utilities (spaCy model loading)
└── detectors/
├── __init__.py
├── prepositions.py # Dangling preposition detection
└── (future detectors) # participles.py, modifiers.py, etc.
Future Plans
- Dangling Participles: "Walking down the street, the trees looked beautiful."
- Dangling Modifiers: "After eating the sandwich, the park was lovely."
- Split Infinitives: "To boldly go where no one has gone before."
- Custom Rules: Add your own grammatical pet peeves to catch.
Technical Details
Bennie uses spaCy's en_core_web_sm model for natural language processing. The detection algorithm identifies prepositions (POS tag "ADP") that appear at the end of sentences or clauses without a clear object.
Contributing
Got a grammatical construct you'd like Bennie to help identify? Contributions are welcome! The modular architecture makes it easy to add new detectors without breaking existing functionality.
A Note on Prescriptivism vs. Descriptivism
While some grammar rules are more guidelines than absolute laws, this tool exists to help you write with intention. Sometimes ending with a preposition is exactly what you want to do - and that's something this tool won't argue with.
"This is the sort of English up with which I will not put." - Often attributed to Winston Churchill (though he probably never said it)
Remember: Good writing is about clarity and communication, not following every rule you were taught in school. Use Bennie as a guide, not a judge! 🎓
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 bennie-1.0.2.tar.gz.
File metadata
- Download URL: bennie-1.0.2.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
883c415dfd9f507be08972d43920548258197aa80bb5ddc849f66201f38801cf
|
|
| MD5 |
31b8822f78daf531e7e8370957424780
|
|
| BLAKE2b-256 |
2d4105b2d95672f742243285bd5b23cb499ca067697c51fc3c3f3dbe3463248f
|
Provenance
The following attestation bundles were made for bennie-1.0.2.tar.gz:
Publisher:
publish.yml on willwillis/Bennie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bennie-1.0.2.tar.gz -
Subject digest:
883c415dfd9f507be08972d43920548258197aa80bb5ddc849f66201f38801cf - Sigstore transparency entry: 335993446
- Sigstore integration time:
-
Permalink:
willwillis/Bennie@e88fac396cf2692f7edc52764a018591e0e8e3d9 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/willwillis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e88fac396cf2692f7edc52764a018591e0e8e3d9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file bennie-1.0.2-py3-none-any.whl.
File metadata
- Download URL: bennie-1.0.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5acd5ca26d83602677eafa05bd3eb508b3dd836b9b706d1156d8f9f66cf29e0d
|
|
| MD5 |
cab440bd43ef026d7a62426abd23a3f0
|
|
| BLAKE2b-256 |
182fa7e12698fa2a52b8298d6348a5d1aed72fd9273f225c4cc4bb2ce4a7b711
|
Provenance
The following attestation bundles were made for bennie-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on willwillis/Bennie
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
bennie-1.0.2-py3-none-any.whl -
Subject digest:
5acd5ca26d83602677eafa05bd3eb508b3dd836b9b706d1156d8f9f66cf29e0d - Sigstore transparency entry: 335993468
- Sigstore integration time:
-
Permalink:
willwillis/Bennie@e88fac396cf2692f7edc52764a018591e0e8e3d9 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/willwillis
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e88fac396cf2692f7edc52764a018591e0e8e3d9 -
Trigger Event:
push
-
Statement type: