tttt Utils Documentation
Codeberg repository |
Main Page |
Programs List |
Utils Documentation
This is documentation of the utils.py module in tttt.
This may be useful for contributing.
If you were looking for documentation for the commands/usage of tttt,
see the Programs List.
This will be formatted as a list of functions with explanations of what
they do and how to use them.
Table of Contents
capitalise
capitalise(list: prompt)
This capitalises the beginning of a sentence, and also capitalises every lowercase word “i”. It expects the sentence as a list with each word as an entry, and it returns the text back as a list of words.
check_a_an
check_a_an(list: prompt, str: help_command)
This checks if the used article is correct, and exits if otherwise. It
expects a list of the word and the article used for it (such as
["a", "penguin"] in that order) for the prompt
argument, and the help_command argument is the command that
it displays for help in the case of the article being wrong. In said case,
it will also exit the program. If it does not exit, it will return the
combined string of the article and word (e.g., "a penguin").
person_swaps
person_swaps(list: prompt, int: person)
This swaps first-person pronouns for second-person pronouns, and vice versa. It expects the sentence as a list with each word as an entry. Here is the table of words it converts:
| Input | Output |
|---|---|
youre | I am |
you're | I am |
me | you |
my | your |
your | my |
are | am |
am | are |
i | you |
I | you |
I'm | you are |
i'm | you are |
Im | you are |
im | you are |
myself | yourself |
yourself | myself |
If person is set to 1, “you” will become
“me”. Otherwise (in which case person should be 2),
“you” will become “I”. It will return the text back as a list of words.
get_arg0
get_arg0()
This normalises sys.argv[0] to the filename of the module that was ran
first (without -.py). It excepts no arguments and returns a new argv
with the normalised [0].
do_grammar
do_grammar(list: prompt, int: person, str: help_command)
This is a wrapper around checking every article with check_a_an() and
using person_swaps(). person works the same as in
person_swaps(), and help_command works the same as in
check_a_an(). It expects the sentence to be in prompt as a list with
each word as an entry, and it returns the text back as a list of words.