|
Revision 1, 0.5 kB
(checked in by mjoc, 2 years ago)
|
Initial import.
|
| Line | |
|---|
| 1 |
#!/usr/bin/env python |
|---|
| 2 |
|
|---|
| 3 |
# MakeHash |
|---|
| 4 |
# Utility for dictionary hash table making |
|---|
| 5 |
# mjoc, 2003 |
|---|
| 6 |
|
|---|
| 7 |
import sys |
|---|
| 8 |
|
|---|
| 9 |
if len(sys.argv) < 3: |
|---|
| 10 |
print "Usage: %s <dict_file> <hash_file>" % sys.argv[0] |
|---|
| 11 |
sys.exit(1) |
|---|
| 12 |
|
|---|
| 13 |
dict = open(sys.argv[1], "r") |
|---|
| 14 |
hash = open(sys.argv[2], "w") |
|---|
| 15 |
|
|---|
| 16 |
line = dict.readline() |
|---|
| 17 |
l = line[0].lower() |
|---|
| 18 |
n = 0 |
|---|
| 19 |
|
|---|
| 20 |
hash.write(l+" "+repr(n)+"\n") |
|---|
| 21 |
n += len(line) |
|---|
| 22 |
|
|---|
| 23 |
for line in dict.readlines(): |
|---|
| 24 |
if line[0].lower() != l: |
|---|
| 25 |
l = line[0] |
|---|
| 26 |
hash.write(l+" "+repr(n)+"\n") |
|---|
| 27 |
n += len(line) |
|---|
| 28 |
|
|---|
| 29 |
dict.close() |
|---|
| 30 |
hash.close() |
|---|