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

Guidelines based on GLAAD Media Reference #486

Merged
merged 4 commits into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions proselint/checks/lgbtq/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""GLAAD."""
41 changes: 41 additions & 0 deletions proselint/checks/lgbtq/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/lgbtq/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_lgbtq_offensive_terms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Tests for lgbtq.terms check."""
from __future__ import absolute_import

from .check import Check

from proselint.checks.lgbtq import offensive_terms as chk


class TestCheck(Check):
"""The test class for lgbtq.offensive_terms."""

__test__ = True

@property
def this_check(self):
"""Bolierplate."""
return chk

def test_smoke(self):
"""Basic smoke test for lgbtq.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_lgbtq_terms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""Tests for lgbtq.offensive_terms check."""
from __future__ import absolute_import

from .check import Check

from proselint.checks.lgbtq import terms as chk


class TestCheck(Check):
"""The test class for lgbtq.terms."""

__test__ = True

@property
def this_check(self):
"""Bolierplate."""
return chk

def test_smoke(self):
"""Basic smoke test for lgbtq.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.""")