Debian Codegraph @

proselint/checks/lexical_illusions/misc.py

raw
1 """Lexical illusions.
2
3 ---
4 layout: post
5 source: write-good
6 source_url: https://github.com/btford/write-good
7 title: Lexical illusion present
8 date: 2014-06-10 12:31:19
9 categories: writing
10 ---
11
12 A lexical illusion is when a word word is unintentionally repeated twice, and
13 and this happens most often between line breaks.
14
15 """
16 from proselint.tools import existence_check, memoize
17
18
19 @memoize
20 def check(text):
21 """Check the text."""
22 err = "lexical_illusions.misc"
23 msg = "There's a lexical illusion here: a word is repeated."
24 regex = r"\b(?<!\-)(\w+)(\b\s\1)+\b"
25 exceptions = [r"^had had$", r"^that that$"]
26
27 return existence_check(text, [regex], err, msg, exceptions=exceptions,
28 require_padding=False)