Skip to content

Commit

Permalink
Merge pull request #339 from jsenn/fix-exclam
Browse files Browse the repository at this point in the history
Complain about punctuational exclamation marks only. Fixes #322
  • Loading branch information
suchow committed Mar 8, 2016
2 parents 96f33dc + 3ca7ac3 commit 1d2fd6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions proselint/checks/leonard/exclamation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
Too much yelling.
"""
import re

from proselint.tools import existence_check, memoize


Expand All @@ -35,13 +37,15 @@ def check_exclamations_ppm(text):
err = "leonard.exclamation.30ppm"
msg = u"More than 30 ppm of exclamations. Keep them under control."

count = text.count("!")
regex = r"\w!"

count = len(re.findall(regex, text))
num_words = len(text.split(" "))

ppm = (count*1.0 / num_words) * 1e6

if ppm > 30:
loc = text.find('!')
loc = re.search(regex, text).start() + 1
return [(loc, loc+1, err, msg)]
else:
return []

0 comments on commit 1d2fd6c

Please sign in to comment.