Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a plugin system #2

Closed
suchow opened this issue Jan 14, 2015 · 0 comments · Fixed by #13
Closed

Create a plugin system #2

suchow opened this issue Jan 14, 2015 · 0 comments · Fixed by #13

Comments

@suchow
Copy link
Member

suchow commented Jan 14, 2015

I want a single code file for each check that:

  1. Implements the check.
  2. Includes a docstring that is autogenerated into a web page.
  3. Includes test cases that do and do not raise an error.

Here a sample of what I'm imagining:

"""DFW001: Comparing uncomparables.

---
layout:     post
error_code: DFW201
source:     David Foster Wallace
title:      PL001: Comparing an uncomparable
date:       2014-06-10 12:31:19
summary:    Comparing an uncomparable.
categories: check

---

David Foster Wallace says:

> This is one of a class of adjectives, sometimes called "uncomparables", that
can be a little tricky. Among other uncomparables are precise, exact, correct,
entire, accurate, preferable, inevitable, possible, false; there are probably
two dozen in all. These adjectives all describe absolute, non-negotiable
states: something is either false or it's not; something is either
inevitable or it's not. Many writers get careless and try to modify
uncomparables with comparatives like more and less or intensives like very. But
if you really think about them, the core assertions in sentences like "War is
becoming increasingly inevitable as Middle East tensions rise"; "Their cost
estimate was more accurate than the other firms'"; and "As a mortician, he has
a very unique attitude" are nonsense. If something is inevitable, it is bound
to happen; it cannot be bound to happen and then somehow even more bound to
happen. Unique already means one-of-a-kind, so the adj. phrase very unique is
at best redundant and at worst stupid, like "audible to the ear" or
"rectangular in shape". You can blame the culture of marketing for some of
this difficulty. As the number and rhetorical volume of US ads increase, we
become inured to hyperbolic language, which then forces marketers to load
superlatives and uncomparables with high-octane modifiers (special --- very
special --- Super-special! --- Mega-Special!!), and so on. A deeper issue
implicit in the problem of uncomparables is the dissimilarities between
Standard Written English and the language of advertising. Advertising English,
which probably deserves to be studied as its own dialect, operates under
different syntactic rules than SWE, mainly because AE's goals and assumptions
are different. Sentences like "We offer a totally unique dining experience";
"Come on down and receive your free gift"; and "Save up to 50 per cent... and
more!" are perfectly OK in Advertising English — but this is because
Advertising English is aimed at people who are not paying close attention.
If your audience is by definition involuntary, distracted and numbed, then free
gift and totally unique stand a better chance of penetrating — and simple
penetration is what AE is all about. One axiom of Standard Written English is
that your reader is paying close attention and expects you to have done the
same.
"""

import re


def check(text):

    error_code = "PL001"
    msg = "Comparison of an uncomparable."  # do formatting thing

    comparators = [
        "very",
        "more",
        "less",
        "extremely",
        "increasingly"
    ]

    uncomparables = [
        "unique",
        "correct",
        "inevitable",
        "possible",
        "false",
        "true"
    ]

    errors = []
    for comp in comparators:
        for uncomp in uncomparables:
            occurences = [
                m.start() for m in re.finditer(comp + "\s" + uncomp, text)]
            for o in occurences:
                errors.append((1, o, error_code, msg))
    return errors

def test1():
    pass
@suchow suchow added this to the v1.0.0 milestone Jan 14, 2015
suchow pushed a commit that referenced this issue Jan 14, 2015
suchow pushed a commit that referenced this issue Sep 25, 2015
suchow pushed a commit that referenced this issue Sep 25, 2015
suchow pushed a commit that referenced this issue Sep 27, 2015
suchow pushed a commit that referenced this issue Sep 27, 2015
suchow pushed a commit that referenced this issue Sep 27, 2015
suchow pushed a commit that referenced this issue Sep 27, 2015
suchow pushed a commit that referenced this issue Sep 27, 2015
suchow added a commit that referenced this issue Sep 27, 2015
laraross added a commit that referenced this issue Sep 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant