Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge prosedecomposer functionality (#26)
* added prosedecomposer functionality * fixed textprocessingtestcase * fixed unit tests * added Sphinx docs
- Loading branch information
1 parent
25cee0c
commit 81a5323
Showing
14 changed files
with
291 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = source | ||
BUILDDIR = build | ||
|
||
# Put it first so that "make" without argument is like "make help". | ||
help: | ||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) | ||
|
||
.PHONY: help Makefile | ||
|
||
# Catch-all target: route all unknown targets to Sphinx using the new | ||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). | ||
%: Makefile | ||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=source | ||
set BUILDDIR=build | ||
|
||
if "%1" == "" goto help | ||
|
||
%SPHINXBUILD% >NUL 2>NUL | ||
if errorlevel 9009 ( | ||
echo. | ||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx | ||
echo.installed, then set the SPHINXBUILD environment variable to point | ||
echo.to the full path of the 'sphinx-build' executable. Alternatively you | ||
echo.may add the Sphinx directory to PATH. | ||
echo. | ||
echo.If you don't have Sphinx installed, grab it from | ||
echo.http://sphinx-doc.org/ | ||
exit /b 1 | ||
) | ||
|
||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Generative Lexicon (lexigen.py) | ||
=============================== | ||
|
||
| | ||
These functions allow for controlled random sampling of words from Project Datamuse's API. | ||
|
||
.. automodule:: generativepoetry.lexigen | ||
:members: | ||
|
21 changes: 21 additions & 0 deletions
21
docs/source/Poem Text Generation (poemgen.py, jolastic.py).rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Poem Text Generation (poemgen.py, jolastic.py) | ||
============================================== | ||
|
||
| | ||
These functions generate the actual text of poems. | ||
|
||
.. automodule:: generativepoetry.poemgen | ||
:members: | ||
|
||
.. autoclass:: generativepoetry.poemgen.Poem | ||
:members | ||
|
||
.. autoclass:: generativepoetry.poemgen.PoemGenerator | ||
:members | ||
|
||
.. automodule:: generativepoetry.jolastic | ||
:members: | ||
|
||
.. autoclass:: generativepoetry.jolastic.StochasticJolasticWordGenerator | ||
:members |
16 changes: 16 additions & 0 deletions
16
docs/source/Sampling and Text Processing from Online Libraries (decompser.py).rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Sampling and Text Processing from Online Libraries (decompser.py) | ||
================================================================= | ||
|
||
| | ||
With the decomposer module, one can sample random documents (books, etc.) from Project Gutenberg and Archive.org and rearrange the texts using Markov chain algorithms, cut-up, or by swapping instances of a part of speech between two texts. | ||
|
||
.. automodule:: generativepoetry.decomposer | ||
:members: | ||
|
||
| | ||
The ParsedText class has several methods for random sampling. | ||
|
||
.. autoclass:: generativepoetry.decomposer.ParsedText | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Utilities | ||
========= | ||
|
||
| | ||
These functions are common utilities used by other modules. | ||
|
||
.. automodule:: generativepoetry.utils | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Visual Poem (PDF,PNG) Generation (pdf.py) | ||
========================================= | ||
|
||
| | ||
These functions allow for the creation of all currently supported types of visual poems. | ||
|
||
.. automodule:: generativepoetry.pdf | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- Path setup -------------------------------------------------------------- | ||
|
||
# If extensions (or modules to document with autodoc) are in another directory, | ||
# add these directories to sys.path here. If the directory is relative to the | ||
# documentation root, use os.path.abspath to make it absolute, like shown here. | ||
# | ||
import os | ||
import sys | ||
sys.path.insert(0, os.path.abspath('../..')) | ||
|
||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = 'Generative Poetry' | ||
copyright = '2020, Corey Bobco' | ||
author = 'Corey Bobco' | ||
|
||
# The full version, including alpha/beta/rc tags | ||
release = '0.3.0' | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = ['sphinx.ext.autodoc'] | ||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ['_templates'] | ||
|
||
# List of patterns, relative to source directory, that match files and | ||
# directories to ignore when looking for source files. | ||
# This pattern also affects html_static_path and html_extra_path. | ||
exclude_patterns = [] | ||
|
||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
html_theme = 'alabaster' | ||
|
||
# Add any paths that contain custom static files (such as style sheets) here, | ||
# relative to this directory. They are copied after the builtin static files, | ||
# so a file named "default.css" will overwrite the builtin "default.css". | ||
html_static_path = ['_static'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
Welcome to Generative Poetry's documentation! | ||
============================================= | ||
|
||
Table of Contents | ||
----------------- | ||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
Generative Lexicon (lexigen.py) | ||
Visual Poem (PDF, PNG) Generation (pdf.py) | ||
Poem Text Generation (poemgen.py, jolastic.py) | ||
Sampling and Text Processing from Online Libraries (decompser.py) | ||
Utilities | ||
|
||
|
||
Try now | ||
^^^^^^^ | ||
|
||
Colab (recommended for most) | ||
"""""""""""""""""""""""""""" | ||
You can install this software and launch the interactive menu for creating visual poems from the following `link <https://colab.research.google.com/drive/1eNTBSLMPpemYQq4n3keKCjVpw_JqY6w->`_ to a Jupyter notebook hosted on Google Colab. | ||
|
||
Note: this will only work on desktop and tablet effectively because of screen-size issues. Keep the `Github notes on usage <https://github.com/coreybobco/generativepoetry-py/>`_ open to consult for reference. | ||
|
||
Installing On Your Computer | ||
""""""""""""""""""""""""""" | ||
|
||
Alternatively, if you install this on your own machine (see below), you can initalize the interactive menu by running the following command from a terminal/shell: generative-poetry-cli | ||
|
||
Windows | ||
""""""" | ||
|
||
Because this library currently relies on the Python package hunspell, which does not support Windows, use Docker to launch a Linux-based container, then use pip to install, and enter the Python interactive shell within: | ||
|
||
.. code-block:: | ||
docker run -t -d python python3 -m pip install generativepoetry && python3 | ||
OSX | ||
""" | ||
|
||
OSX users must install hunspell beforehand: | ||
|
||
.. code-block:: | ||
brew install hunspell | ||
Then download the en_US dictionary from http://wordlist.aspell.net/dicts/ and unzip it to /Library/Spelling/ and install using pip: | ||
|
||
.. code-block:: | ||
python3 -m pip install generativepoetry | ||
You will also need Microsoft's core font TTF files in /Library/Fonts/. | ||
|
||
Linux | ||
""""" | ||
|
||
Ubuntu/Debian users should install hunspell-en-us, libhunspell-dev, and libdb++-dev beforehand and then install with pip: | ||
|
||
.. code-block:: | ||
sudo apt-get install hunspell-en-us libhunspell-dev libdb++-dev | ||
python3 -m pip install generativepoetry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.