A collection of useful functions for writers to analyze text/stories.

Overview

AuthorTools

AuthorTools provides a multitude of functions for easily analyzing (your?) writing. AuthorTools is made especially for creative writers with some python skills, or developers of writing applications. It contains tools to split strings in a variety of ways, such as into sentences or by chapter, and functions to analyze text, like counting the percent of a text that is composed of dialogue (in quotes).

Installation

AuthorTools is available on PyPI.

pip install authortools

Usage

AuthorTools provides its functions in authortools.py. After installation, you will need to import the tools.

import authortools

Then, all functions should be available to you.

import authortools
authortools.word_count("Sample Text.")

There is also another module that contains samples of many of the functions in authortools.py. It's useful if you just want to see a bunch of results on some writing, without going too deep into the tools here.

from authortools import writing_analysis
writing_analysis.run_tests("Sample Text.")

The easiest way to get started with the tools is to copy-paste your story (or whatever) into a .txt file, and read it into a string in Python. Then run the functions on it.

import authortools

text_file = open("input.txt", "r", encoding="utf8")
text = text_file.read()
text_file.close()

print(authortools.avg_word_length(text))

Functions

Sentences

authortools.sentences("First Sentence.  Second Sentence\nThird Sentence.")

Returns an array of individual sentences found in the text. Based on spaces (two spaces, \n, or \t).

Sentences by punctuation

authortools.sentences_by_punctuation("First Sentence.  Second Sentence\nStill the second sentence.")

Returns an array of individual sentences found in the text. Based on punctuation (.?!).

Words

authortools.words("There's like six different words there.")

Returns an array of individual words found in the text. Splits at all spaces and removes most punctuation except those part of the word itself.

Quotes

authortools.quotes("\"This quote will be added to the returned array,\" he said. \"This one will be too; but mine ends with an exclaimation point, which won't be removed, like your comma will be!\" I clarified.")

Returns an array of quotes found in the text. Trailing comma and quotation marks are trimmed from the resulting array.

Chapters

authortools.chapters("Title: Whether this is included is optional.  Chapter 1\nThis is the first chapter.\nChapter 2: This is the second chapter.")

Returns an array of chapters found in the text. Chapters need to be in the format: "Chapter 00". Spacing and case don't matter. Note that "Chapter XIV" and "Chapter Fourteen" will NOT be found and split by this function.

Two optional parameters: num_chapters (int) -- This is in case you wanted to limit it. num_chapters defaults to 100, but the function returns when it can't find any more chapters. include_title defaults to False; Should any text found before the first chapter be included as the first element of the returned list?

Split into parts

authortools.split_into_parts("Part one  Part two  Part three", 3)

Splits text into an array of n equally sized parts. Good for analyzing writing that doesn't have defined chapters; like, split into three parts, and run avg_sentence_word_count on each part to see if your style changed.

Split by size

authortools.split_by_size("Part one  Part two  Part three", 10)

Splits text into an array with each part being of size n.

Letter count

authortools.letter_count("Ten letters!")

Counts the letters (a-z and A-Z) in a given string.

Word count

authortools.word_count("There are five words here.")

Returns the number of words in a given string.

Average word length

authortools.avg_word_length("avg len is 2.5") 

Returns the average word length in a given string.

Percent char in quotes

authortools.percent_char_in_quotes("\"0.35,\" he said.") 

Returns the percent (0.0-1.0) of characters that are in quotes. Quotation marks not counted as characters. Great for analyzing how frequently one uses dialogue.

Reading time

authortools.reading_time("Not much.") 

Returns the reading time in seconds.

Reading time in minutes

authortools.reading_time_minutes("Even less.") 

Returns the reading time in minutes.

Word counts

my_sentences = authortools.sentences("First Sentence.  Second Sentence\nThird Sentence.")
my_word_counts = authortools.word_counts(my_sentences) 

Returns the word counts for multiple items in a list as a list. Sentence word count should vary in good writing!

Word count change

my_sentences = authortools.sentences("First Sentence.  Second Sentence\nThird Sentence.")
my_word_counts = authortools.word_count_change(my_sentences) 

Returns the word counts change (current - previous) for every item in the list as a list. Sentence word count should vary in good writing!

Average sentence word count

authortools.avg_sentence_word_count("Three words here.  Few here, too.  Average is three.") 

Returns the average amount of words per sentence in a given text.

Word repetitions

authortools.word_repetitions("Words; do any words repeat in this sentence made of words?")

Returns an array containing any words that repeat in the given string. It isn't good to repeat yourself in the same sentence, generally speaking. Pair with authortools.sentences and a loop if you want a per-sentence basis, since this function looks for repetitions in the whole string you give it.

Word frequency

authortools.word_frequency("Two times that two appears in this text.")

