Created
July 8, 2019 12:22
-
-
Save timothy-allan/350ae03eb0d1464e8402375850e31050 to your computer and use it in GitHub Desktop.
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 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Sat Jul 6 14:33:28 2019 | |
@author: timallan | |
""" | |
import random | |
origFile = open('/Users/timallan/Desktop/whiteFang/03_inDESIGN/_TXT/WhiteFangOriginal.txt', 'r') | |
saveFile = open('/Users/timallan/Desktop/whiteFang/03_inDESIGN/_TXT/wF_06.txt', 'w') | |
origLines = origFile.readlines() | |
origLineCount = len(origLines) | |
origWordCount = 0 | |
cutLine = [] | |
cutLines = [] | |
for aLine in origLines: | |
origWordCount += len(aLine) | |
for aLine in origLines: | |
singleLine = aLine.split() | |
origLineLen = len(singleLine) | |
targetLineLen = int(origLineLen * 0.41) | |
while origLineLen > targetLineLen: | |
randNum = random.randrange(0, origLineLen) | |
singleLine.pop(randNum) | |
origLineLen -= 1 | |
cutString = ' '.join(singleLine) | |
cutLines.append(cutString) | |
cutFinalString = '\n'.join(cutLines) | |
print(cutFinalString) | |
saveFile.write(cutFinalString) | |
origFile.close() | |
saveFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment