|
|
1.1 ! root 1: PHOME=${PHOME:-/usr/lib/prefer} ! 2: export PHOME ! 3: $PHOME/prefawk ' ! 4: BEGIN {typestr = "%type"; edstr = "%editor"} ! 5: ! 6: /^%A/ {$1 = "%author"} ! 7: /^%B/ {$1 = "%booktitle"} ! 8: /^%C/ {$1 = "%address"} ! 9: /^%d/ {$1 = "%date"} ! 10: /^%D/ {$1 = "%date"} ! 11: /^%E/ {$1 = "%editor"} ! 12: /^%G/ {$1 = "%government"} ! 13: /^%I/ {$1 = "%publisher"} ! 14: /^%J/ {$1 = "%journal"} ! 15: /^%K/ {$1 = "%keyword"} ! 16: /^%L/ {$1 = "%label"} ! 17: /^%M/ {$1 = "%tm"} ! 18: /^%N/ {$1 = "%number"} ! 19: /^%O/ {$1 = "%other"} ! 20: /^%P/ {$1 = "%pages"} ! 21: /^%r/ {$1 = "%report"} ! 22: /^%R/ {$1 = "%report"} ! 23: /^%T/ {$1 = "%title"} ! 24: /^%V/ {$1 = "%volume"} ! 25: ! 26: /^%/ { ! 27: if(($1 != "%author") && ($1 != "%publisher")) ! 28: print; ! 29: if($1 != "%editor") ! 30: ineditor = 0 ! 31: inref = 1; ! 32: } ! 33: ! 34: $1 == "%author" { ! 35: if ($NF ~ /\([Ee]d.*\)/) { ! 36: edited++; ! 37: $NF = ""; ! 38: } ! 39: print; ! 40: } ! 41: ! 42: $1 == "%publisher" { ! 43: publisher++ ; ! 44: if($2 == "PhD") { ! 45: phd++; ! 46: printf "%s", $1; ! 47: for (i=4; i <= NF; i++) ! 48: printf " %s", $i; ! 49: print ""; ! 50: } ! 51: else if($2 ~ /Master*/) { ! 52: masters++; ! 53: printf "%s",$1; ! 54: for (i=4; i <= NF; i++) ! 55: printf " %s", $i; ! 56: print ""; ! 57: } ! 58: else print; ! 59: } ! 60: ! 61: $1 == "%editor" { editor++; ineditor = 1;} ! 62: $1 == "%author" { author++ } ! 63: $1 == "%journal" { journal++ } ! 64: $1 == "%tm" { tm++ } ! 65: $1 == "%report" { report++ } ! 66: $1 == "%booktitle" { booktitle++ } ! 67: /[Pp]roc/ || /[Cc]onf/ { if ($1 == "%journal") inproceedings++;} ! 68: ! 69: /^[^%]/ { # handle multiple editors ! 70: if(ineditor) { ! 71: printf "%s ", edstr; ! 72: if($1 == "and") ! 73: print substr($0,length($1)+2); ! 74: else ! 75: print; ! 76: } ! 77: else print; # handle other multiple lines (like %Z) ! 78: } ! 79: # blank line, so now infer document type ! 80: /^$/ { ! 81: if(inref) infer(); ! 82: } ! 83: ! 84: ! 85: func infer() ! 86: { ! 87: printf "%s ", typestr; ! 88: if(edited) print "editedbook"; ! 89: else if(masters) print "mastersthesis"; ! 90: else if(phd) print "phdthesis"; ! 91: else if(inproceedings) print "inproceedings"; ! 92: else if(journal) print "article"; ! 93: else if(booktitle) print "incollection"; ! 94: else if(tm) print "tm"; ! 95: else if(report) print "techreport"; ! 96: else if(publisher) print "book"; ! 97: else print "misc"; ! 98: print; ! 99: ! 100: inref = 0; ! 101: editor = 0; ! 102: author = 0; ! 103: journal = 0; ! 104: inproceedings = 0; ! 105: booktitle = 0; ! 106: publisher = 0; ! 107: tm = 0; ! 108: report = 0; ! 109: book = 0; ! 110: tflag = 0; ! 111: ineditor = 0; ! 112: phd = 0; ! 113: masters = 0; ! 114: edited = 0; ! 115: } ! 116: ! 117: END { ! 118: if(inref) infer(); ! 119: } ! 120: ' $1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.