Package gender_render

{gender*render}

Template-system for rendering gender-neutral text-, email- and RPG-text-templates properly gendered and with the correct pronouns of all people involved.

Ever had the struggle of correctly gendering people in your automated emails? Are you sick of writing email templates that are unsupportive of non-binary people, gender everyone with ugly underscores, or clumsily avoid pronouns alltogether, costing you hours of work to frickle them together? With gender*render, you can write easy, gender-neutral templates for your emails, and automatically render them into correctly gendered emails, given the pronouns and names of all people concerned! [Jump to quickstart]

to quickstart

Gender*render is not only a piece of software that can definitely come in handy if you want to write progressive automated emails, but also a proof of concept. Many people say that correctly gendering non-binary people, people with unusual pronouns, or people with no pronouns at all in automated fashions is impossible. And many live by said premise. gender*render as a concept is supposed to be a proof that this is simply false, and that any such claims come from a mixture of missing will and laziness, with technical limitations merely being a pretext. Gender*render comes with an in-depth specification, so you can easily implement it in any language of your choice, port it to other (human) languages or read about the thoughts behind this project! [Download spec] [other versions & changelog]

download spec

Advantages/Features

Using gender*render offers a set of advantages over traditional "one for men and one for women"-email templates:

  • Supportive: Supports addressing one or multiple people in your texts, talking about them in the first as well as second person and multiple grammatical contexts, supports addressing people with no preferred way of addressing, supports preferences regarding noun gendering, supports neo-pronouns.

  • Easy: Easy enough for non-tech people to write templates with it - writing one template for all genders with gender*render may actually be easier than writing two templates for two genders.

  • Slim & Handy: gender*render doesn't get into your way and doesn't cluster up your template with syntax for things you don't need right now.

  • Portable: Comes as a python-module, but with a full specification that encourages re-implementation in different languages.

  • Reliable: Tested with 100% code- and branch coverage and a more than 2:1 testing code to actual code ratio.

  • Well-documented: Written with inspiration from literate programming, gender*render comes with a specification with in-depth elaboration on the underlying concepts, as well as full documentation of all methods, and a getting started guide.

If your web forms ask your customers for their pronoun preferences instead of their gender, preferably with text entry boxes instead of dropdowns, and you have these pronoun information in a nice data base, you can easily automate the process of correctly gendering your emails based on the person they are directed to.

Content 📖

  1. Introduction
  2. Advantages & Features
  3. Content <– you are here
  4. Quick start
  5. Spec downloads & changelog
  6. stats & links
  7. Mission Statement
  8. License
  9. Development & Contributing
  10. Code of Conduct

Quick Start 🚗💨

InstallationUsageTemplate Syntax

Installation

pip3 install gender-render

Usage

import gender_render as gr

# use:
rendered_template_as_a_str = gr.render_template(
    template_as_a_string,
    pronoun_data_as_a_string_or_dict
)

# or:
rendered_template_as_a_str = gr.render_template(
    template_file_path,
    pronoun_data_file_path,
    takes_file_path=True
)

Template Syntax

Template & Pronoun Data Result
**Addressing one person**: * Template:
Dear {Mr_s Doe},
Yesterday, I was asked about your
wellbeing, "Is there reason to worry
about {them}?", and I told the
person who asked that [...]
* Pronoun Data:
{
    "address": "Mrs",
    "family-name": "Smith",
    "object": "her"
}
Having more value in the pronoun data than needed is, of course, also allowed!
Dear Mrs Smith,
Yesterday, I was asked about your
wellbeing, "Is there reason to worry
about her?", and I told the
person who asked that [...]
**Addressing multiple persons**: * Template:
Dear {seller* Mr_s Doe},

According to our guidelines, the
issue with {reseller* Mr_s Doe} is
best resolved if {reseller*they}
publically apologizes to
{buyer* Mr_s Doe} for {reseller*their}
behavior.

Best regards,
{customer_support* Jean Doe}
* Pronoun Data:
{
 "seller": {
    "address": "Mrs",
    "name": "Brown"
  },
  "reseller": {
    "address": "Mr",
    "name": "Jones",
    "subject": "he",
    "dpossessive": "his"
  },
  "buyer": {
    "address": "Mx",
    "name": "Ainge"
  },
  "customer_support": {
    "first-name": "Emma",
    "name": "Ackernick"
  }
}
Note that all these attributes can take any value; not only "Mr" and "Mrs" is valid!
Dear Mrs Brown,

According to our guidelines, the
issue with Mr Jones is
best resolved if he
publically apologizes to
Mx Ainge for his
behavior.

Best regards,
Emma Ackernick
**gender*render doesn't get into your way, since you can fuse any sequence of tags into one tag**: * Template:
"{Mr_s} {Doe}"

equals

"{Mr_s Doe}".
* Pronoun Data:
{
  "address": "Ind.",
  "name": "Abrams"
}
"Ind. Abrams"

equals

"Ind. Adams"
**Address individuals who don't want to get a special title**: * Template:
Dear {Mr_s Doe},
[...]
* Pronoun Data:
{
  "gender-addressing": "false",
  "name": "Chase",
  "first-name": "Joey"
}
Dear Joey Chase,
[...]
**Refer to individuals with hyponyms for person or by their profession**: * Template:
I hope the {actor} is doing well.
* Pronoun Data:
{
  "gender-nouns": "female"
}
Available values are "male", "female" and "neutral".
I hope the actress is doing well.
Note that this also works for words that start with capital letters - "Actor" would've been gendered as "Actress"!
***Every* gendered noun has a neutral version available**: * Template:
As a {salesman}, {they} had to face
great hardships!
* Pronoun Data:
{
  "subject": "they",
  "gender-nouns": "neutral"
}
"neutral" is also the default value.
As a salesperson, they had to face
great hardships!
**If a noun has no explicit specific version for a grammatical gender, the neutral version of the noun is used**: * Template:
Since tuesday, {they} serve as a
{cadet}.
* Pronoun Data:
{
  "subject": "they",
  "gender-nouns": "female"
}
Since tuesday, they serve as a
cadet.
**Define your own properties**: * Template:
After {they} ate {their}
{<favorite_food>} like any
other {child}, {they} slept.
* Pronoun Data:
{
  "subject": "ze",
  "dpossessive": "zen",
  "<favorite_food>": "spaghetti"
}
After ze ate zen
spaghetti like any
other child, ze slept.

Download Specifications & Changelog

gender*render follows a strict set of easily implementable specifications. The implementations explain in-depth which design decision was taken why and how gender*render works exactly, but also define guidelines for re-implementing gender*render for different programming- and well as natural languages, and contain various findings and ideas/ concepts on how to deal with various aspects of grammatical gender and automated gendering in a technical context, some of whom might help you in writing related or similar tools.

There is one main specification ("spec"), as well as several extensions specifications ("ext-…"). To get started, you can download the main specification, which dives further into the versioning scheme of gender*render specifications, their vision and development model, or download any specification in any version from the following list.

Clicking a version number downloads the specification as a pdf file, whilst the [html↗]-link next to every specification version leads to a hosted html version of the specification.

  • spec:
  • download latest
  • v0.6.0 [html↗] - Add capitalization system, suggest error hierarchy, list implementation-specific warnings.
  • v0.5.0 [html↗] - Add instructions for word splitting for ungendered-word-warnings to the specification.
  • v0.4.0 [html↗] - Change "gripd" to "idpd".
  • v0.3.0 [html↗] - Extend on how to determine whether an implementation follows the standard or not regarding the extension specs.
  • v0.2.0 [html↗] - Add the concept of canonical context values and direct-mapped context values to the specification.
  • v0.1.1 [html↗] - Mention RGB-dialogues as a possible use case.
  • v0.1.0 [html↗] - Initial release

GitHub badges

Implementation

attribute value
PyPi PyPI download total PyPI version PyPI pyversions
license implementation license
maintenance Average time to resolve an issue Percentage of issues still open
tests codecov vulture
documentation here
build build

Specification

attribute value
license implementation license
download latest dowload
other downloads here

Mission Statement 📕

