A small Python package for splitting text into dialogue and narrative.
Project description
A small Python package for splitting text into dialogue and narrative.
Installation
narrative is available on PyPI. Simply install it with pip:
$ pip install narrative
You can also install it from source:
$ git clone https://github.com/prosegrinder/python-narrative.git Cloning into 'python-narrative'... ... $ cd python-narrative $ python setup.py install ...
Usage
narrative splits a piece of prose into narrative and dialogue components. The main function split() will return a dict containing both narrative and dialogue components:
>>> import narrative >>> text = '"Hello," he said. "How are you today?"' >>> narrative.split(text) {'dialogue': ['"Hello,"', '"How are you today?"'], 'narrative': ['', ' he said. ', '']}
There are two other helper functions as well.
get_dialogue() returns only the dialogue components:
>>> narrative.get_dialogue(text) ['"Hello,"', '"How are you today?"']
get_narrative() returns only the narrative components:
>>> narrative.get_dialogue(text) ['', ' he said. ', '']
Note: The empty strings are a feature of Python’s split() function. See Why are empty strings returned in split() results? for an explanation.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for narrative-1.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4530132fa8599eb9f651367bc369d643bbeb7967bb7bfddc0c52b1ad50b9ad6 |
|
MD5 | 7b4c39214167ecd15641cfe2428d7f09 |
|
BLAKE2b-256 | e04b22cc3adbce0553f6fa86d5ea64d6c3be89c5167457a564d693ded2d5e5e1 |