Returns a dictionary, with the keys being a word, and the value being the amount of times that word appears in the text. Good for seeing which words are frequently used in a peice of writing.

You might also like...
A beautiful and useful prompt for your shell
A beautiful and useful prompt for your shell

A Powerline style prompt for your shell A beautiful and useful prompt generator for Bash, ZSH, Fish, and tcsh: Shows some important details about the

A repository containing useful resources needed to complete the SUSE Scholarship Challenge #UdacitySUSEScholars #poweredbySUSE
A repository containing useful resources needed to complete the SUSE Scholarship Challenge #UdacitySUSEScholars #poweredbySUSE

SUSE-udacity-cloud-native-scholarship A repository containing useful resources needed to complete the SUSE Scholarship Challenge #UdacitySUSEScholars

The purpose of this script is to bypass disablefund, provide some useful information, and dig the hook function of PHP extension.
The purpose of this script is to bypass disablefund, provide some useful information, and dig the hook function of PHP extension.

The purpose of this script is to bypass disablefund, provide some useful information, and dig the hook function of PHP extension.

A project to explore and provide useful code for Mango Markets

🥭 Mango Explorer A project to explore and provide useful code for Mango Markets

Additional useful operations for Python

Pyteal Extensions Additional useful operations for Python Available Operations MulDiv64: calculate m1*m2/d with no overflow on multiplication (TEAL 3+

This repository contains various tools useful for offensive operations (reversing, etc) regarding the PE (Portable Executable) format

PE-Tools This repository contains various tools useful for offensive operations (reversing, etc) regarding the PE (Portable Executable) format Install

A compilation of useful scripts to automate common tasks

Scripts-To-Automate-This A compilation of useful scripts for common tasks Name What it does Type Add file extensions Adds ".png" to a list of file nam

Some Python scripts that fx(hash) users might find useful.

fx_hash_utils Some Python scripts that fx(hash) users might find useful. get_images This script downloads all the static images of the tokens generate

An useful scripts for Misskey

misskey-scripts This place storing useful scripts which made by me. icon-repair Repair broken remote user's icon.

Owner
Sometimes I upload projects and stuff https://gamejolt.com/@codenameaidan
null
A code base for python programs the goal is to integrate all the useful and essential functions

Base Dev EN This GitHub will be available in French and English FR Ce GitHub sera disponible en français et en anglais Author License Screen EN ???? D

Pikatsuto 1 Mar 7, 2022
Collection of functions for working with interlaced content in VapourSynth.

vsfieldkit Collection of functions for working with interlaced content in VapourSynth. It does not have any hard dependencies outside of VapourSynth.

Justin Turner Arthur 11 May 27, 2022
Code and yara rules to detect and analyze Cobalt Strike

Cobalt Strike Resources This repository contains: analyze.py: a script to analyze a Cobalt Strike beacon (python analyze.py BEACON) extract.py; extrac

Tek 224 Jan 4, 2023
Analyze FnO trends by using NSE Bhav copy

BhavFnO Analyze FnO trends by using NSE Bhav copy Download entire BhavFnO folder and unzip it In that folder open command window

null 33 Jan 4, 2023
Set of tools to analyze Tinynuke samples

tinynuke-toolset You'll find in that repository a set of tools and scripts I developped to analyze Tinynuke samples. Dll extractor: script used to ext

Heat Miser 14 Aug 18, 2022
Developed a website to analyze and generate report of students based on the curriculum that represents student’s academic performance.

Developed a website to analyze and generate report of students based on the curriculum that represents student’s academic performance. We have developed the system such that, it will automatically parse data onto the database from excel file, which will in return reduce time consumption of analysis of data.

VIJETA CHAVHAN 3 Nov 8, 2022
Script to quickly get the metrics from Github repos to analyze.

commit-prefix-analysis Script to quickly get the metrics from Github repos to analyze. Setup Install the Github CLI. You'll know its working when runn

David Carpenter 1 Dec 17, 2022
script to analyze EQ decay using python

pyq_decay script to analyze EQ decay using python PyQ Decay ver 1.0 A pythonic script to analyze EQ aftershock decay using method of Omori (1894), Mog

null 1 Nov 4, 2021
Fetch PRs from GitHub and analyze which ones are unmergeable

Set up token Generate a personal access token on GitHub. Add repo permissions. export GH_TOKEN="abcdefg" Pull PR data make Usually, GitHub doesn't h

Stefan van der Walt 1 Nov 5, 2021
Improve current data preprocessing for FTM's WOB data to analyze Shell and Dutch Governmental contacts.

We're the hackathon leftovers, but we are Too Good To Go ;-). A repo by Lukas Schubotz and Raymon van Dinter. We aim to improve current data preprocessing for FTM's WOB data to analyze Shell and Dutch Governmental contacts.

ASReview hackathon for Follow the Money 5 Dec 9, 2021