File: usage.py

package info (click to toggle)
python3-proselint 0.14.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,220 kB
  • sloc: python: 7,173; sh: 6; makefile: 3
file content (62 lines) | stat: -rw-r--r-- 2,019 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""Elementary Rules of Usage.

---
layout:     post
source:     Strunk & White
source_url: ???
title:      Elementary Rules of Usage
date:       2014-06-10 12:31:19
categories: writing
---

Strunk & White say:
1. Form the possessive singular of nouns by adding 's.
2. In a series of three or more terms with a conjunction, use a comma after
each term except the last.
3. Enclose parenthetic expressions between commas. ("This rule is difficult to
apply.")
4. Place a comma before a conjunction introducing an independent clause.
5. Do not join independent clauses with a comma; use a semi-colon. Or a period.
6. Do not break sentences in two. Do not use periods for the role of commas.
7. Use a colon after an independent clause if you introduce: a list of
particulars, an appositive, an application, or an illustrative quotation.
8. Use a dash to set off an abrupt break or interruption and to announce a
long appositive or summary.
9. The number of the subject determines the number of the verb. (MDPNB: This
will require nltk & syntactic parsing)
10. Use the proper case(grammatical gender) of pronouns.
    * MDPNB: hard case: "Give this work to whoever looks idle." `whoever looks
    idle` is the object of `to`.
11. A participial phrase at the beginning of a sentence must refer to the
grammatical subject.
"""

# from proselint.tools import memoize
# import re


# @memoize
# def check(text):
#     err = "strunk_white.usage"
#     msg = "Use of '{}'. {}"

#     bad_words = [
#         "obviously",
#         "utilize"
#     ]

#     explanations = {
#         "obviously":
#         "This is obviously an inadvisable word to use.",
#         "utilize":
#         r"Do you know anyone who *needs* to utilize the word utilize?"
#     }

#     errors = []
#     for word in bad_words:
#         occ = [m for m in re.finditer(word, text.lower())]
#         for o in occ:
#             errors.append((o.start(), o.end(), err,
#                           msg.format(word, explanations[word])))

#     return errors