Appendix talk:Moby Thesaurus II
Latest comment: 1 year ago by Dan Polansky in topic Script
Script
editScript to create files to upload to wiki, from mthesaur.txt:
from __future__ import print_function
import re, sys
outFile = None
blockSize=310
counter=0
fileCounter=1
outFile = open("mthesaur_%03d.txt" % fileCounter, "w")
for line in open("mthesaur.txt"):
counter += 1
first = re.sub(r",.*", "", line.rstrip())
firstLetter = first[0].lower()
if counter > blockSize:
outFile.close()
fileCounter+=1
outFile = open("mthesaur_%03d.txt" % fileCounter, "w")
counter = 0
print("==" + first + "==", file=outFile)
line = re.sub(r"([ a-zA-Z0-9-]*)", r"[[\1]]", line.rstrip())
line = re.sub(",", ", ", line)
line = re.sub("^", "* ", line)
print(line, file=outFile)
print("", file=outFile)