def singularize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}):
w = word.lower().capitalize()<EOL>if word in custom:<EOL><INDENT>return custom[word]<EOL><DEDENT>if word in singular:<EOL><INDENT>return singular[word]<EOL><DEDENT>if pos == NOUN:<EOL><INDENT>for a, b in singular_inflections:<EOL><INDENT>if w.endswith(a):<EOL><INDENT>return w[:-len(a)] + b<EOL><DEDENT><DEDENT>for suffix in ("<STR_LIT>", "<STR_LIT>", "<STR_LIT:n>", "<STR_LIT:e>", "<STR_LIT>", "<STR_LIT:s>"):<EOL><INDENT>if w.endswith(suffix):<EOL><INDENT>w = w[:-len(suffix)]<EOL>break<EOL><DEDENT><DEDENT>if w.endswith(("<STR_LIT>", "<STR_LIT>", "<STR_LIT>")):<EOL><INDENT>return w + "<STR_LIT:e>"<EOL><DEDENT>return w<EOL><DEDENT>return w<EOL>
Returns the singular of a given word.
        The inflection is based on probability rather than gender and role.