Polish sed Script.


Polish
is a suite of sed files for "polishing" text files before they are processed with the troff text-formatting tools. The suite was written by Robert Marks (bobm@agsm.edu.au) over a period of months for use with the production of the Australian Journal of Management. Even he is not quite sure of all things the suite does: the simplest way to see is to split the following file into the ten sed files, and pipe a text file through ten sed processes, before comparing the final text file with the original. I welcome any comments, at my email address.

#polish.sedf0: endline, endsentence, %, vis-a-vis, em dash, EQ, C.A.P.S.
/^\.\\"/!{
s/[ 	][ 	]*$//
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
	s/" " /"" /g
/^\.EQ/,/^\.EN/!{
	/^\.TS/,/^\.TE/!{
	/^\.nf/,/^\.fi/!{
		/^[^.]/{
			/[.?!]..*[A-Z]/{
			s/\.   *\([\A-Z]\)/.\
\1/g
			s/\.)   *\([\A-Z]\)/.)\
\1/g
			s/\([?!]\)  *\([\A-Z]\)/\1\
\2/g
			s/\([.?!]\)  *\([[(]\)\([\A-Z]\)/\1\
\2\3/g
			s/\([^ds]\)\.)  *\([\A-Z]\)/\1.)~\
\2/g
			s/\([^ds]\)\."  *\([\A-Z]\)/\1.\\(rq~\
\2/g
			s/\([^ds]\)\.]  *\([\A-Z]\)/\1.]~\
\2/g
			s/)\. \([A-Z]\)/).\
