Debian Codegraph @

proselint/checks/mixed_metaphors/misc.py

raw
1 """Mixed metaphors."""
2
3 from proselint.tools import (existence_check, max_errors, memoize,
4 preferred_forms_check)
5
6
7 @max_errors(1)
8 @memoize
9 def check_bottleneck(text):
10 """Avoid mixing metaphors about bottles and their necks.
11
12 source: Sir Ernest Gowers
13 source_url: http://bit.ly/1CQPH61
14 """
15 err = "mixed_metaphors.misc.bottleneck"
16 msg = "Mixed metaphor — bottles with big necks are easy to pass through."
17 list = [
18 "biggest bottleneck",
19 "big bottleneck",
20 "large bottleneck",
21 "largest bottleneck",
22 "world-wide bottleneck",
23 "huge bottleneck",
24 "massive bottleneck",
25 ]
26
27 return existence_check(text, list, err, msg)
28
29
30 @memoize
31 def check_misc(text):
32 """Avoid mixing metaphors.
33
34 source: Garner's Modern American Usage
35 source_url: http://bit.ly/1T4alrY
36 """
37 err = "mixed_metaphors.misc.misc"
38 msg = "Mixed metaphor. Try '{}'."
39
40 preferences = [
41
42 ["cream rises to the top", ["cream rises to the crop"]],
43 ["fasten your seatbelts", ["button your seatbelts"]],
44 ["a minute to decompress", ["a minute to decompose"]],
45 ["sharpest tool in the shed", ["sharpest marble in the (shed|box)"]],
46 ["not rocket science", ["not rocket surgery"]],
47 ]
48
49 return preferred_forms_check(text, preferences, err, msg)