dict-moby-thesaurus (1.0-6.2) conv.py

Summary

 conv.py |   35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

    
download this patch

Patch contents

--- dict-moby-thesaurus-1.0.orig/conv.py
+++ dict-moby-thesaurus-1.0/conv.py
@@ -0,0 +1,35 @@
+import sys, dictdlib
+
+# Conversion script by John Goerzen
+
+itextfile = open("introduction.txt", "rt")
+
+
+dw = dictdlib.DictWriter("moby-thesaurus",
+                         'http://www.ibiblio.org/pub/docs/books/gutenberg/etext02/mthes10.zip',
+                         'Moby Thesaurus II by Grady Ward, 1.0',
+                         itextfile.read(-1))
+
+while 1:
+    line = sys.stdin.readline()
+    if not line:
+        break
+    line.strip()
+    base, d = line.split(',', 1)
+    defstr = ""
+    defline = "   "
+    count = 0
+    for defword in d.split(','):
+        count += 1
+        if len(defline) + len(defword) + 3 > 70:
+            defstr += defline + "," + "\n"
+            defline = "   " + defword
+        elif defline == "   ":
+            defline += defword
+        else:
+            defline += ", " + defword
+    if defline != "   ":
+        defstr += defline + "\n"
+    dw.writeentry("%s Moby Thesaurus words for \"%s\":\n" % (count, base) + \
+                  defstr, [base])
+dw.finish()