Last active
December 3, 2019 04:44
-
-
Save mark-ingenosity/5f3a081643a11e26aad34c084ace41e1 to your computer and use it in GitHub Desktop.
[WRITING: Python: Extract Dialog from Story Text] Strips all text not enclosed in double quotes leaving only dialog text (ex. "Some dialog text..."). #dialog #book #story #scrubbing
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| # | |
| # text2dialog.py | |
| # Python script to strip dialog from story text, discarding all other narrative text. | |
| # Uses open-close double quotes as delimeters. | |
| # | |
| import re, sys | |
| with open(sys.argv[1]) as f: | |
| reg = re.compile(r'"[^"]*"|\([^)]*\)') | |
| for line in f: | |
| print(' '.join(reg.findall(line))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment