summaryrefslogtreecommitdiffstats
path: root/src/cmd/dict/canonind.awk
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2003-11-25 03:37:45 +0000
committerrsc <devnull@localhost>2003-11-25 03:37:45 +0000
commit08708877939323c1e1cb87210193ec25fc472ff7 (patch)
treebd34e2144a3e9532ab228619d7ae8d4a0078aeeb /src/cmd/dict/canonind.awk
parent091f74d0a0db5ba1e098a518922525cb032a97b4 (diff)
downloadplan9port-08708877939323c1e1cb87210193ec25fc472ff7.tar.gz
plan9port-08708877939323c1e1cb87210193ec25fc472ff7.zip
add dict
Diffstat (limited to 'src/cmd/dict/canonind.awk')
-rw-r--r--src/cmd/dict/canonind.awk29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/cmd/dict/canonind.awk b/src/cmd/dict/canonind.awk
new file mode 100644
index 00000000..41c6ee75
--- /dev/null
+++ b/src/cmd/dict/canonind.awk
@@ -0,0 +1,29 @@
+# turn output of mkindex into form needed by dict
+BEGIN {
+ if(ARGC != 2) {
+ print "Usage: awk -F' ' -f canonind.awk rawindex > index"
+ exit 1
+ }
+ file = ARGV[1]
+ ARGV[1] = ""
+ while ((getline < file) > 0) {
+ for(i = 2; i <= NF; i++) {
+ w = $i
+ if(length(w) == 0)
+ continue
+ b = index(w, "(")
+ e = index(w, ")")
+ if(b && e && b < e) {
+ w1 = substr(w, 1, b-1)
+ w2 = substr(w, b+1, e-b-1)
+ w3 = substr(w, e+1)
+ printf "%s%s\t%d\n", w1, w3, $1 > "junk"
+ printf "%s%s%s\t%d\n", w1, w2, w3, $1 > "junk"
+ } else
+ printf "%s\t%d\n", w, $1 > "junk"
+ }
+ }
+ system("sort -u -t' ' +0f -1 +0 -1 +1n -2 < junk")
+ system("rm junk")
+ exit 0
+}