
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
magic_profanity
is a Python library for detecting and censoring profanity in text using customizable word lists and character mappings. It supports English and Hinglish, with enhanced features including:
pip install magic_profanity
nltk
(for sentiment analysis)from magic_profanity import ProfanityFilter
Basic initialization:
profanity_filter = ProfanityFilter()
With sentiment analysis:
profanity_filter = ProfanityFilter(enable_sentiment=True)
With all features enabled:
profanity_filter = ProfanityFilter(
enable_sentiment=True,
sentiment_options={
'custom_threshold': {'positive': 0.1, 'negative': -0.1},
'preprocess_text': True
},
enable_enhancement=True
)
From a list:
profanity_filter.load_words(["badword1", "badword2"])
From a file:
profanity_filter.load_words_from_file("path/to/custom_wordlist.txt")
text = "This sentence contains a badword1 and a BadWord2."
if profanity_filter.has_profanity(text):
print("Profanity detected!")
else:
print("No profanity found.")
censored_text = profanity_filter.censor_text(text)
print(censored_text)
profanity_filter.add_custom_words(["newbadword1", "newbadword2"])
profanity_filter.char_map = {
"a": ("a", "@", "*", "4"),
"i": ("i", "*", "l", "1"),
"o": ("o", "*", "0", "@"),
# Add more mappings as needed
}
text = "This product is amazing! I'm really happy with it."
analysis = profanity_filter.analyze_text(text)
print(f"Censored text: {analysis['censored_text']}")
print(f"Contains profanity: {analysis['contains_profanity']}")
print(f"Sentiment: {analysis['sentiment']['classification']}")
print(f"Sentiment scores: {analysis['sentiment']['scores']}")
text = "This product is absolutely amazing! I couldn't be happier with it."
analysis = profanity_filter.analyze_text(text, detailed=True)
print(f"Sentiment: {analysis['sentiment']['classification']}")
print(f"Confidence: {analysis['sentiment']['confidence']}")
print(f"Emotion indicators: {analysis['sentiment']['emotion_indicators']}")
text = "This damn product is terrible. I hate how it always breaks!"
analysis = profanity_filter.analyze_text(text)
# Print enhancement suggestions
suggestions = analysis['enhancement_suggestions']
for category, items in suggestions.items():
if category != 'overall_recommendations' and items:
print(f"\n{category.replace('_', ' ').title()}:")
for suggestion in items:
print(f"- Replace '{suggestion['original']}' with: {', '.join(suggestion['suggestions'])}")
elif category == 'overall_recommendations' and items:
print("\nOverall recommendations:")
for recommendation in items:
print(f"- {recommendation}")
# Initialize with all features enabled
# Initialize with all features enabled
profanity_filter = ProfanityFilter(
enable_sentiment=True,
sentiment_options={
'custom_threshold': {'positive': 0.1, 'negative': -0.1},
'preprocess_text': True
},
enable_enhancement=True
)
# Analyze text
text = "This damn product is terrible. I hate how it always breaks!"
analysis = profanity_filter.analyze_text(text, detailed=True)
# Use the analysis results
print(f"Censored: {analysis['censored_text']}")
print(f"Sentiment: {analysis['sentiment']['classification']} ({analysis['sentiment']['confidence']})")
if analysis['enhancement_suggestions']['politeness_improvements']:
print("\nSuggested improvements:")
for suggestion in analysis['enhancement_suggestions']['politeness_improvements']:
print(f"- Replace '{suggestion['original']}' with: {', '.join(suggestion['suggestions'])}")
Contributions are welcome!
Please open an issue or pull request on GitHub with your suggestions, bug reports, or enhancements.
This project is licensed under the MIT License β see the LICENSE
file for details.
FAQs
A Python library for detecting and censoring profanity in text
We found that magic-profanity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.