\1/g
			}
			/ -$/{
				N
				s/ -\n/\\(em/
			}
			/[0-9]/{
			/\([0-9]\) per$/{
				N
				s/ per\ncent/%/
			}
			/\([0-9]\)$/{
				N
				s/\nper cent/%/
				s/\npercent\([^ai]\)/%\1/
			}
			}
		}
	}
	/^\.H [123]/{
		n
		/^\.P$/d
		}
	/^[^.]/{
		s/\([A-Z]\)\.\([A-Z]\)/\1.\\^\2/g
		s/\([A-Z]\)\.\([A-Z]\)/\1.\\^\2/g
	}
	/[`!$]/!{
		/^\.nf/,/^\.fi/!{
		/^[^ ][^ ]*  /!{
			/^[^.]/s/\([^sf+][^?;:]\)  /\1 /g
		}
		}
	}
	}
	/[`!$]/!{
		/^[^.]/{
			/-/{
			s/ - /\\(em/g
			s/\([0-9]\)- \([a-zA-Z]\)/\1\- \2/g
			}
		}
	}
	/^[^.']/{
		s/percent\([^ai]\)/per cent\1/g
		/[0-9]c/{
		s/\([0-9]\)c /\1\\(ct /g
		s/\([0-9]\)c$/\1\\(ct/
		}
		/--./{
		s/ -- /\\(em/g
		s/--\(.\)/\\(em\1/g
		}
	}
	/^\.nf/,/^\.fi/!{
		/^[^.]/{
			/vis/{
			/ vis a$/{
				N
				s/ a\nvis/-\\o'a\\(ga'-vis/
			}
			/ vis$/{
				N
				s/\na vis/-\\o'a\\(ga'-vis/
			}
			}
			/--$/{
			/ --$/{
				N
				s/ --\n/\\(em/
			}
			/[a-zA-Z0-9]--$/{
				N
				s/--\n/\\(em/
			}
			}
		}
	}
}
}
}
}
#polish.sedf1: EQ, 0. , %, -0. , digraphs, spelling, \-, USA/UK, (abc), 1987a, \f2n\fP
/^\.\\"/!{
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/^\.EQ/,/^\.EN/!{
	/^[^.]/{
		/[0-9]/{
		s/\([0-9]\) percent\([^ai]\)/\1\%\2/g
		s/\([0-9]\) percent$/\1\%/
		s/\([0-9]\) per cent/\1%/g
		s/\([ ^	`"/(~#i]\)\.\([0-9]\)/\10.\2/g
		s/^\.\([0-9][^a-zA-Z]\)/0.\1/
		s/\([ ^	`"/(~#]\)-\.\([0-9]\)/\1\\-0.\2/g
		s/^-\.\([0-9]\)/\\-0.\1/
		s/\(1[89][0-9][0-9]\)\([abcdef]\)/\1\\f2\2\\fP/g
		}
		s/\([Cc]\)ooperat/\1o\\o'o\\(..'perat/g
		s/\([Cc]\)oordinat/\1o\\o'o\\(..'rdinat/g
		s/\([Cc]\)o-o\([rp][a-z]\)/\1o\\o'o\\(..'\2/g
		s/^\([Rr]\)ole/\1\\o'o^'le/
		s/\([- '/q`"(]\)\([Rr]\)ole/\1\2\\o'o^'le/g
		s/\([Nn]\)aive/\1a\\o'\\(ui\\(..'ve/g
		s/vis[ -]a[ -]vis/vis-\\o'a\\(ga'-vis/g
		s/^\([Rr]\)esume/\1\\o'e\\(aa'sum\\o'e\\(aa'/
		s/\([ -'/q`"(]\)\([Rr]\)esume/\1\2\\o'e\\(aa'sum\\o'e\\(aa'/g
		s/\([Ff]\)acade/\1a\\o'c\\(cd'ade/g
		s/\([Ff]\)ocuss/\1ocus/g
		s/\([Nn]\)onetheless/\1one the less/g
		s/d'etre/d'\\o'e^'tre/g
		/oe/{
		s/^oe\([a-z][a-z]\)/\\(oe\1/
		s/\([ -'/q`"(]\)oe\([a-z][a-z]\)/\1\\(oe\2/g
		s/oeuvre/\\(oeuvre/g
		}
		/[Aa]e/{
		s/\([a-z][a-z]\)ae\([ \.,;:)]\)/\1\\(ae\2/g
		s/^ae\([cdgoqst][a-z]\)/\\(ae\1/
		s/\([ -'/q`"(]\)ae\([cdgoqst][a-z]\)/\1\\(ae\2/g
		s/aesth/\\(aesth/g
		s/Ae\([aglnostcdq][a-z]\)/\\(AE\1/g
		}
		s/medieval/medi\\(aeval/g
		s/(cf /(see /g
		s/(c\.f\. /(see /g
		s/\([Ii]\)bid\([^e.]\)/\1bid.\\\&\2/g
		/U[SK]/{
		s/^U\([SK]\) /U.\1.\\\& /
		s/^U\([SK]\)\.$/U.\1./
		s/\([ (]\)U\([SK]\) /\1U.\2.\\\& /g
		s/\([ (]\)U\([SK]\)$/\1U.\2.\\\&/
		s/\([ (]\)U\([SK]\)\.$/\1U.\2./
		s/\([ (]\)U\([SK]\)\([,;:)]\)/\1U.\2.\3/g
		s/^USA /U.S.A.\\\& /
		s/^USA\.$/U.S.A./
		s/\([ (]\)USA /\1U.S.A.\\\& /g
		s/\([ (]\)USA$/\1U.S.A.\\\&/
		s/\([ (]\)USA\.$/\1U.S.A./
		s/\([ (]\)USA\([,;:)]\)/\1U.S.A.\2/g
		}
		/([abcdefgh])/{
		s/^(\([abcdefgh]\))/(\\f2\1\\fP)/
		s/\([ 	]\)(\([abcdefgh]\))\([ 	]\)/\1(\\f2\2\\fP)\3/g
		s/\([ 	]\)(\([abcdefgh]\))\([ 	]\)/\1(\\f2\2\\fP)\3/g
		s/\([ 	]\)(\([abcdefgh]\))$/\1(\\f2\2\\fP)/
		}
	}
	/[`!$]/!{
	/^\.nf/,/^\.fi/!{
		/^[^.]/{
			s/: \([`"([\\0-9a-zA-Z]\)/:  \1/g
			/^[^ ][^ ]*[:;?][~#][^~#]/!s/:[~#]\([`"([\\0-9a-zA-Z]\)/:  \1/g
			/^[^ ][^ ]*[:;?]\([^ ]\)\1/!s/\([:;?]\)\([^ ]\)\2\([`"([\\0-9a-zA-Z]\)/\1  \3/g
			/^[^ ][^ ]*;[~#]/!s/;[#~]\([`"([\\0-9a-zA-Z]\)/; \1/g
		}
	}
		/^[^.]/{
			/[0-9]/{
			/-/{
			s/\([ ^	`"/(]\)-\([0-9]\)/\1\\-\2/g
			s/\([0-9]\)-\([0-9]\)/\1\\-\2/g
			s/\([0-9])\)-\(([0-9]\)/\1\\-\2/g
			s/\([0-9]\)-\$\([0-9.]\)/\1\\-$\2/g
			s/\([0-9]\) - \([0-9]\)/\1 \\- \2/g
			s/\([0-9]\)- /\1\\- /g
			}
			}
		}
		/^\.TS/,/^\.TE/!{
		/^\.nf/,/^\.fi/!{
			/^[^.]/{
				s/\.   *\([\A-Z]\)/.\
\1/g
			}
		}
			/^[^.]/{
				s/^\([bcdefghijklmnpqrstuvwxyzBCDEFGHJKLMNPQRSTUVWXYZ]\)\([ ']\)/\\f2\1\\fP\2/
				s/ \([bcdefghijklmnpqrstuvwxyzBCDEFGHJKLMNPQRSTUVWXYZ]\)$/ \\f2\1\\fP/
				s/\([ (]\)\([bcdefghijklmnpqrstuvwxyzBCDEFGHJKLMNPQRSTUVWXYZ]\)\([ ']\)/\1\\f2\2\\fP\3/g
				s/ \([bcdefghijklmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]\)\([;:,)^	]\) / \\f2\1\\fP\2 /g
				s/ \([bcdefghijklmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]\)\.$/ \\f2\1\\fP./
				s/ \([bcdefghijklmnpqrstuvwxyzBCDEFGHJKLMNPQRSTUVWXYZ]\) / \\f2\1\\fP /g
				s/ \([bcdefghijklmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]\)\([;:,^	]\) / \\f2\1\\fP\2 /g
				s/ \([bcdefghijklmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ]\)\.$/ \\f2\1\\fP./
				s/\([^A-Zx:;,. ] \)A\([ ']\)/\1\\f2A\\fP\2/g
				s/ A)/ \\f2A\\fP)/g
			}
		}
	}
}
}
}
}
#polish.sedf2: tbl! : l!=1, Section, .)~ , [a-z]-, [0-9]-, [a-z].
/^\.\\"/!{
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/^\.EQ/,/^\.EN/!{
	/^\.TS/,/^\.TE/!{
		/[0-9]/{
		s/l\([0-9]\)/1\1/g
		s/\([^+-sf][0-9]\)l/\11/g
		}
	/^\.nf/,/^\.fi/!{
		/^[^.]/{
			/section/{
			/[^-]section$/{
				N
				s/section\n\([0-9]\)/Section \1/
				}
			/[^-]sections$/{
				N
				s/sections\n\([0-9]\)/Sections \1/
				}
			}
			/figure/{
			/figure$/{
				N
				s/figure\n\([0-9]\)/Figure \1/
				}
			/figures$/{
				N
				s/figures\n\([0-9]\)/Figures \1/
				}
			}
			/table/{
			/table$/{
				N
				s/table\n\([0-9]\)/Table \1/
				}
			/tables$/{
				N
				s/tables\n\([0-9]\)/Tables \1/
				}
			}
			/[?!.][)"]$/{
				N
				s/\([^ds]\.)\)\n\([A-Z]\)/\1~\
\2/
				s/\."\n\([A-Z]\)/.\\(rq~\
\1/
				s/\([?!])\)\n\([A-Z]\)/\1~\
\2/
			}
			/-$/{
			/[a-z]-$/{
				N
				s/-\n\([a-z]\)/-\1/
			}
			/[0-9tdh]-$/{
				N
				s/-\n\([0-9]\)/\\-\1/
				s/-\n\([a-z]\)/-\1/
				s/-\n\([A-Z]\)/\\-~\
\1/
			}
			}
			/[a-z]\.$/{
				N
				s/\.\n\([a-z]\)/.\\\& \1/
			}
			/up/{
			/up to$/{
				N
				s/up to\ndate/up-to-date/
			}
			/up$/{
				N
				s/up\nto date/up-to-date/
			}
			}
			/wear/{
			/wear$/{
				N
				s/wear\nand tear/wear-and-tear/
			}
			/wear and$/{
				N
				s/wear and\ntear/wear-and-tear/
			}
			}
			/[ivsfhw][ngoie][ehxfrn]ty$/{
				N
				s/\n\([otfsen][nwhoie][eoruvxgn]\)/-\1/
			}
		}
	}
	}
}
}
}
}
#polish.sedf.dup: .\&, p.99, $+c, endofline -, C.A.P.S.
/^\.\\"/!{
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/^\.EQ/,/^\.EN/!{
	/^\.TS/,/^\.TE/!{
		/^[^.]/{
			/\../{
			s/\([ (p]\)p\.\([0-9A-Z]\)/\1p.\\^\2/g
			s/\([ (p]\)p\. \([0-9A-Z]\)/\1p.\\^\2/g
			s/\([A-Z]\)\.\([A-Z]\)/\1.\\^\2/g
			s/\([A-Z]\)\.\([A-Z]\)/\1.\\^\2/g
			s/\([a-zA-Z]\)\. \([a-zA-Z]\)/\1.\\\& \2/g
			}
		}
		/^\.nf/,/^\.fi/!{
			/^[^.]/{
				/-$/{
				/[a-z]-$/{
					N
					s/-\n\([a-z]\)/-\1/
				}
				/[0-9tdh]-$/{
					N
					s/-\n\([0-9]\)/\\-\1/
				}
				}
			}
		}
	}
}
}
}
}
#polish.sedf3:  -ly-, -$&c, et al, .\&, p.79, v., 80s, figure, times, adverbs,endofline
/^\.\\"/!{
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/^\.EQ/,/^\.EN/!{
	/^\.TS/,/^\.TE/!{
		/^[^.]/{
			s/\([a-zA-Z]\)\. \([0-9(\a-zA-Z]\)/\1.\\\& \2/g
			/ly/{
			s/^\([A-Z][a-z]*\)ly /\1ly, /
			s/^Not \([a-z]*\)ly /Not \1ly, /
			s/^More \([a-z]*\)ly /More \1ly, /
			s/\([a-z][a-oq-z][a-oq-z]*\)ly-\([a-z]\)/\1ly \2/g
			}
			/[A-Z][A-Z]/{
			s/\([ (/]\)\([A-Z][A-Z][A-Z]*\)\([ ),;?!'./\:]\)/\1\\s-1\2\\s+1\3/g
			s/^\([A-Z][A-Z][A-Z]*\)\([ ),;?!'./\:]\)/\\s-1\1\\s+1\2/
			s/\([ (]\)\([A-Z][A-Z][A-Z]*\)$/\1\\s-1\2\\s+1/
			}
			s/\([MD]r\) /\1.\\\& /g
			s/Mrs /Mrs.\\\& /g
			s/^\([A-Z][a-z-]*\)wise /\1wise, /
			s/\([Uu]\)p to date/\1p-to-date/g
			s/\([Ww]\)ear and tear/\1ear-and-tear/g
			s/\([^,]\) in particular\.$/\1, in particular./
			s/\([^,]\) in that order\.$/\1, in that order./
			s/\([0-9]\) below\.$/\1, below./
			s/\([^,]\) of course\([^,.a-z)]\)/\1, of course,\2/g
			s/\([^,]\) of course\.$/\1, of course./
			s/\([ivsfhw][ngoie][ehxfrn]\)ty \([otfsen][nwhoie][eoruvxgn]\)/\1ty-\2/g
		}
		/[`$!]/!{
			/^[^.]/{
				s/( \([a-zA-Z\0-9]\)/(\1/g
				s/\([a-zA-Z0-9)]\) \([,;:)?]\)/\1\2/g
				/v/{
				s/ vs / \\f1v.\\\&\\fP /g
				s/^vs /\\f1v.\\\&\\fP /
				s/ vs$/ \\f1v.\\\&\\fP/
				s/ v / \\f1v.\\\&\\fP /g
				s/^v /\\f1v.\\\&\\fP /
				s/ v$/ \\f1v.\\\&\\fP/
				s/ v\. / \\f1v.\\\&\\fP /g
				s/^v\. /\\f1v.\\\&\\fP /
				s/ v\.$/ \\f1v.\\\&\\fP/
				s/ v\.\\\& / \\f1v.\\\&\\fP /g
				s/^v\.\\\& /\\f1v.\\\&\\fP /
				s/ v\.\\\&$/ \\f1v.\\\&\\fP/
				}
				/[<>+]/{
				s/ + /\\^\\(pl\\^/g
				s/+/\\^\\(pl\\^/g
				s/\([<>]\)/\\^\1\\^/g
				s/ \([<>]\) /\\^\1\\^/g
				}
				s/, ns\([^.]\)/, n.s.\1/g
				s/, sd\([^.]\)/, s.d.\1/g
			}
		}
	}
	/^[^.]/{
		s/\([cC]\)o-eff/\1oeff/g
		/\$/{
		s/\$\.\([1-9][0-9]\)\([0-9]\)\([^mMbBtT]\)/\1.\2\\(ct\3/g
		s/\$\.0\([0-9]\)\([0-9]\)\([^mMbBtT]\)/\1.\2\\(ct\3/g
		s/\$\.\([1-9][0-9]\)\([^mMbBtT]\)/\1\\(ct\2/g
		s/\$\.0\([0-9]\)\([^mMbBtT]\)/\1\\(ct\2/g
		}
		/al/{
		s/ et al\([^.]\)/ et al.\\\&\1/g
		s/^et al\([^.]\)/et al.\\\&\1/
		s/^al /al.\\\& /
		s/et al$/et al.\\\&/
		}
		s/\([ (p]\)p\([0-9A-Z]\)/\1p.\\^\2/g
		/\../{
			/p\./{
			s/\([ (p]\)p\.\([0-9A-Z]\)/\1p.\\^\2/g
			s/\([ (p]\)p\. \([0-9A-Z]\)/\1p.\\^\2/g
			s/^p\.\([0-9A-Z]\)/p.\\^\1/
			s/^p\. \([0-9A-Z]\)/p.\\^\1/
			}
			s/fn\.\([0-9]\)/fn.\\^\1/g
			s/fn\. \([0-9]\)/fn.\\^\1/g
			s/para\.\([0-9]\)/para.\\^\1/g
			s/para\. \([0-9]\)/para.\\^\1/g
			s/pg\.\([0-9A-Z]\)/p.\\^\1/
			s/pg\. \([0-9A-Z]\)/p.\\^\1/
		}
		/[0-9]/{
		s/\(1[89][0-9][0-9]\)'s/\1s/g
		s/\([0-9][0-9]\)'s/\1s/g
		s/\([^-]\)section \([0-9]\)/\1Section \2/g
		s/\([^-]\)sections \([0-9]\)/\1Sections \2/g
		s/figure \([0-9]\)/Figure \1/g
		s/figures \([0-9]\)/Figures \1/g
		s/table \([0-9]\)/Table \1/g
		s/tables \([0-9]\)/Tables \1/g
		s/\([0-9]\)x\([0-9]\)/\1\\^\\(mu\\^\2/g
		s/\([0-9]\)X\([0-9]\)/\1\\^\\(mu\\^\2/g
		}
		/;$/{
			N
			s/;\n\.\([^Lb]\)/:\
.\1/
		}
	}
}
}
}
}
#polish.sedf4: Vol.23, non, post, ith, ie, 9,999
/^\.\\"/!{
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/^\.EQ/,/^\.EN/!{
	/\../{
	/[0-9]/{
	s/Vol\.\([0-9]\)/Vol.\\^\1/g
	s/Vol\. \([0-9]\)/Vol.\\^\1/g
	s/No\.\([0-9]\)/No.\\^\1/g
	s/No\. \([0-9]\)/No.\\^\1/g
	}
	}
	/^\./!{
		s/\([^,]\) respectively\./\1, respectively./g
		s/\([^,;?.]\) see \([(\A-Z]\)/\1, see \2/g
		/[Nn]on /{
		s/Non \([a-zA-Z]\)/Non-\1/g
		s/\([ 	(]\)non \([a-zA-Z]\)/\1non-\2/g
		s/^non \([a-zA-Z]\)/non-\1/
		}
		/[Mm]ulti /{
		s/Multi \([a-zA-Z]\)/Multi-\1/g
		s/\([ 	(]\)multi \([a-zA-Z]\)/\1multi-\2/g
		s/^multi \([a-zA-Z]\)/multi-\1/
		}
		/[Ss]elf /{
		s/Self \([a-zA-Z]\)/Self-\1/g
		s/\([ 	(]\)self \([a-zA-Z]\)/\1self-\2/g
		s/^self \([a-zA-Z]\)/self-\1/
		}
		/[Ii]nter /{
		s/Inter \([a-zA-Z].[^i][^a]\)/Inter-\1/g
		s/\([ 	(]\)inter \(.[^l]\)/\1inter-\2/g
		s/^inter \(.[^l]\)/inter-\1/
		}
		/[Mm]id /{
		s/Mid \([a-zA-Z0-9]\)/Mid-\1/g
		s/\([ 	(]\)mid \([a-zA-Z0-9]\)/\1mid-\2/g
		s/^mid \([a-zA-Z0-9]\)/mid-\1/
		}
		s/Post \([a-zA-Z]\)/Post-\1/g
		/[ijknx]th/{
		s/\([ (]\)\([ijknx]\)th/\1\\f2\2\\fPth/g
		s/^\([ijknx]\)th/\\f2\1\\fPth/g
		}
		s/\([ (]\)ie\([, ]\)/\1i.e.\\\&\2/g
		s/\([ (]\)ie\.\([, ]\)/\1i.e.\\\&\2/g
		s/\([ (]\)eg\([, ]\)/\1e.g.\\\&\2/g
		s/\([ (]\)eg\.\([, ]\)/\1e.g.\\\&\2/g
		/[0-9]/{
		/[Ss]\../{
			s/\([ (]\)s\.\([0-9]\)/\1s.\\^\2/g
			s/\([ (]\)s\. \([0-9]\)/\1s.\\^\2/g
			s/\([ (]\)S\.\([0-9]\)/\1s.\\^\2/g
			s/\([ (]\)S\. \([0-9]\)/\1s.\\^\2/g
			}
		s/\([0-9]\)\([0-9][0-9][0-9]\)\([0-9][0-9][0-9][^0-9]\)/\1,\2,\3/g
		s/\([0-9]\)\([0-9][0-9][0-9]\)\([0-9][0-9][0-9]\)$/\1,\2,\3/
		s/\([^.][^.][0-9]\)\([0-9][0-9][0-9][^0-9]\)/\1,\2/g
		s/\([^.][^.][0-9]\)\([0-9][0-9][0-9][^0-9]\)/\1,\2/g
		s/\([^.][^.][0-9]\)\([0-9][0-9][0-9]\)$/\1,\2/
		s/^\([0-9]\)\([0-9][0-9][0-9][^0-9]\)/\1,\2/
		}
		s/\([Rr]\)ight hand/\1ight-hand/g
		s/\([Ll]\)eft hand/\1eft-hand/g
		s/foregone \([^c]\)/forgone \1/g
		s/foregone\.$/forgone./
		s/([Ee]d)/(ed.)/g
	}
	/^\.TS/,/^\.TE/!{
	/^\.nf/,/^\.fi/!{
		/^[^.]/{
			/[ uniLlg][nltmgeo][oteihfn][nirdte]$/{
			/ non$/{
				N
				s/\n/-/
			}
			/ multi$/{
				N
				s/\n/-/
			}
			/ inter$/{
				N
				s/\n\(.[^l]\)/-\1/
			}
			/ mid$/{
				N
				s/\n/-/
			}
			/[Rr]ight$/{
				N
				s/\nhand/-hand/
				}
			/[Ll]eft$/{
				N
				s/\nhand/-hand/
				}
			/foregone$/{
				N
				s/foregone\n\([^c]\)/forgone \1/
			}
			}
		}
	}
	}
}
}
}
}
#polish.sedf5: Firstly, however, adverbs
/^\.\\"/!{
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/^\.EQ/,/^\.EN/!{
	/^\.TS/,/^\.TE/!{
	/^\.nf/,/^\.fi/!{
		/^[^.]/{
			/ so$/{
				N
				s/\ncalled/-called/
			}
			/[^md] [a-z][a-z]* [tb][oy]$/{
				N
				s/ \([a-z][a-z]*\) \([tb][oy]\)\n\1 / \1-\2-\1 /
			}
			/day$/{
				N
				s/\nto day/-to-day/
			}
		}
	}
	}
	/^[^.]/{
		/^[ABFHIMNORT]/{
		s/^Also,/Moreover,/
		s/^Again /Again, /
		s/^By definition /By definition, /
		s/^Furthermore /Furthermore, /
		s/^Hence /Hence, /
		/^In/{
		s/^Instead \([^o]\)/Instead, \1/
		s/^Indeed /Indeed, /
		s/^In particular /In particular, /
		s/^In practice /In practice, /
		}
		s/^Moreover /Moreover, /
		s/^Nonetheless /None the less, /
		s/^Nevertheless /Nevertheless, /
		s/^On the one hand /On the one hand, /
		s/^On the other hand /On the other hand, /
		s/^Overall /Overall, /
		s/^Rather \(...[^ne]\)/Rather, \1/
		s/^Thereafter /Thereafter, /
		s/^Thus /Thus, /
		}
		/owever/{
		s/^However /But /
		s/^However, /But /
		s/\([a-z]\) however /\1, however, /g
		s/\([a-z]\) however$/\1, however,/
		s/\([a-z]\) however\.$/\1, however./
		}
		/or example/{
		s/^For example /For example, /
		s/\([a-z]\) for example /\1, for example, /g
		s/\([a-z]\) for example$/\1, for example,/
		s/\([a-z]\) for example\.$/\1, for example./
		}
		/\([a-z]\) for$/{
			N
			s/ for\nexample /, for\
example, /
		}
		s/ so called/ so-called/g
		s/^so called/so-called/
		s/\([^md]\) \([a-z][a-z]*\) \([tb][oy]\) \2 /\1 \2-\3-\2 /g
		s/\([^md]\) \([a-z][a-z]*\) \([tb][oy]\) \2$/\1 \2-\3-\2/
		s/etc\([^.h]\)/etc.\\\&\1/g
		s/\([a-z]\) if any\./\1, if any./g
		/[a-zOJ][a-z]ly/{
		s/\([Ff]\)irstly,/\1irst,/g
		s/\([Ss]\)econdly,/\1econd,/g
		s/\([Tt]\)hirdly,/\1hird,/g
		s/\([Ff]\)ourthly,/\1ourth,/g
		s/\([Ll]\)astly,/\1ast,/g
		s/^Not only,/Not only\\\&/
		/^[A-Z][a-z][a-z]*ly/{
		s/^Firstly/First,/g
		s/^Secondly/Second,/g
		s/^Thirdly/Third,/g
		s/^Fourthly/Fourth,/g
		s/^Lastly/Last,/g
		s/^Finally /Finally, /g
		s/^Especially,/Especially\\\&/
		s/^Carefully,/Carefully\\\&/
		s/^Early,/Early\\\&/
		s/^Freely,/Freely\\\&/
		s/^Supply,/Supply\\\&/
		s/^Simply,/Simply\\\&/
		s/^July,/July\\\&/
		s/^Hourly,/Hourly\\\&/
		s/^Daily,/Daily\\\&/
		s/^Weekly,/Weekly\\\&/
		s/^Monthly,/Monthly\\\&/
		s/^Statistically, sign/Statistically\\\& sign/
		s/^Approximately,/Approximately\\\&/
		s/^Relatively,/Relatively\\\&/
		s/^Only,/Only\\\&/
		s/^Merely,/Merely\\\&/
		s/^Virtually,/Virtually\\\&/
		s/^Possibly,/Possibly\\\&/
		s/^Unfortunately, for/Unfortunately\\\& for/
		s/^Immediately, \([ab][ef]\)/Immediately\\\& \1/
		s/^Surprisingly, \(..[twnh]\)/Surprisingly\\\& \1/
		s/^Strictly, \(speak\)/Strictly \1/
		s/^Fairly,/Fairly\\\&/
		s/^Roughly,/Roughly\\\&/
		}
		}
	}
}
}
}
}
#polish.sedf6: TS/TE sub- but PtyLtd -order defn avg whereas `` '' "
/^\.\\"/!{
/^\.TS/,/^\.TE/{
	/(.*)/{
	s/\([	^]\)(\([0-9\(-.mi ,]*\))\1/\1\\s-2(\2)\\s+2\1/g
	s/\([	^]\)(\([0-9\(-.mi ,]*\))\1/\1\\s-2(\2)\\s+2\1/g
	s/\([	^]\)(\([0-9\(-.mi ,]*\))$/\1\\s-2(\2)\\s+2/
	s/^(\([0-9\(-.mi ,]*\))\([	^]\)/\\s-2(\1)\\s+2\2/
	}
	/-/{
	s/\([	^]\)-\1/\1\\(em\1/g
	s/\([	^]\)-\1/\1\\(em\1/g
	s/\([	^]\)-$/\1\\(em/
	s/^-\([	^]\)/\\(em\1/
	}
	s/^\.SP/.sp/
}
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/^\.EQ/,/^\.EN/!{
	/[!$@`]/!{
		s/ sub / sub-/g
	}
	/^[^.]/{
		/\(['`]\)\1/{
			s/``/\\(lq/g
			s/''/\\(rq/g
		}
		/[!`$]/!{
		/"/{
			s/say "/say, \\(lq/g
			s/said "/said, \\(lq/g
			s/^"\([^ {}"]\)/\\(lq\1/
			s/\([([]\)"\([^ {}"]\)/\1\\(lq\2/g
			s/\([ 	]\)"\([^ {}"]\)/\1\\(lq\2/g
			s/\\(em"\([^ {}"]\)/\\(em\\(lq\1/g
			s/\([^ {}"]\)"\\(em/\1\\(rq\\(em/g
			s/\([.!?]\)"$/\1\\(rq~/
			s/\([.!?]\)"[~]$/\1\\(rq~/
			s/"\([.!?]\)$/\\(rq\1/
			s/\([^ {}"]\)"$/\1\\(rq/
			s/\([^ {}"]\)"\([])}]\)/\1\\(rq\2/g
			s/\([^ {}"]\)"\([ 	]\)/\1\\(rq\2/g
			s/\([^ {}"]\)"\([.,;:?!]\)/\1\\(rq\2/g
		}
		}
		/[PL]t/{
		s/Pty /Pty.\\\& /g
		s/Pty$/Pty.\\\&/
		s/Ltd /Ltd.\\\& /g
		s/Ltd$/Ltd.\\\&/
		}
		/ [tobw][hren]/{
		s/\([a-z][^sn,]\) though /\1, though, /g
		s/\([a-z][^sn,]\) though$/\1, though,/
		s/\([Ffeti][ichg][roih][snre][tdr]\) order/\1-order/g
		s/\([Ffe][ic][ro][sn][td]\) best/\1-best/g
		s/\([a-z0-9]\) on average\.$/\1, on average./
		s/\([a-z0-9]\) whereas/\1, whereas/g
		}
		s/\([eE]\)ntrepot/\1ntrep\\o'o^'t/g
		s/\([cC]\)liche/\1lich\\o'e\\(aa'/g
		/[Rr]ee/{
		s/\([Pp]\)reempt/\1re\\o'e\\(..'mpt/g
		s/\([Rr]\)eexam/\1e\\o'e\\(..'xam/g
		s/\([Rr]\)eenact/\1e\\o'e\\(..'nact/g
		s/\([Rr]\)eemerge/\1e\\o'e\\(..'merge/g
		s/\([Rr]\)eelect/\1e\\o'e\\(..'lect/g
		s/\([Rr]\)eestim/\1e\\o'e\\(..'stim/g
		s/\([Pp]\)reemin/\1re\\o'e\\(..'min/g
		}
		/[Rr]e-e/{
		s/\([Pp]\)re-empt/\1re\\o'e\\(..'mpt/g
		s/\([Rr]\)e-exam/\1e\\o'e\\(..'xam/g
		s/\([Rr]\)e-enact/\1e\\o'e\\(..'nact/g
		s/\([Rr]\)e-emerge/\1e\\o'e\\(..'merge/g
		s/\([Rr]\)e-elect/\1e\\o'e\\(..'lect/g
		s/\([Rr]\)e-estim/\1e\\o'e\\(..'stim/g
		s/\([Pp]\)re-emin/\1re\\o'e\\(..'min/g
		}
		/[Ee]lite/{
		s/^elite/\\o'e\\(\\\\''lite/
		s/ elite/ \\o'e\\(\\\\''lite/
		s/Elite/\\o'\\s-2E\\s0\\(\\\\''lite/
		}
	}
	/^\.TS/,/^\.TE/!{
	/^\.nf/,/^\.fi/!{
		/[`!$]/!{
		/^[^.]/{
			/ sub$/{
				N
				s/\n/-/
			}
		}
		}
		/^[^.]/{
			/[Ffei][icg][roh][sne][tdr]$/{
				N
				s/\norder/-order/
				s/\nbest/-best/
			}
		}
	}
	}
}
}
}
}
#polish.sedf9: UNDO troff cmds, U.S.A., EQ, 1,987, endofline em
/^\.\\"/!{
s/^\.\(.. \)\\-/.\1-/
s/^\.\([A-Z] \)\\-/.\1-/
/^\.[^H].*\\(ct/s/\\(ct/c/g
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/^\.EQ/,/^\.EN/!{
	/^[^.]/{
		s/,,/,/g
		s/delim(\\(lq)/delim(``)/
		s/^Rather, than/Rather than/
		/-[ah]/{
		s/\([a-z]\)-and /\1- and /g
		s/\([a-z]\)-and$/\1- and/
		s/have-to-have/have to have/g
		}
		/(pl/{
		s/\\s\\(pl/\\s+/g
		s/\\s\\\^\\(pl\\\^/\\s+/g
		}
		/U\.\\\^[SK]/{
		s/^U\.\\\^S\.\\\^A\.\([^A-Z]\)/U.S.A.\1/
		s/^U\.\\\^S\.\\\^A\.$/U.S.A./
		s/\([^.]\)U\.\\\^S\.\\\^A\.\([^A-Z]\)/\1U.S.A.\2/g
		s/\([^.]\)U\.\\\^S\.\\\^A\.$/\1U.S.A./
		s/^U\.\\\^\([SK]\)\.\([^A-Z]\)/U.\1.\2/
		s/^U\.\\\^\([SK]\)\.$/U.\1./
		s/\([^.]\)U\.\\\^\([SK]\)\.\([^A-Z]\)/\1U.\2.\3/g
		s/\([^.]\)U\.\\\^\([SK]\)\.$/\1U.\2./
		}
		/[pn]\.\\/{
		s/\([ (p]\)p\.\\\& \([0-9A-Z]\)/\1p.\\^\2/g
		s/^p\.\\\& \([0-9A-Z]\)/p.\\^\1/
		s/fn\.\\\& \([0-9]\)/fn.\\^\1/g
		}
		s/ vs / \\f1v.\\\&\\fP /g
	}
	/^\.TS/,/^\.TE/!{
	/^\.nf/,/^\.fi/!{
		/^[^.]/{
			/\\(em$/{
				N
				s/\n//
			}
		}
	}
	}
}
/\\/{
s/size \\-\([0-9]\)/size -\1/g
s/\\(\\(/\\(/g
s/\\(\\(/\\(/g
}
/1,9/{
s/^1,9\([0-9][0-9][^0-9]\)/19\1/g
s/\([^0-9]\)1,9\([0-9][0-9][^0-9]\)/\119\2/g
s/\([^0-9]\)1,9\([0-9][0-9][^0-9]\)/\119\2/g
s/\([^0-9]\)1,9\([0-9][0-9]\)$/\119\2/
s/\(\\[sf][0-9]\)1,9\([0-9][0-9][^0-9]\)/\119\2/g
s/\(\\s[+-][0-9]\)1,9\([0-9][0-9][^0-9]\)/\119\2/g
}
/2,0/{
s/^2,0\([0-9][0-9][^0-9]\)/20\1/g
s/\([^0-9]\)2,0\([0-9][0-9][^0-9]\)/\120\2/g
s/\([^0-9]\)2,0\([0-9][0-9][^0-9]\)/\120\2/g
s/\([^0-9]\)2,0\([0-9][0-9]\)$/\120\2/
}
}
}
/^\.TS/,/^\.TE/{
	/\\s-2(/{
	s/\([	^]\)\\s-2(\(ii*\))\\s+2\1/\1(\2)\1/g
	s/\([	^]\)\\s-2(\(ii*\))\\s+2\1/\1(\2)\1/g
	s/\([	^]\)\\s-2(\(ii*\))\\s+2$/\1(\2)/
	s/^\\s-2(\(ii*\))\\s+2\([	^]\)/(\1)\2/
	}
}
}
#polish.sedf9a:
/^\.\\"/!{
/^\.G1/,/^\.G2/!{
/^\.PS/,/^\.PE/!{
/\\[fs]/{
	s/\(\\s[+-][0-9]\)1,9\([0-9][0-9][^,0-9]\)/\119\2/g
	s/\\f\([1-4]\),\([0-9]\)/\\f\1\\\&\2/g
	}
/[0-9],[0-9]/{
	s/\([ (][0-9][0-9]*\)\\-\([0-9]\),\([0-9][0-9][0-9]\)/\1-\2\3/g
	s/^\([0-9][0-9]*\)\\-\([0-9]\),\([0-9][0-9][0-9]\)/\1-\2\3/g
	}
}
}
}


Up
Robert Marks, bobm@agsm.edu.au