-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8a99b42
commit b25d5c3
Showing
5 changed files
with
135 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""GLAAD.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
"""GLAAD. | ||
--- | ||
layout: post | ||
source: GLAAD Media Reference Guide - 9th Edition | ||
source_url: http://www.glaad.org/reference | ||
title: GLAAD Guidelines | ||
date: 2016-07-06 | ||
categories: writing | ||
--- | ||
This check looks for offensive terms related to LGBTQ issues and | ||
raises an error marking them as offensive. The New York Times and | ||
Associated Press have also adopted this style guide. | ||
""" | ||
from proselint.tools import memoize, existence_check | ||
|
||
|
||
@memoize | ||
def check(text): | ||
"""Flag offensive words based on the GLAAD reference guide.""" | ||
err = "glaad.offensive_terms" | ||
msg = "Offensive term. Remove it or consider the context." | ||
|
||
list = [ | ||
"fag", | ||
"faggot", | ||
"dyke", | ||
"sodomite", | ||
"homosexual agenda", | ||
"gay agenda", | ||
"transvestite", | ||
"homosexual lifestyle", | ||
"gay lifestyle" | ||
# homo - may create false positives without additional context | ||
# FIXME use topic detetor to decide whether "homo" is offensive | ||
] | ||
|
||
return existence_check(text, list, err, msg, join=True, ignore_case=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
"""GLAAD. | ||
--- | ||
layout: post | ||
source: GLAAD Media Reference Guide - 9th Edition | ||
source_url: http://www.glaad.org/reference | ||
title: GLAAD Guidelines | ||
date: 2016-07-06 | ||
categories: writing | ||
--- | ||
This check looks for possibly offensive terms related to LGBTQ issues and | ||
makes more acceptable recommendations. TheNew York Times and | ||
Associated Press have also adopted this style guide. | ||
""" | ||
from proselint.tools import memoize, preferred_forms_check | ||
|
||
|
||
@memoize | ||
def check(text): | ||
"""Suggest preferred forms given the reference document.""" | ||
err = "glaad.terms" | ||
msg = "Possibly offensive term. Consider using '{}' instead of '{}'." | ||
|
||
list = [ | ||
["gay man", ["homosexual man"]], | ||
["gay men", ["homosexual men"]], | ||
["lesbian", ["homosexual woman"]], | ||
["lesbians", ["homosexual women"]], | ||
["gay people", ["homosexual people"]], | ||
["gay couple", ["homosexual couple"]], | ||
["sexual orientation", ["sexual preference"]], | ||
["openly gay", ["admitted homosexual", "avowed homosexual"]], | ||
["equal rights", ["special rights"]] | ||
] | ||
|
||
return preferred_forms_check(text, list, err, msg, ignore_case=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
"""Test GLAAD Guidelines.""" | ||
from __future__ import absolute_import | ||
|
||
from .check import Check | ||
|
||
from proselint.checks.glaad import offensive_terms as chk | ||
|
||
|
||
class TestCheck(Check): | ||
"""The test class for glaad.offensive_terms.""" | ||
|
||
__test__ = True | ||
|
||
@property | ||
def this_check(self): | ||
"""Bolierplate.""" | ||
return chk | ||
|
||
def test_smoke(self): | ||
"""Basic smoke test for glaad.offensive_terms.""" | ||
assert self.passes("""Smoke phrase with nothing flagged.""") | ||
assert self.passes("""I once met a gay man.""") | ||
assert not self.passes("""I once met a fag.""") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Test GLAAD Guidelines.""" | ||
from __future__ import absolute_import | ||
|
||
from .check import Check | ||
|
||
from proselint.checks.glaad import terms as chk | ||
|
||
|
||
class TestCheck(Check): | ||
"""The test class for glaad.terms.""" | ||
|
||
__test__ = True | ||
|
||
@property | ||
def this_check(self): | ||
"""Bolierplate.""" | ||
return chk | ||
|
||
def test_smoke(self): | ||
"""Basic smoke test for glaad.terms.""" | ||
assert self.passes("""Smoke phrase with nothing flagged.""") | ||
assert self.passes("""They were a gay couple.""") | ||
assert not self.passes("""He was a homosexual man.""") | ||
|
||
def test_homosexual_term(self): | ||
"""Check that the term homosexual does not get caught.""" | ||
assert self.passes("""Homosexual.""") | ||
|
||
def test_sexual_prefence(self): | ||
"""Check that sexual preference is flagged.""" | ||
assert not self.passes("""My sexual preference is for women.""") |