gender*render (as a project) is motivated by a column of three numerated goals and visions, that it is committed to and that define its vision:

  1. enable people and corporations to use fully gender-inclusive language in auto-generated texts, be it in an email, notification or computer game (that's what the implementation is for).
  2. proof that gender-inclusive language in tech and even auto-generated by an algorithm is very well possible (by providing a specification system for this and related subjects).
  3. (passively) raise awareness to the necessity and practicability of gender-inclusive language and specifically the use and acceptance of gender-inclusive language systems in tech and algorithms (by providing 1 & 2).

These three missions are listed in ascending order of importance (3 is the end goal or the bigger picture, whilst 1 and 2 are the means), as well as vaguely descending order according to how active the project pursues them (3 is pursued purely passively by simply providing 1 and 2, yet serves as their motivation).

In addition to being devoted to its mission, gender*render is dedicated to the ideals of its code of conduct.

License

Specification and implementation are licensed separately. For the specification, see here (OWFa 1.0). For the implementation, see here (MIT).

For the data sets (e.g. of gendered nouns) that gender*render uses, refer to the individual licenses included in the files in the src/data directory in the TAR-ball from PyPi; these data sets are all licensed under permissive licenses, but might require different forms of attributions to different people in case you want to modify or redistribute them.

Development & Contributing

Questions, suggestions and issues as well as pre-discussed pull requests are welcome. See here for additional information.

Code of Conduct

In general, be decent and don't put shame on the 21st century. See here for additional information.

Reference Implementation

The gender*render-python reference implementation. For documentation and a usage guide, see https://phseiff.com/gender-render/

This implementation follows the specification(s) found here: https://phseiff.com/gender-render/#download-specifications

The interfaces defined by the main specification can be found as gender_render.Template, (from gender_render.template_interface), gender_render.PronounData (from gender_render.pronoun_data_interface) and render_template().

To find out how to enable and disable warnings, refer to the documentation of gender_render.warnings.

Expand source code Browse git
#!/usr/bin/env python
"""

.. include:: ../README.md

## Reference Implementation

The gender*render-python reference implementation.
For documentation and a usage guide, see https://phseiff.com/gender-render/

This implementation follows the specification(s) found here:
https://phseiff.com/gender-render/#download-specifications

The interfaces defined by the main specification can be found as `gender_render.Template`, (from
`gender_render.template_interface`), `gender_render.PronounData` (from `gender_render.pronoun_data_interface`) and
`gender_render.render_template`.

To find out how to enable and disable warnings, refer to the documentation of `gender_render.warnings`.
"""

__author__ = "phseiff"
__version__ = "1.1.0"

import typing
from .handle_context_values import GRPD, IDPD

from . import warnings
from .pronoun_data_interface import PronounData
from .template_interface import Template

# the render_template function from the specification:


def render_template(template, pronoun_data: typing.Union[str, GRPD, IDPD], takes_file_path=False,
                    warning_settings: warnings.WarningSettingType = warnings.ENABLE_DEFAULT_WARNINGS):
    """Accepts a gender*render template as a string and a string or dict of pronoun data or, if `takes_file_path` is
    True, two file paths to both, and returns the template rendered with the given pronoun data.
    Serves as a shortcut for Template(...).render(PronounData(...), ...)"""

    pd = PronounData(pronoun_data, takes_file_path, warning_settings)
    tr = Template(template, takes_file_path, warning_settings)
    return tr.render(pd, warning_settings=warning_settings)

Sub-modules

gender_render.errors

Custom error types, as defined by the gender*render specification …

gender_render.gender_nouns

Functions to gender nouns with gender bias correctly …

gender_render.global_capitalization_system

Implementation of the global capitalization system (a concept explained in-depth in the specification), which analyses and understands …

gender_render.handle_context_values

Functions that regard gender*render pronoun data's properties and attributes and their relationship to context-values of tags.

gender_render.parse_pronoun_data

Contains functions for gender*render pronoun data.

gender_render.parse_templates

Parser functions for gender*render templates.

gender_render.pronoun_data_interface

The interface to gender*render pronoun data representations presented to the user.

gender_render.render_pipeline

Contains the functions to render templates and pronoun data, bundled together in a class. This is the submodule where pronoun data and templates …

gender_render.template_interface

The interface to gender*render template representations presented to the user.

gender_render.warnings

Defines the warnings specified by the spec …

Functions

def render_template(template, pronoun_data: Union[str, Dict[str, Dict[str, str]], Dict[str, str]], takes_file_path=False, warning_settings: Union[Set[Type[Union[GRWarningGRLogging]]], FrozenSet[Type[Union[GRWarningGRLogging]]]] = frozenset({<class 'gender_render.warnings.FreeGenderedPersonNounWarning'>, <class 'gender_render.warnings.GenderedNounsBuildFromWebWarning'>, <class 'gender_render.warnings.FreeUngenderedPersonNounWarning'>, <class 'gender_render.warnings.DefaultValueUsedWarning'>, <class 'gender_render.warnings.NotAPersonNounWarning'>, <class 'gender_render.warnings.UnexpectedFileFormatWarning'>, <class 'gender_render.warnings.NotANounWarning'>, <class 'gender_render.warnings.IdMatchingNecessaryWarning'>, <class 'gender_render.warnings.NotAWordWarning'>, <class 'gender_render.warnings.UnknownPropertyWarning'>, <class 'gender_render.warnings.FreePronounFoundWarning'>, <class 'gender_render.warnings.GRWarning'>, <class 'gender_render.warnings.NounGenderingGuessingsWarning'>}))

Accepts a gender*render template as a string and a string or dict of pronoun data or, if takes_file_path is True, two file paths to both, and returns the template rendered with the given pronoun data. Serves as a shortcut for Template(…).render(PronounData(…), …)

Expand source code Browse git
def render_template(template, pronoun_data: typing.Union[str, GRPD, IDPD], takes_file_path=False,
                    warning_settings: warnings.WarningSettingType = warnings.ENABLE_DEFAULT_WARNINGS):
    """Accepts a gender*render template as a string and a string or dict of pronoun data or, if `takes_file_path` is
    True, two file paths to both, and returns the template rendered with the given pronoun data.
    Serves as a shortcut for Template(...).render(PronounData(...), ...)"""

    pd = PronounData(pronoun_data, takes_file_path, warning_settings)
    tr = Template(template, takes_file_path, warning_settings)
    return tr.render(pd, warning_settings=warning_settings)