Skip to content

Commit

Permalink
Maintenance updated 2021 08 (#27)
Browse files Browse the repository at this point in the history
* standard workflows

* moved code to src

* added markdownlint config

* converted readme to markdown

* formatted with black

* updated build files

* removed 2.x from testing

* added install_requires

* v1.3.2
  • Loading branch information
davidlday authored Aug 28, 2021
1 parent 03576df commit 898c478
Show file tree
Hide file tree
Showing 24 changed files with 271 additions and 260 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
Expand All @@ -10,21 +7,23 @@ on:
jobs:
deploy:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
pip install setuptools wheel twine build
- name: Build Dists
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/pypi-test-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test Upload Python Package

on:
push:
tags:
- "v*"

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
- name: Build Dists
run: |
python -m build
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
48 changes: 40 additions & 8 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,62 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python CI

on: [push, pull_request]

jobs:
build:
lint:
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v2
with:
submodules: true
- name: Black
uses: psf/black@stable
- name: Pylint
uses: cclauss/[email protected]
with:
args: pip install .; pylint src/**/*.py

test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.8, 3.9]

python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install --upgrade pip
python -m pip install --upgrade pip
- name: Install module
run: |
python ./setup.py develop
pip install -e .
- name: Test with pytest
run: |
pip install pytest
pytest
check_build:
runs-on: ubuntu-latest
steps:
- name: Check Out
uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine build
- name: Build
run: python -m build
- name: Check
run: twine check dist/*
48 changes: 0 additions & 48 deletions .github/workflows/python-lint.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MD034: false # no-bare-urls: Bare URL used
MD024: false # no-duplicate-heading/no-duplicate-header: Multiple headings with the same content
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include MANIFEST.in
include README.rst
include README.md
include LICENSE
graft prosegrinder
graft src
graft tests
global-exclude .git
global-exclude __pycache__
Expand Down
129 changes: 129 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
# Prosegrinder

[![Latest PyPI version](https://img.shields.io/pypi/v/prosegrinder.svg)](https://pypi.python.org/pypi/prosegrinder)
[![GitHub Workflow Status](https://github.com/prosegrinder/python-prosegrinder/workflows/Python%20CI/badge.svg?branch=main)](https://github.com/prosegrinder/python-prosegrinder/actions?query=workflow%3A%22Python+CI%22+branch%3Amain)

A relatively fast, functional prose text counter with readability scoring.

## Installation

`prosegrinder` is available on PyPI. Simply install it with `pip`:

```bash
pip install prosegrinder
```

## Usage

The main use is via the `prosegrinder.Prose` object.

```python
>>> from prosegrinder import Prose
>>> p = Prose("Some lengthy text that's actual prose, like a novel or article.")
```

The Prose object will parse everything down and compute basic statistics,
including word count, sentence count, paragraph count, syllable count, point of
view, dialogue, narrative, and a set of readability scores. All objects and
attributes should be treated as immutable.

I know this isn't great documentation, but it should be enough to get you going.

### Command Line Interface

Prosegrinder now includes a simple CLI for analyzing text in a file:

```bash
$ prosegrinder --help
Usage: prosegrinder [OPTIONS] FILES...

Setup the command line interface

Options:
-i, --indent INTEGER Python pretty-print json indent level.
-s, --save FILENAME File to save output to.
--help Show this message and exit.
```

Will provide basic statistics on text from a file or set of files including the
filename and sh256 of text in each file analyzed. Output is json to help
facilitate use in automation::

```json
[
{
"filename": "shortstory.txt",
"statistics": {
"sha256": "5b756dea7c7f0088ff3692e402466af7f4fc493fa357c1ae959fa4493943fc03",
"word_character_count": 7008,
"phone_count": 5747,
"syllable_count": 2287,
"word_count": 1528,
"sentence_count": 90,
"paragraph_count": 77,
"complex_word_count": 202,
"long_word_count": 275,
"pov_word_count": 113,
"first_person_word_count": 8,
"second_person_word_count": 74,
"third_person_word_count": 31,
"pov": "first",
"readability_scores": {
"automated_readability_index": 0.281,
"coleman_liau_index": 9.425,
"flesch_kincaid_grade_level": 8.693,
"flesch_reading_ease": 62.979,
"gunning_fog_index": 12.079,
"linsear_write": 10.733,
"lix": 34.975,
"rix": 3.056,
"smog": 11.688
}
}
},
{
"filename": "copyright.txt",
"statistics": {
"sha256": "553bfd087a2736e4bbe2f312e3d3a5b763fb57caa54e3626da03b0fd3f42e017",
"word_character_count": 222,
"phone_count": 169,
"syllable_count": 78,
"word_count": 46,
"sentence_count": 7,
"paragraph_count": 16,
"complex_word_count": 10,
"long_word_count": 12,
"pov_word_count": 1,
"first_person_word_count": 1,
"second_person_word_count": 0,
"third_person_word_count": 0,
"pov": "first",
"readability_scores": {
"automated_readability_index": 1.404,
"coleman_liau_index": 8.073,
"flesch_kincaid_grade_level": 6.982,
"flesch_reading_ease": 56.713,
"gunning_fog_index": 11.324,
"linsear_write": 3.714,
"lix": 32.658,
"rix": 1.714,
"smog": 9.957
}
}
}
]
```

### Readability scores

The set of scores automatically calculated:

- Automated Readability Index
- Coleman Liau Index
- Flesch Kincaid Grade Level
- Flesch Reading Ease
- Gunning Fog Index
- Linsear Write
- LIX
- RIX
- SMOG
Loading

0 comments on commit 898c478

Please sign in to comment.