#!/usr/bin/tclsh # The argument to march2txt.tcl is the name of the settings file, with the # default being march_settings.tcl if { [llength $argv] } { set filename_in "[file rootname [lindex $argv 0]].tcl" } else { set filename_in "march_settings.tcl" } # The form of the settings file is as follows: # (maybe a future version will be smarter about handling this # # set conference_year 2010 # # epitome_name is name of text file that contains entire March meeting # # Epitome, cut-and-pasted from website. Likewise, speakers_name is the # # name of a text file that contains a listing of all the invited speakers, # # cut-and-pasted from the March Meeting website. # # set epitome_name "Mar10epitome.txt" # set speakers_name "Mar10invited.txt" # # #The program generates three .tex files from these inputs: a listing of # #all the sessions, a grid that shows session room numbers and the number # #of invited talks, and a list of invited talks sorted by session. # # set session_out_name "Epitome_Mar10.tex" # set grid_out_name "Grid_Mar10.tex" # set speakers_out_name "Invited_Mar10.tex" # # # The room descriptions in the Epitome can be needlessly long, sometimes # # containing fully redundant information like the name of the convention # # center, and sometimes spelling out the whole fancy name of some # # ballroom. textsublist is a list of alternating room names and shorter # # abbreviations for them. # # set textsublist {"Portland Ballroom" "PB" "Oregon Ballroom" "OB"} # # these are tex headers, encapsulated in {s so I don't have to escape all # special characters # set gridheader {\documentclass[10pt]{article} \pagestyle{empty} \newcommand{\session}[3]{ \textbf{#1} & #3 & #2\\} \newcommand{\blocks}[1]{ Session & #1 & Room(s) \\} \newcommand{\blocktotal}[1]{\textbf{Sessions:} & #1 & \\} \newcommand{\speakerstotal}[1]{\textbf{Invited:} & #1 & \\} \newcommand{\invitedcount}[1]{\begin{tabular}[t]{r|lllllll|l} \cline{2-8} There are & #1 & Sessions \\ With & 0 & 1 & 2 & 3 & 4 & 5 & 6+ & Invited Talks \\ Symbol: & \tzero & \tone & \ttwo & \tthree & \tfour & \tfive & \tsix\\ \cline{2-8} \end{tabular} } \newcommand{\ns}{ } \newcommand{\tzero}{$\circ$} \newcommand{\tone}{$\star$} \newcommand{\ttwo}{$\star$} \newcommand{\tthree}{$\star$} \newcommand{\tfour}{$\bullet$} \newcommand{\tfive}{$\bullet$} \newcommand{\tsix}{$\diamond$} \setlength{\evensidemargin}{0in} \setlength{\oddsidemargin}{0pt} \setlength{\topmargin}{0pt} \setlength{\headheight}{0pt} \setlength{\headsep}{0pt} \setlength{\textwidth}{6.5in} \setlength{\textheight}{9in} } set epitomeheader {\documentclass[10pt]{article} \setlength{\evensidemargin}{-0.25in} \setlength{\oddsidemargin}{-0.25in} \setlength{\topmargin}{0pt} \setlength{\textwidth}{7in} \setlength{\textheight}{8.5in} \setlength{\parindent}{0pt} \setlength{\tabcolsep}{.2ex} \newcommand{\focus}[1]{\textit{#1}} \newcommand{\sessioncount}[1]{\normalsize Total Sessions:#1} } set talksheader {\documentclass[10pt]{article} \newcommand{\talk}[6]{\item[#1#2.#3] #4: #5. \textsc{#6}} \newcommand{\sessionskip}{\paragraph*{}\par} \newcommand{\blockskip}{\newpage\section*{}\par} \newcommand{\sessiontitle}[3]{\small \item \textbf{#1: #2}\quad Room:~\textsc{#3}} \newcommand{\specialtitle}[3]{\small \item \textbf{Special Session \ #1: #2}\quad Room:~\textsc{#3}\ \\ \textit{Start times after first talk are approximate}} \newcommand{\focus}[1]{\textit{#1}} \setlength{\evensidemargin}{0pt} \setlength{\oddsidemargin}{0pt} \setlength{\topmargin}{0pt} \setlength{\textwidth}{7in} \setlength{\textheight}{8.5in} \makeatletter \newcommand{\ps@invited}{% \renewcommand{\@oddhead}{March Meeting Invited Talks. \hfil} \renewcommand{\@evenhead}{\@oddhead} \renewcommand{\@oddfoot}{ \hfil \textit{Focus Sessions} in italics.} \renewcommand{\@evenfoot}{\@oddfoot}} \makeatother \pagestyle{invited} \newcommand{\talklabel}[1]{\hfil\normalsize\textbf{#1}} \newenvironment{talklist}{% \begin{list}{}{\renewcommand{\makelabel}{\talklabel}% \setlength{\labelwidth}{5em} \setlength{\labelsep}{1ex} \setlength{\leftmargin}{0pt} % \setlength{\rightmargin}{0pt} \setlength{\parsep}{0pt} \setlength{\itemsep}{0pt} }} % {\end{list}} \begin{document} \begin{talklist} \small } # the settings file will contain the names of the invited speakers list, # and the epitome. source $filename_in set totalsessioncount 0 # from epitome2tex set regularsessioncount 0 # from epitomegrid set invitedcount 0 set blocklist {} set maxsessions 0 set currentsessioncount 0 set regularsession false set newsession false set focussessioncount 0 set clockstring "%l:%M%p" set fieldsepmarker " & " set numwords [list zero one two three four five six seven] set epitome_in [open $epitome_name r] for {gets $epitome_in currentText} {![eof $epitome_in]} { gets $epitome_in currentText } { if {[regexp -- {^Mar [0-9]+ 20[0-9][0-9] ([1-9][012]?:[0-9][0-9][AP]M), ([MTWF][a-z]+)}\ $currentText match thetime dayofweek]} { set newsession true } if {[regexp -- {^Session ([A-Z])([1-9][0-9]?) (.+) Room:} \ $currentText match block session title]} { if {$newsession} { set currentsessioncount 0 set specialsession false if { $thetime == "8:00AM" || $thetime == "11:15AM" || $thetime == "2:30PM" } { set regularsession true lappend regularsessions $block } else { set regularsession false } set currentblock $block if {!$regularsession && ![regexp {Poster Session|Business Meeting|Reception|Presentation}\ $title]} { set specialsession true lappend specialsessions "$block$session" set currentblock $block$session } if {$regularsession || $specialsession} { lappend usefulblocks $currentblock set thetimes($currentblock) "[string tolower $thetime] $dayofweek" } set starttime($currentblock) $thetime } #if newsession regexp -- {Room: (.+)$} $currentText match room set room [string trim $room] set speakernum 0 gets $epitome_in nextLine if {[regexp -- {^Invited Speakers: (.*)} $nextLine match speakerList]} { set speakernum [llength [split $speakerList ,]] } incr invitedcount $speakernum #The session list parsing starts here if {[regexp -- {(.+) Sponsor:.+} $title match realtitle]} { set title $realtitle} else { if {[regexp -- {(.+) Chair:.+} $title match realtitle]} { set title $realtitle } } regsub -all {&} $title {\\&} title regsub -all { -- } $title {---} title foreach {textlong textsub} $textsublist { regsub -all $textlong $room $textsub room } if {[regexp -indices -- {^Focus Session: } $title titleindex]} { set title "\\focus\{[string range $title [expr 1+ [lindex \ $titleindex 1]] end]\}" incr focussessioncount } #here is where we build the two lists that will eventually be #fed into the output. Sessiontitles is for the invited speaker #list, sessionlist is for the epitome. It's easier to do two #separate lists, with the appropriate formatting done here, #than to do all the formatting at output time. #note that by using the array key $currentblock$session, the #session number will be duplicated for special sessions, but #this means that $currentblock drawn from $usefulsessions will #work with $currentblock$session in output if {![regexp {Poster Session|Business Meeting|Reception|Presentation}\ $title]} { regsub -all { } $room {~} nbroom set sessiontitles($currentblock$session) [list $block$session $title $nbroom] set title "$title. \\textsc\{$nbroom\}" set speakertext "\\tiny($speakernum)" lappend sessionlist($currentblock) [list $block$session $speakertext $title] incr totalsessioncount incr sessioncount($currentblock) } if {[info exists invitedArray($block)]} { incr invitedArray($block) $speakernum } else { set invitedArray($block) $speakernum } if {$speakernum > 6} {set speakernum 6} # There are only one or two sessions each year with more than 5 speakers, # usually a panel or something. To simplify the counting, we're using 6 to # denote 6+, but all speakers are added to invited speaker count # invcount(n) counts the number of sessions with n invited # speakers incr invcount($speakernum) #we will count invited speakers and sessions for the special #sessions but only want to build the grid for regular sessions if {$regularsession} { if {!([lsearch $blocklist $block]>-1)} {lappend blocklist $block} incr regularsessioncount if {[info exists sessionArray($block)]} { incr sessionArray($block) } else { set sessionArray($block) 1 } if {[info exists roomArray($session)]} { if {[lsearch $roomArray($session) $room] < 0} { lappend roomArray($session) $room } } { lappend roomArray($session) $room } set talkarray($block$session) $speakernum if {$session > $maxsessions} {set maxsessions $session} } set newsession false } #end if a session line regexp Session } #end for not end of epitome file close $epitome_in # set speakers_in [open $speakers_name r] foreach {textlong textsub} $textsublist { lappend textsubtext "$textsub=$textlong" } set textsubtext [join $textsubtext {, }] # output of session list (Epitome) set epitome_out [open $session_out_name w 0604] puts $epitome_out $epitomeheader puts $epitome_out "\\makeatletter\r" puts $epitome_out "\\newcommand\{\\ps@epitome\}\{%\r" puts $epitome_out "\\renewcommand\{\\@oddhead\}\{March Meeting \ $conference_year. \\hfil \\textit\{Focus Sessions\} in italics \{\\tiny\ (Invited talk \\# in parenthesis)\} \}\r" puts $epitome_out "\\renewcommand\{\\@evenhead\}\{\\@oddhead\}\r" puts $epitome_out "\\renewcommand\{\\@oddfoot\}\{$textsubtext\\hfil\}\r" puts $epitome_out "\\renewcommand\{\\@evenfoot\}\{\\@oddfoot\}\r" puts $epitome_out "\}\r" puts $epitome_out "\\makeatother\r" puts $epitome_out "\\pagestyle\{epitome\}\r" puts $epitome_out "\\begin\{document\}\r" puts $epitome_out "\\small\r" foreach block $usefulblocks { puts $epitome_out "\\begin\{tabular\}\{rrp{6.5in}l\}\r" puts $epitome_out \ "\\multicolumn\{4\}\{l\}\{\\textsc\{$thetimes($block)\}\} \\\\ \r" foreach session $sessionlist($block) { puts -nonewline $epitome_out [join $session $fieldsepmarker] puts $epitome_out " \\\\ \r" } puts $epitome_out "\\end\{tabular\}\r\r" puts $epitome_out "\\smallskip\r" if {$sessioncount($block)>1} { puts $epitome_out "Total Session $block:$sessioncount($block)\r" } puts $epitome_out "\r" puts $epitome_out "\\bigskip\r" } puts $epitome_out "\\end\{document\}\r" close $epitome_out # output of session summary grid set grid_out [open $grid_out_name w 0604] set blocktest [join $blocklist $fieldsepmarker] puts $grid_out $gridheader puts $grid_out "\\begin\{document\}" puts $grid_out "\\begin\{center\}" puts $grid_out "March Meeting $conference_year Rooms and Sessions" puts $grid_out "\\end\{center\}" puts $grid_out "$textsubtext\r\r" puts $grid_out "\\medskip\r" puts $grid_out "\\begin\{tabular\}\[t\]\{r|ccc|ccc|ccc|ccc|cc|l\}" puts $grid_out "\\blocks\{$blocktest\}\r" puts $grid_out "\\hline\r" for {set index 1} {$index <= $maxsessions} {incr index} { if {[info exists roomArray($index)]} { puts -nonewline $grid_out "\\session\{$index\}\{[join $roomArray($index) {, }]\}" } else { puts -nonewline $grid_out "\\session\{$index\}\{\}" } set sessionout {} foreach block $blocklist { if {[info exists talkarray($block$index)]} { lappend sessionout "\\t[lindex $numwords $talkarray($block$index)]" } else { lappend sessionout "\\ns" } } puts $grid_out "\{[join $sessionout $fieldsepmarker]\}\r" } foreach block $blocklist { lappend blockout $sessionArray($block) lappend speakersout $invitedArray($block) } puts $grid_out "\\hline\r" puts $grid_out "\\blocktotal\{[join $blockout $fieldsepmarker]\}\r" puts $grid_out "\\speakerstotal\{[join $speakersout $fieldsepmarker]\}\r" puts $grid_out "\\end\{tabular\}\r\r" puts $grid_out "\\medskip\r" puts $grid_out "Sessions: $regularsessioncount Regular, \ $focussessioncount Focus, $totalsessioncount Total\r\r" puts $grid_out "Invited Speakers: $invitedcount\r\r" for {set i 0} {$i <= 6} {incr i} {lappend countout $invcount($i)} puts $grid_out "\\invitedcount\{[join $countout $fieldsepmarker]\}\r" puts $grid_out "\\end{document}" close $grid_out # now process the speakers file set speakers_in [open $speakers_name r] gets $speakers_in line1 gets $speakers_in line2 for {} {![eof $speakers_in]} { gets $speakers_in line1 gets $speakers_in line2 } { if {[regexp -indices -- {^[^0-9]+$} $line1 authorindices] && \ [regexp -indices -- {([A-Z])([1-9][0-9]?)\.0+([1-9][0-9]?)} $line2 \ lineindices blockindices sessionindices talkindices] && \ [regexp -indices -start [lindex $talkindices 1] -- {Room:} $line2 \ roomindices] } { set author [string trim $line1] set title [string trim [string range $line2 [expr [lindex \ $lineindices 1] +1] [expr [lindex $roomindices 0] -1] ]] set block [string range $line2 [lindex $blockindices 0] \ [lindex $blockindices 1]] set session [string range $line2 [lindex $sessionindices 0] \ [lindex $sessionindices 1]] set talk [string range $line2 [lindex $talkindices 0] \ [lindex $talkindices 1]] set room [string range $line2 [expr [lindex $roomindices 1] +2] end] foreach {textlong textsub} $textsublist { regsub -all $textlong $room $textsub room } if {[lsearch $specialsessions $block$session]>-1} { lappend talklist($block$session) [list $block $session \ $talk $author $title] } else { if {[lsearch $regularsessions $block]>-1} { lappend talklist($block) [list $block $session $talk $author $title] } } } } close $speakers_in set speakers_out [open $speakers_out_name w 0604] foreach block $usefulblocks { if {[info exists talklist($block)]} { set talklist($block) [lsort -integer -index 2 $talklist($block)] set talklist($block) [lsort -integer -index 1 $talklist($block)] } } puts $speakers_out $talksheader foreach currentblock $usefulblocks { if {[lsearch $regularsessions $currentblock]>-1} { set regularsession true set outputline {\sessiontitle} } else { set regularsession false set outputline {\specialtitle} } if {[info exists talklist($currentblock)]} { puts $speakers_out "\\makeatletter\r" puts $speakers_out "\\renewcommand\{\\ps@invited\}\{%\r" puts $speakers_out "\\renewcommand\{\\@oddhead\}\{March Meeting \ $conference_year Invited Talks. \\hfil \\textbf\{$currentblock\}\ \\textsc\{$thetimes($currentblock)\}\}\r" puts $speakers_out "\\renewcommand\{\\@evenhead\}\{\\@oddhead\}\r" puts $speakers_out "\\renewcommand\{\\@oddfoot\}\{$textsubtext\\hfil \ \\textit\{Focus Sessions\} in italics.\}\r" puts $speakers_out "\\renewcommand\{\\@evenfoot\}\{\\@oddfoot\}\r" puts $speakers_out "\}\r" puts $speakers_out "\\makeatother\r" puts $speakers_out "\\pagestyle\{invited\}\r" set currentsession [lindex $talklist($currentblock) 0 1] puts -nonewline $speakers_out $outputline foreach field $sessiontitles($currentblock$currentsession) { puts -nonewline $speakers_out "\{$field\}" } puts $speakers_out "\r" set invited 0 foreach talk $talklist($currentblock) { if {[lindex $talk 1] != $currentsession} { puts $speakers_out "\\sessionskip" set currentsession [lindex $talk 1] puts -nonewline $speakers_out $outputline foreach field $sessiontitles($currentblock$currentsession) { puts -nonewline $speakers_out "\{$field\}" } puts $speakers_out "\r" set invited 0 } puts -nonewline $speakers_out "\\talk" set index [lindex $talk 2] set offset [expr 60* (12 * ($index -1) + (36-12) * $invited)] lappend talk [string tolower [clock format [expr [clock scan \ $starttime($currentblock)] + $offset] -format $clockstring]] incr invited foreach field $talk { puts -nonewline $speakers_out "\{$field\}" } puts $speakers_out "\r" } puts $speakers_out "\\blockskip" } } puts $speakers_out "\\end\{talklist\}" puts $speakers_out "\\end\{document\}" close $speakers_out