Skip to content

Commit

Permalink
updates based on pr 486
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Grant authored and joshmgrant committed Jul 14, 2016
1 parent 8a99b42 commit b25d5c3
Show file tree
Hide file tree
Showing 5 changed files with 135 additions and 0 deletions.
1 change: 1 addition & 0 deletions proselint/checks/glaad/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""GLAAD."""
41 changes: 41 additions & 0 deletions proselint/checks/glaad/offensive_terms.py
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)
39 changes: 39 additions & 0 deletions proselint/checks/glaad/terms.py
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)
23 changes: 23 additions & 0 deletions tests/test_glaad_offensive_terms.py
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.""")
31 changes: 31 additions & 0 deletions tests/test_glaad_terms.py
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.""")

0 comments on commit b25d5c3

Please sign in to comment.