Skip to content

Instantly share code, notes, and snippets.

@XChrisUnknownX
Last active July 6, 2019 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XChrisUnknownX/78ba099871c9062c254e04d8a5d2673d to your computer and use it in GitHub Desktop.
Save XChrisUnknownX/78ba099871c9062c254e04d8a5d2673d to your computer and use it in GitHub Desktop.
This program marks .txt transcripts for timed dictation/reading/practice. Must have Python 3 to use. Must keep in the same folder as the .txt you wish to mark.
import time
import sys
import random
version = "1.1"
versiondescription = "I fixed the thing so it stops counting Q. and A. as a word."
print("Note: Timings are not exact. Transcript is marked at the 15 second reading interval.")
textname = input("Name of text file you wish to open. ")
wordspermin = input("Mark X words per minute. Input X. ")
symbol = input("Input marking symbol. ")
try:
wordsperminint = int(wordspermin)
wordspersecond = (wordsperminint/60)
roundedwordspersecond = round(wordspersecond)
roundedwordspersecondint = int(roundedwordspersecond)
if roundedwordspersecondint <= 0:
roundedwordspersecondint = 1
else:
pass
wordsper15seconds = roundedwordspersecondint*15
wordsper15seconds = int(round(wordsperminint/4))
if wordsper15seconds <= 0:
wordsper15seconds = 1
else:
pass
except:
input("Words per minute must be a number. Program will now terminate.")
sys.exit()
# Thanks to kyber I was able to make better logic.
trigger = wordsper15seconds
with open(textname,"r") as markfile, open("MarkedTranscript.txt","x") as newfile3:
wordscount = 0
for line in markfile:
words = line.split()
words_num = len(words)
new_line = ""
for idx, word in enumerate(words, start=1):
wordscount += 1
if word == "Q.":
wordscount -= 1
elif word == "A.":
wordscount -= 1
elif word == "COURT:":
wordscount -= 1
elif word == "WITNESS:":
wordscount -= 1
if wordscount == trigger:
new_line += symbol
wordscount = 0
new_line += word + (" " if idx < words_num else "")
newfile3.write(new_line + '\n')
import time
import sys
import random
version = "1"
print("Note: Timings are not exact. Transcript is marked at the 15 second reading interval.")
textname = input("Name of text file you wish to open. ")
wordspermin = input("Mark X words per minute. Input X. ")
symbol = input("Input marking symbol. ")
try:
wordsperminint = int(wordspermin)
wordspersecond = (wordsperminint/60)
roundedwordspersecond = round(wordspersecond)
roundedwordspersecondint = int(roundedwordspersecond)
if roundedwordspersecondint <= 0:
roundedwordspersecondint = 1
else:
pass
wordsper15seconds = roundedwordspersecondint*15
wordsper15seconds = int(round(wordsperminint/4))
if wordsper15seconds <= 0:
wordsper15seconds = 1
else:
pass
except:
input("Words per minute must be a number. Program will now terminate.")
sys.exit()
# Thanks to kyber I was able to make better logic.
trigger = wordsper15seconds
with open(textname,"r") as markfile, open("MarkedTranscript.txt","x") as newfile3:
wordscount = 0
for line in markfile:
words = line.split()
words_num = len(words)
new_line = ""
for idx, word in enumerate(words, start=1):
wordscount += 1
if wordscount == trigger:
new_line += symbol
wordscount = 0
new_line += word + (" " if idx < words_num else "")
newfile3.write(new_line + '\n')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment