├── README.md ├── corpus.zip ├── doc ├── density.pdf ├── dtn.pdf ├── ieee.cls ├── ieeefig.sty ├── mostfreq.pdf ├── overlap-network.pdf ├── topic-network.pdf ├── topic-networks.pdf ├── topic-networks.tex └── wordcloud.pdf └── r └── topic-networks.R /README.md: -------------------------------------------------------------------------------- 1 | Topic-Networks 2 | ============== 3 | 4 | A demo of new approach to automatic text summarization using topic models and bipartite graphs. -------------------------------------------------------------------------------- /corpus.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobflagg/Topic-Networks/d7bd6d283a7674a9aff2182c118087a61f32f0e5/corpus.zip -------------------------------------------------------------------------------- /doc/density.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobflagg/Topic-Networks/d7bd6d283a7674a9aff2182c118087a61f32f0e5/doc/density.pdf -------------------------------------------------------------------------------- /doc/dtn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobflagg/Topic-Networks/d7bd6d283a7674a9aff2182c118087a61f32f0e5/doc/dtn.pdf -------------------------------------------------------------------------------- /doc/ieee.cls: -------------------------------------------------------------------------------- 1 | % ========================================================================= 2 | % ------------------------------------------------------------------------- 3 | % XX X 4 | % X 5 | % XX XXX XXX XXX XXX X XXXX 6 | % X X X X X X X X X X X 7 | % X XXXXX XXXXX XXXXX X X XXX 8 | % X X X X XX X X X X 9 | % XXX XXX XXX XXX XX XXX X XXXX 10 | % ------------------------------------------------------------------------- 11 | % ========================================================================= 12 | % ieee.cls --- For formatting IEEE conference & journal papers 13 | % --- Compiled by Gregory Plett, Sept 1997 14 | % 15 | % This class was inspired by one first compiled by Gerry Murray and 16 | % Silvano Balemi for LaTeX209. It was later updated for use with 17 | % LaTeX2e, and some bugs were fixed, all by Istvan Kollar. Lastly, 18 | % I have tried to make the class easier to use by paper authors. 19 | % Significant new functionality has been added. Many routines are 20 | % "borrowed" from other people's packages and modified extensively. 21 | % When I rembered where I got the routines from, I gave the author 22 | % credit. 23 | % 24 | % After I made many changes on my own, I found a version by Peter 25 | % N"uchter, and tried to retain some amount of compatibility with his 26 | % version. To be completely compatible with him, you may need to 27 | % manually: 28 | % \usepackage{rawfonts}\usepackage{oldlfont} 29 | % \AtBeginDocument{\parindent1.0em} (?) 30 | % 31 | %=========================================================================== 32 | % 33 | % Usage: 34 | % \documentclass[main-mode,sub-mode,misc-options]{ieee} 35 | % \usepackage{your own packages} 36 | % \begin{document} 37 | % \bibliographystyle{IEEEbib} 38 | % \title[short]{regular} 39 | % \author[short]{full} 40 | % \maketitle 41 | % \begin{abstract}...\end{abstract} 42 | % \begin{keywords}...\end{keywords} 43 | % \section{...} 44 | % \PARstart ... or \PARstartCal ... 45 | % ... 46 | % \begin{biography}[picname.ps]{Author's name}...\end{biography} 47 | % \end{document} 48 | % 49 | % The document class options are: 50 | % 51 | % main-mode: One of the following is required. (draft is the default) 52 | % draft: Double-spaced, single column with date/time stamp. 53 | % submission: Double-spaced, suitable for submission for review. 54 | % compressed: Same as "submission", only single spaced. 55 | % final: Double-column, for assessing page-length and 56 | % format of final version. 57 | % 58 | % sub-mode: 59 | % techreport: This can modify "final" to produce a two-col 60 | % technical report. 61 | % internal: This can modify "submission", "compressed" or "final". 62 | % It changes the header to notify the reader that 63 | % this is a version of the manuscript to be used for 64 | % internal review processes only, and not to be 65 | % distributed. 66 | % submitted: This can modify "compressed" or "final". It changes 67 | % the header to notify the reader that this 68 | % is a preprint and not to be distributed. 69 | % inpress: This can modify "compressed" or "final". It changes the 70 | % header to notify the reader that this paper has 71 | % been accepted for publishing, but it is not yet to be 72 | % distributed. 73 | % reprint: This can modify "final". It changes the header 74 | % to notify the reader where the paper is reprinted from. 75 | % 76 | % misc-options: 77 | % narroweqnarray: Changes the spacing around the "=" sign in 78 | % equation arrays to make it the same as in displayed math. 79 | % inline: Compresses the horizontal spacing of inline math equations. 80 | % notitlepage: No separate title page. (default) 81 | % titlepage: Separate title page. 82 | % anonymous: Omit all author information from main part of paper. 83 | % Author info only prints on titlepage. 84 | % 9pt,10pt,11pt,12pt: Choose the appropriate type size. You should 85 | % not need to do this as the "correct" size is automatically 86 | % chosen. However, if you want, you may use these to change 87 | % the type size of the main text. "9pt" is a bit of a hack 88 | % to retain backward-compatibility. 89 | % invited: If the paper is an "invited" paper, then this option 90 | % prints "(Invited Paper)" under the authors' names. 91 | % 92 | % For regular IEEE submissions, define the journal name as: 93 | % \journal{IEEE Trans. Inst. Meas.} 94 | % 95 | % To specify the conference place and date: 96 | % \confplacedate{Ottawa, Canada, May 19--21, 1997} 97 | % 98 | % Before \maketitle, define: 99 | % \title{Title of paper} 100 | % \author{Author1\member{Fellow}\authorinfo{Department of 101 | % Electrical Engineering\\ Some University, Somewhere, CA 94305 102 | % USA} \and Author2\member{Senior Member}\authorinfo{Deptartment of 103 | % Measurement and Instrument Eng., Another University, ...}} 104 | % 105 | % Note, the contents of \authorinfo tends to vary depending on if it is 106 | % a conference or journal paper. The amount of manual changes are 107 | % small, and must be done by a human anyway. The example given is for an 108 | % IMTC conference. 109 | % 110 | % See also IEEEbib.bst and ieeefig.sty 111 | % Also very useful for document preparation is the style file "endfloat", 112 | % available on all CTAN TeX archives. 113 | % 114 | %=========================================================================== 115 | % modified 14 October 2002: 116 | % - fixed bibliography listing of [#] when # < 10 and number of 117 | % references is greater than 9. Thanks for Janos Markus for finding 118 | % this bug and suggesting a solution. 119 | % modified 15 January 2000: 120 | % - "fixed" narroweqnarray. Never implemented! Now it is... 121 | % modified 12 January 2000: 122 | % - modified so only first \title and \author commands are recognized. 123 | % This allows LyX to have \title and \author with full syntax in 124 | % header, but dummy \title and \author show up in GUI. 125 | % - added "\date" so the \date command can change "submitted" and 126 | % "draft" date headers. 127 | % modified 11 January 2000: 128 | % - added PARstartLyX and PARstartCalLyX for LyX compatibility 129 | % - added biographyLyX 130 | % modified 1 Dec 1997: 131 | % - fixed first page in reprint mode to be same length as other pages 132 | % - added "invited" misc-option 133 | % modified 5 Sept 1997: 134 | % - added the inpress, reprint and internal sub-modes 135 | % - removed IMTC-conf and CDC-conf to separate files 136 | % modified 1 Sept 1997: 137 | % - included Babel package compatibility 138 | % - removed paper title from header on first page of draft 139 | % manuscript 140 | % - removed the fixed option "letterpaper" to allow a4paper (etc) 141 | % modified 1 Aug 1997: 142 | % - included the CDC-conf option 143 | %=========================================================================== 144 | % ************************************************************************** 145 | % ****** ****************************************** 146 | % ***** LaTeX2e INITIALIZATION ***************************************** 147 | % ****** ****************************************** 148 | % ************************************************************************** 149 | \typeout{Document Class `ieee' .} 150 | \NeedsTeXFormat{LaTeX2e}[1993/11/11] % Oldest acceptable version of LaTeX2e 151 | \ProvidesClass{ieee}[2000/01/11] % Name of package provided, date 152 | \def\i@@@cls{exists} 153 | 154 | % Initial Code & Declaration of Options 155 | % ------------------------------------- 156 | \newif\ifev@l \ev@lfalse % true if "final" mode. 157 | \newif\ifsubm@t \subm@tfalse % true if "submission" mode. 158 | \newif\ifdr@ft \dr@fttrue % true if "draft" mode. 159 | \newif\ifc@mpress \c@mpressfalse % true if "compressed" mode. 160 | 161 | \newif\if@technote \@technotefalse % true if "technote" sub-mode. 162 | \newif\ifintern@l \intern@lfalse % true if "internal" sub-mode. 163 | \newif\ifprepr@nt \prepr@ntfalse % true if "preprint" sub-mode. 164 | \newif\ifinpr@ss \inpr@ssfalse % true if "inpress" sub-mode. 165 | \newif\ifrepr@nt \repr@ntfalse % true if "reprint" sub-mode. 166 | 167 | \newif\iftitlep@ge \titlep@gefalse % true if has own titlepage 168 | \newif\if@non \@nonfalse % true if anonymous 169 | \newif\ifixpt \ixptfalse % true if trying to do 9 pt 170 | \newif\if@nvited \@nvitedfalse % true if an invited paper 171 | 172 | % Main options 173 | % ------------ 174 | \DeclareOption{draft}{\ev@lfalse\subm@tfalse\dr@fttrue% 175 | \typeout{ieee: `Draft' mode selected.}} 176 | \DeclareOption{submission}{\ev@lfalse\dr@ftfalse\subm@ttrue% 177 | \typeout{ieee: `Submission' mode selected.}} 178 | \DeclareOption{compressed}{\ev@lfalse\dr@ftfalse\subm@tfalse\c@mpresstrue% 179 | \typeout{ieee: `Compressed' mode selected.}} 180 | \DeclareOption{final}{\ev@ltrue\dr@ftfalse\subm@tfalse% 181 | \typeout{ieee: `Final' mode selected.}} 182 | \DeclareOption{evaluation}{\ev@ltrue\dr@ftfalse\subm@tfalse% 183 | \typeout{ieee: `Final' mode selected.}} % synonym for final 184 | 185 | % Sub options 186 | % ----------- 187 | \DeclareOption{technote}{\@technotetrue% 188 | \typeout{ieee: `Technote' sub-mode selected.}} 189 | \DeclareOption{internal}{\intern@ltrue\prepr@ntfalse\inpr@ssfalse\repr@ntfalse% 190 | \typeout{ieee: `Internal-Review' sub-mode selected.}} 191 | \DeclareOption{submitted}{\intern@lfalse\prepr@nttrue\inpr@ssfalse\repr@ntfalse% 192 | \typeout{ieee: `Submitted' sub-mode selected.}} 193 | \DeclareOption{preprint}{\intern@lfalse\prepr@nttrue\inpr@ssfalse\repr@ntfalse% 194 | \typeout{ieee: `Submitted' sub-mode selected.}} % synonym for submitted 195 | \DeclareOption{inpress}{\intern@lfalse\prepr@ntfalse\inpr@sstrue\repr@ntfalse% 196 | \typeout{ieee: `Inpress' sub-mode selected.}} 197 | \DeclareOption{reprint}{\intern@lfalse\prepr@ntfalse\inpr@ssfalse\repr@nttrue% 198 | \typeout{ieee: `Reprint' sub-mode selected.}} 199 | 200 | % Misc options 201 | % ------------ 202 | % regular or compressed "=" spacing in 203 | \def\eqnarr@ysep{\arraycolsep} % eqnarray (this is the default) 204 | % NOTE: we must use "def" and not "=" 205 | % as arraycolsep not yet defined. 206 | \DeclareOption{narroweqnarray}{\gdef\eqnarr@ysep{0.28em\relax}% 207 | \typeout{ieee: Narrow equation arrays selected.}} 208 | \DeclareOption{inline}{\everymath{\thinmuskip=2mu plus 1mu 209 | \medmuskip=3mu plus 1mu minus 2mu 210 | \thickmuskip=4mu plus 2mu\relax}% 211 | \typeout{ieee: Narrower inline equations selected.}} 212 | \DeclareOption{notitlepage}{\titlep@gefalse% 213 | \typeout{ieee: No separate title page.}} 214 | \DeclareOption{titlepage}{\titlep@getrue% 215 | \typeout{ieee: Use separate title page.}} 216 | \DeclareOption{anonymous}{\@nontrue\AtBeginDocument{\glpexclude{biography}} 217 | \typeout{ieee: Omit author information from paper.}} 218 | \DeclareOption{invited}{\@nvitedtrue% 219 | \typeout{ieee: (Invited Paper).}} 220 | 221 | \DeclareOption{9pt}{\ixpttrue% 222 | \typeout{ieee: Trying to emulate old `9pt' document class.}} 223 | 224 | \DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} 225 | 226 | % Execution of Options/Package Loading 227 | % ------------------------------------ 228 | \newlength\narrowcol 229 | \newlength\parindentsave % recover parindent in blsone text 230 | 231 | \ProcessOptions 232 | \ifev@l % if "final" mode... 233 | \if@technote\ixpttrue\typeout{ieee: Trying to emulate old `9pt' 234 | document class.}\fi% 235 | \LoadClass[twoside,final,twocolumn,10pt]{article} 236 | \else % if "draft"/"submission"/(compressed) mode... 237 | \ifixpt 238 | \LoadClass[oneside,final,onecolumn,10pt]{article} 239 | \else 240 | \LoadClass[oneside,final,onecolumn,12pt]{article} 241 | \fi 242 | \fi 243 | \RequirePackage[final]{graphicx} 244 | \RequirePackage{ifthen} 245 | 246 | % Re-Definitions of English words which must be done before 247 | % the Babel package (optional) is loaded. 248 | % --------------------------------------------------------- 249 | \def\keywordsname{Index Terms} 250 | \def\indexterms#1{\def\keywordsname{#1}} 251 | \def\appendicesname{Appendices} 252 | \def\figurename{Fig.} 253 | 254 | % ************************************************************************** 255 | % ***** Check Sub-Options for Compatibility w/ Main-Options ************ 256 | % ************************************************************************** 257 | \if@technote\ifev@l\else\ClassError{ieee}{`technote' sub-mode may be 258 | used only with the `final' ^^Jmain-mode. It may not be used 259 | with either the `draft,' `submission,' or ^^J`compressed' 260 | main-modes}{}\endinput\fi\fi 261 | \ifintern@l\ifdr@ft\ClassError{ieee}{`internal' sub-mode may be 262 | used only with the ^^J`submission,' `compressed,' or `final' main-modes. 263 | It may not be used ^^Jwith the `draft' main-mode}{}\endinput\fi\fi 264 | \ifprepr@nt\ifc@mpress\else\ifev@l\else\ClassError{ieee}{`submitted' 265 | sub-mode may be used only with the ^^J`compressed' or `final' 266 | main-modes. It may not be used with either the ^^J`draft' or 267 | `submission' main-modes}{}\endinput\fi\fi\fi 268 | \ifinpr@ss\ifc@mpress\else\ifev@l\else\ClassError{ieee}{`inpress' 269 | sub-mode may be used only with the `compressed' ^^Jor `final' 270 | main-modes. It may not be used with either the `draft' or 271 | ^^J`submission' main-modes}{}\endinput\fi\fi\fi 272 | \ifrepr@nt\ifev@l\else\ClassError{ieee}{`reprint' 273 | sub-mode may be used only with the `final' ^^Jmain-mode. It may not be 274 | used with either the `draft,' `submission,' or ^^J`compressed' 275 | main-modes}{}\endinput\fi\fi 276 | 277 | % ************************************************************************** 278 | % ***** Page Layout Definition ***************************************** 279 | % ************************************************************************** 280 | %% Layout definitions (mostly) common to all options. 281 | 282 | \hoffset 0in \voffset 0in 283 | \headheight 12pt \headsep 7mm 284 | \marginparsep 10pt \marginparwidth 20pt 285 | \marginparpush 25pt 286 | \columnsep 4mm 287 | \parindent 1.0em 288 | \lineskip 1pt 289 | \normallineskip 1pt 290 | \def\baselinestretch{1} 291 | 292 | \partopsep \z@ 293 | \topsep 1.3ex 294 | \parsep \z@ 295 | \itemsep \z@ 296 | 297 | \setlength{\parindentsave}{\parindent} 298 | 299 | \ifev@l % if "evaluation" mode 300 | % if camera-ready or A4paper ... 301 | \ifdim\paperwidth<211mm 302 | \oddsidemargin -11.4mm \evensidemargin -11.4mm 303 | % for regular US Letter, not camera-ready 304 | \else 305 | \oddsidemargin -8.45mm \evensidemargin -8.45mm 306 | \fi 307 | \ifrepr@nt 308 | \textheight 237.5mm % leave 6mm for cpyright on first page 309 | \else 310 | \textheight 243.5mm 311 | \fi 312 | \voffset -0.5in 313 | \textwidth 182.0mm 314 | \topmargin -12pt 315 | \setlength{\narrowcol}{89mm} 316 | \else % if "draft"/"submission" mode... 317 | \ifc@mpress % and "compressed" 318 | \oddsidemargin -0.25in \evensidemargin -0.25in 319 | \textheight 9in \textwidth 7in 320 | \topmargin -0.25in 321 | \setlength{\narrowcol}{7in} 322 | \else % and NOT "compressed" 323 | \renewcommand\baselinestretch{1.8}\renewcommand{\arraystretch}{0.8} 324 | \parindent=1.8\parindent 325 | \oddsidemargin 0pt \evensidemargin 0pt 326 | \headheight 12pt \headsep 0.375in 327 | \topmargin 0pt 328 | \textheight 8.5in \textwidth 6.5in 329 | \marginparsep 0in \marginparwidth 0pt 330 | \marginparpush 5pt 331 | \setlength{\narrowcol}{6.5in} 332 | \fi 333 | \fi 334 | 335 | \def\normalstyle{\rmfamily} 336 | 337 | % ************************************************************************** 338 | % ***** Font Definition ************************************************ 339 | % ************************************************************************** 340 | %% The 9-point option is being faked since it is not supported by the 341 | %% article base class. 342 | 343 | %% Check if we have selected 9 points 344 | \ifixpt 345 | \typeout{-- This is a 9 point document} 346 | \gdef\@ptsize{9} 347 | \def\@normalsize{\@setsize\normalsize{10.7pt}\ixpt\@ixpt 348 | \abovedisplayskip 1em plus2pt minus5pt\belowdisplayskip \abovedisplayskip 349 | \abovedisplayshortskip \z@ plus3pt\belowdisplayshortskip .6em plus3pt minus3pt 350 | \topsep \belowdisplayshortskip%!PN 351 | } 352 | \def\small{\@setsize\small{9.12pt}\viiipt\@viipt} 353 | \def\footnotesize{\@setsize\footnotesize{8.15pt}\viipt\@vipt} 354 | \def\scriptsize{\@setsize\scriptsize{8pt}\vipt\@vpt} 355 | \def\tiny{\@setsize\tiny{5pt}\vpt\@vpt} 356 | \def\large{\@setsize\large{12pt}\xpt\@xpt} 357 | \def\Large{\@setsize\Large{14pt}\xiipt\@xiipt} 358 | \def\LARGE{\@setsize\LARGE{18pt}\xivpt\@xivpt} 359 | \def\huge{\@setsize\huge{22pt}\xviipt\@xviipt} 360 | \def\Huge{\@setsize\Huge{25pt}\xxpt\@xxpt} 361 | \fi 362 | %% 363 | %% Check if we have selected 10 points 364 | \def\@tempa{0}\if\@ptsize\@tempa 365 | \typeout{-- This is a 10 point document} 366 | \def\@normalsize{\@setsize\normalsize{11.9pt}\xpt\@xpt 367 | \abovedisplayskip 1em plus2pt minus5pt\belowdisplayskip \abovedisplayskip 368 | \abovedisplayshortskip \z@ plus3pt\belowdisplayshortskip .6em plus3pt minus3pt 369 | \topsep \belowdisplayshortskip%!PN 370 | } 371 | \def\small{\@setsize\small{9.2pt}\viiipt\@viiipt} 372 | \def\footnotesize{\@setsize\footnotesize{8.8pt}\viiipt\@viiipt} 373 | \def\scriptsize{\@setsize\scriptsize{8pt}\viipt\@viipt} 374 | \def\tiny{\@setsize\tiny{6pt}\vpt\@vpt} 375 | \def\normalsize{\@setsize\normalsize{11.9pt}\xpt\@xpt} 376 | \def\large{\@setsize\large{14pt}\xiipt\@xiipt} 377 | \def\Large{\@setsize\Large{18pt}\xivpt\@xivpt} 378 | \def\LARGE{\@setsize\LARGE{22pt}\xviipt\@xviipt} 379 | \def\huge{\@setsize\huge{22pt}\xxpt\@xxpt} 380 | \def\Huge{\@setsize\Huge{28pt}\xxvpt\@xxvpt} 381 | \fi 382 | %% 383 | %% Check if we have selected 11 points 384 | \def\@tempa{1}\if\@ptsize\@tempa 385 | \typeout{-- This is an 11 point document} 386 | \def\@normalsize{\@setsize\normalsize{13.6pt}\xipt\@xipt 387 | \abovedisplayskip 1em plus2pt minus5pt\belowdisplayskip \abovedisplayskip 388 | \abovedisplayshortskip \z@ plus3pt\belowdisplayshortskip .6em plus3pt minus3pt 389 | \topsep \belowdisplayshortskip%!PN 390 | } 391 | \def\small{\@setsize\small{12pt}\xpt\@xpt} 392 | \def\footnotesize{\@setsize\footnotesize{11pt}\ixpt\@ixpt} 393 | \def\scriptsize{\@setsize\scriptsize{9.5pt}\viiipt\@viiipt} 394 | \def\tiny{\@setsize\tiny{7pt}\vipt\@vipt} 395 | \def\normalsize{\@setsize\normalsize{13.6pt}\xipt\@xipt} 396 | \def\large{\@setsize\large{14pt}\xiipt\@xiipt} 397 | \def\Large{\@setsize\Large{18pt}\xivpt\@xivpt} 398 | \def\LARGE{\@setsize\LARGE{22pt}\xviipt\@xviipt} 399 | \def\huge{\@setsize\huge{25pt}\xxpt\@xxpt} 400 | \def\Huge{\@setsize\Huge{30pt}\xxvpt\@xxvpt} 401 | \fi 402 | %% 403 | %% Check if we have selected 12 points 404 | \def\@tempa{2}\if\@ptsize\@tempa 405 | \typeout{-- This is a 12 point document} 406 | \def\@normalsize{\@setsize\normalsize{14pt}\xiipt\@xiipt 407 | \abovedisplayskip 1em plus3pt minus6pt\belowdisplayskip \abovedisplayskip 408 | \abovedisplayshortskip \z@ plus3pt\belowdisplayshortskip .6em plus4pt minus4pt 409 | \topsep \belowdisplayshortskip%!PN 410 | } 411 | \def\small{\@setsize\small{11.4pt}\xpt\@xpt} 412 | \def\footnotesize{\@setsize\footnotesize{10pt}\ixpt\@ixpt} 413 | \def\scriptsize{\@setsize\scriptsize{9pt}\viiipt\@viiipt} 414 | \def\tiny{\@setsize\tiny{8pt}\vipt\@vipt} 415 | \def\normalsize{\@setsize\normalsize{14pt}\xiipt\@xiipt} 416 | \def\large{\@setsize\large{18pt}\xivpt\@xivpt} 417 | \def\Large{\@setsize\Large{22pt}\xviipt\@xviipt} 418 | \def\LARGE{\@setsize\LARGE{25pt}\xxpt\@xxpt} 419 | \def\huge{\@setsize\huge{30pt}\xxvpt\@xxvpt} 420 | \let\Huge=\huge 421 | \fi 422 | 423 | \AtBeginDocument{\normalsize\normalstyle\ps@headings\pagenumbering{arabic}} 424 | 425 | % ************************************************************************** 426 | % ***** List Definition ************************************************ 427 | % ************************************************************************** 428 | %% Change aspect of lists with 429 | %% 1) \itemindent, label indentation wrt to left list margin 430 | %% 2) \leftmargini, the indentation of the whole list (on left, first level) 431 | \ifev@l 432 | \itemindent -1em 433 | \leftmargini 2em 434 | \leftmarginii 1em 435 | \leftmarginiii 1.5em 436 | \leftmarginiv 1.5em 437 | \leftmarginv 1.0em 438 | \leftmarginvi 1.0em 439 | \else 440 | \itemindent -1em 441 | \leftmargini 3em 442 | \leftmarginii 3em 443 | \leftmarginiii 3em 444 | \leftmarginiv 3em 445 | \leftmarginv 3em 446 | \leftmarginvi 3em 447 | \fi 448 | %\itemindent 2em % Alternative values: sometimes used.. 449 | %\leftmargini 0em 450 | \labelsep 5pt 451 | \leftmargin\leftmargini 452 | \labelwidth \z@ 453 | 454 | \def\@listI{\leftmargin\leftmargini} \@listI 455 | \def\@listi{\leftmargin\leftmargini \topsep \z@ plus 1pt minus 1pt} 456 | \def\@listii{\leftmargin\leftmarginii\labelwidth\leftmarginii 457 | \advance\labelwidth-\labelsep \topsep \z@} 458 | \def\@listiii{\leftmargin\leftmarginiii\labelwidth\leftmarginiii 459 | \advance\labelwidth-\labelsep \topsep \z@} 460 | \def\@listiv{\leftmargin\leftmarginiv\labelwidth\leftmarginiv 461 | \advance\labelwidth-\labelsep \topsep \z@} 462 | \def\@listv{\leftmargin\leftmarginv\labelwidth\leftmarginv 463 | \advance\labelwidth-\labelsep \topsep \z@} 464 | \def\@listvi{\leftmargin\leftmarginvi\labelwidth\leftmarginvi 465 | \advance\labelwidth-\labelsep \topsep \z@} 466 | 467 | \def\labelenumi{\theenumi.} \def\theenumi{\arabic{enumi}} 468 | \def\labelenumii{(\theenumii)} \def\theenumii{\alph{enumii}} 469 | \def\labelenumiii{\theenumiii.} \def\theenumiii{\roman{enumiii}} 470 | \def\labelenumiv{\theenumiv.} \def\theenumiv{\Alph{enumiv}} 471 | \def\p@enumii{\theenumi} 472 | \def\p@enumiii{\theenumi(\theenumii)} 473 | \def\p@enumiv{\p@enumiii\theenumiii} 474 | 475 | \def\labelitemi{$\scriptstyle\bullet$} 476 | \def\labelitemii{\bf --} 477 | \def\labelitemiii{$\ast$} 478 | \def\labelitemiv{$\cdot$} 479 | 480 | %% \itemindent is set to \z@ by list, so define new temporary variable 481 | \newdimen\tmpitemindent 482 | \def\verse{\let\\=\@centercr 483 | \list{}{\itemsep\z@ \itemindent -1.5em \listparindent \itemindent 484 | \rightmargin\leftmargin\advance\leftmargin 1.5em}\item[]} 485 | \let\endverse\endlist 486 | \def\quotation{\list{}{\listparindent 1.5em \itemindent\listparindent 487 | \rightmargin\leftmargin \parsep 0pt plus 1pt}\item[]} 488 | \let\endquotation=\endlist 489 | \def\quote{\list{}{\rightmargin\leftmargin}\item[]} 490 | \let\endquote=\endlist 491 | \def\@mklab#1{#1} 492 | \def\description{\tmpitemindent\itemindent\list{}{\itemindent\tmpitemindent 493 | \labelwidth\z@\def\makelabel##1{\hspace\labelsep\emph{##1}}}} 494 | \def\enddescription{\endlist\par} 495 | \def\enumerate{\tmpitemindent\itemindent\ifnum \@enumdepth >3 \@toodeep\else 496 | \advance\@enumdepth \@ne \edef\@enumctr{enum\romannumeral\the\@enumdepth}% 497 | \list{\csname label\@enumctr\endcsname}{\itemindent\tmpitemindent 498 | \usecounter{\@enumctr}\def\makelabel##1{\hspace\labelsep\hfil{##1}}}\fi} 499 | \def\endenumerate{\endlist\par} 500 | \def\itemize{\tmpitemindent\itemindent\ifnum \@itemdepth >3 \@toodeep\else 501 | \advance\@itemdepth\@ne 502 | \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}% 503 | \list{\csname\@itemitem\endcsname}{\itemindent\tmpitemindent 504 | \def\makelabel##1{\hspace\labelsep\hfil\emph{##1}}}\fi} 505 | \def\enditemize{\endlist\par} 506 | 507 | \newif\if@restonecol 508 | \def\titlepage{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn 509 | \else \newpage \fi \thispagestyle{coverpagestyle}\c@page\z@} 510 | \def\endtitlepage{\if@restonecol\twocolumn \else \newpage \fi% 511 | \if@twoside\mbox{}\thispagestyle{coverpagestyle}\c@page\z@\cleardoublepage\fi} 512 | 513 | \arraycolsep 5pt 514 | \tabcolsep 6pt 515 | \arrayrulewidth .4pt 516 | \doublerulesep 2pt 517 | \tabbingsep\labelsep 518 | 519 | % ************************************************************************** 520 | % ***** Footnote Definition ******************************************** 521 | % ************************************************************************** 522 | \skip\footins 10pt plus 5pt minus 2pt 523 | \footnotesep 7pt 524 | \footskip 6mm 525 | \skip\@mpfootins = \skip\footins 526 | \fboxsep = 3pt \fboxrule = .4pt 527 | \long\def\@makefntext#1{\parindent .8em\indent$^{\@thefnmark}$#1} 528 | \def\footnoterule{} 529 | 530 | % Reset baselinestretch within footnotes. 531 | % Originally stolen from Stanford University thesis style. 532 | % -------------------------------------------------------- 533 | \long\def\@footnotetext#1{\insert\footins{\blsone% 534 | \footnotesize\interlinepenalty\interfootnotelinepenalty 535 | \splittopskip\footnotesep 536 | \splitmaxdepth \dp\strutbox \floatingpenalty \@MM 537 | \hsize\columnwidth \@parboxrestore 538 | \edef\@currentlabel{\csname p@footnote\endcsname\@thefnmark}\@makefntext 539 | \let\par\\ 540 | {\rule{\z@}{\footnotesep}\ignorespaces 541 | #1\strut}}} 542 | 543 | % ************************************************************************** 544 | % ***** Keep track of Sections ***************************************** 545 | % ************************************************************************** 546 | \if@technote 547 | \setcounter{secnumdepth}{3} 548 | \else 549 | \setcounter{secnumdepth}{4} 550 | \fi 551 | 552 | \def\thesection{\@Roman\c@section} 553 | \def\thesubsection{\Alph{subsection}} 554 | \def\thesubsubsection{\thesubsection.\arabic{subsubsection}} 555 | \def\thesubsubsectiondis{\Alph{subsection}.\arabic{subsubsection}} 556 | \def\theparagraph{\thesubsubsection.\alph{paragraph}} 557 | \def\theparagraphdis{\thesubsubsectiondis.\alph{paragraph}} 558 | 559 | \def\theequation{\arabic{equation}} 560 | 561 | % ************************************************************************** 562 | % ***** Table of Contents, List of Figures/Tables Definitions ********** 563 | % ************************************************************************** 564 | \def\@pnumwidth{1.55em} 565 | \def\@tocrmarg {2.55em} 566 | \def\@dotsep{4.5} 567 | \setcounter{tocdepth}{3} 568 | 569 | \def\tableofcontents{\section*{\contentsname}\@starttoc{toc}} 570 | \def\l@section#1#2{\addpenalty{\@secpenalty} \addvspace{1.0em plus 1pt} 571 | \@tempdima 1.8em \begingroup \parindent \z@ \rightskip \@pnumwidth 572 | \parfillskip-\@pnumwidth \bf\leavevmode #1\hfil\hbox to\@pnumwidth{\hss #2} 573 | \par \endgroup} 574 | \def\l@subsection{\@dottedtocline{2}{1.5em}{2.3em}} 575 | \def\l@subsubsection{\@dottedtocline{3}{3.8em}{3.2em}} 576 | \def\listoffigures{\section*{\listfigurename}\@starttoc{lof}} 577 | \def\l@figure{\@dottedtocline{1}{1em}{1.8em}} 578 | \def\listoftables{\section*{\listtablename}\@starttoc{lot}} 579 | \let\l@table\l@figure 580 | 581 | % ************************************************************************** 582 | % ***** Float Definitions ********************************************** 583 | % ************************************************************************** 584 | %% Normal Floats %% Double Column Floats 585 | \floatsep 12pt plus 2pt minus 2pt \dblfloatsep 12pt plus 2pt minus 2pt 586 | \textfloatsep 20pt plus 2pt minus 4pt \dbltextfloatsep 20pt plus 2pt minus 4pt 587 | %\@maxsep 20pt \@dblmaxsep 20pt %!PN 588 | \@fptop 0pt plus 1fil \@dblfptop 0pt plus 1fil 589 | \@fpsep 8pt plus 2fil \@dblfpsep 8pt plus 2fil 590 | \@fpbot 0pt plus 1fil \@dblfpbot 0pt plus 1fil 591 | \def\topfraction{1.0} \def\dbltopfraction{1.0} 592 | \def\floatpagefraction{0.8} \def\dblfloatpagefraction{0.8} 593 | \setcounter{topnumber}{2} \setcounter{dbltopnumber}{4} 594 | % 595 | \intextsep 12pt plus 2pt minus 2pt 596 | \setcounter{bottomnumber}{2} 597 | \def\bottomfraction{.4} 598 | \setcounter{totalnumber}{4} 599 | \def\textfraction{.2} 600 | 601 | % Reset baselinestretch within floats. 602 | % Originally stolen from Stanford University thesis style. 603 | % -------------------------------------------------------- 604 | \def\@xfloat#1[#2]{\ifhmode \@bsphack\@floatpenalty -\@Mii\else 605 | \@floatpenalty-\@Miii\fi\def\@captype{#1}\ifinner 606 | \@parmoderr\@floatpenalty\z@ 607 | \else\@next\@currbox\@freelist{\@tempcnta\csname ftype@#1\endcsname 608 | \multiply\@tempcnta\@xxxii\advance\@tempcnta\sixt@@n 609 | \@tfor \@tempa :=#2\do 610 | {\if\@tempa h\advance\@tempcnta \@ne\fi 611 | \if\@tempa t\advance\@tempcnta \tw@\fi 612 | \if\@tempa b\advance\@tempcnta 4\relax\fi 613 | \if\@tempa p\advance\@tempcnta 8\relax\fi 614 | }\global\count\@currbox\@tempcnta}\@fltovf\fi 615 | \global\setbox\@currbox\vbox\bgroup 616 | \def\baselinestretch{1}\small\normalsize 617 | \hsize\columnwidth \@parboxrestore} 618 | 619 | % ************************************************************************** 620 | % ***** Caption Definition ********************************************* 621 | % ************************************************************************** 622 | % some journals do not have centered captions for figures. 623 | \newif\ifc@ptionleft \c@ptionlefttrue 624 | \def\leftfigcaptions{\c@ptionlefttrue} 625 | \def\centerfigcaptions{\c@ptionleftfalse} 626 | 627 | \long\def\caption{\refstepcounter\@captype \@dblarg{\@caption\@captype}} 628 | 629 | \long\def\@caption#1[#2]#3{\par\addcontentsline{\csname ext@#1\endcsname}{#1}{% 630 | \protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}} 631 | \begingroup \@parboxrestore \normalsize 632 | \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}{#1}\par 633 | \endgroup} 634 | 635 | \def\tablestring{table} 636 | \def\figurestring{figure} 637 | 638 | % changed by GLP to allow table captions to be set to a specific maximum 639 | % width "\captionwidth", if defined. 640 | \newlength{\captionindent} 641 | \long\def\@makecaption#1#2#3{ 642 | \ifx\figurestring#3 643 | \vskip 5pt 644 | \setbox\@tempboxa\hbox{\small #1.~ #2} 645 | \ifdim \wd\@tempboxa >\hsize 646 | \setbox\@tempboxa\hbox{\small #1.~ } 647 | %\setlength\captionindent{\wd\@tempboxa} \divide\captionindent by 2 648 | %\parbox[t]{\hsize}{\small \hangindent \captionindent \hangafter=1% 649 | \parbox[t]{\hsize}{\small 650 | \unhbox\@tempboxa#2} 651 | \else \hbox 652 | to\hsize{\small\ifc@ptionleft\else\hfil\fi\box\@tempboxa\hfil} 653 | \fi 654 | \else 655 | \begin{center} 656 | \ifx\captionwidth\undefined {\small #1}\\{\small\scshape #2} 657 | \else 658 | \begin{minipage}{\captionwidth} 659 | \begin{center}{\small #1}\\{\small\scshape #2}\end{center} 660 | \end{minipage} 661 | \fi 662 | \end{center}\vskip 4pt 663 | \fi} 664 | 665 | \def\thefigure{\@arabic\c@figure} 666 | \def\fps@figure{tbp} 667 | \def\ftype@figure{1} 668 | \def\ext@figure{lof} 669 | \def\fnum@figure{\figurename\ \thefigure} 670 | %\def\figure{\@float{figure}} % GLP 671 | %\let\endfigure\end@float 672 | \@namedef{figure*}{\@dblfloat{figure}} 673 | \@namedef{endfigure*}{\end@dblfloat} 674 | 675 | \def\thetable{\@Roman\c@table} 676 | \def\fps@table{tbp} 677 | \def\ftype@table{2} 678 | \def\ext@table{lot} 679 | \def\fnum@table{TABLE~\thetable} 680 | \def\table{\@float{table}} 681 | \let\endtable\end@float 682 | \@namedef{table*}{\@dblfloat{table}} 683 | \@namedef{endtable*}{\end@dblfloat} 684 | 685 | % ************************************************************************** 686 | % ***** Header/Footer Definition *************************************** 687 | % ************************************************************************** 688 | % compute the time in hours and minutes; make new vars \timehh and \timemm 689 | \newcount\timehh\newcount\timemm\timehh=\time\divide\timehh by 60 690 | \timemm=\time\count255=\timehh\multiply\count255 by-60 691 | \advance\timemm by \count255 692 | \ifnum\timehh=12\def\apm{pm}\else 693 | \ifnum\timehh>12\def\apm{pm}\advance\timehh by-12\else 694 | \def\apm{am}\fi\fi 695 | \def\t@me{\number\timehh\,:\,\ifnum\timemm<10 0\fi\number\timemm\,\apm} 696 | 697 | % default definitions 698 | % ------------------- 699 | \def\theevenhe@d{\footnotesize\thepage \hfil \leftmark\hbox{}} 700 | \def\theoddhe@d{\hbox{}\footnotesize\rightmark \hfil \thepage} 701 | \def\theevenf@@t{} 702 | \def\theoddf@@t{} 703 | 704 | \def\theeventphe@d{\footnotesize\thepage \hfil \hbox{}} 705 | \def\theoddtphe@d{\hbox{}\footnotesize \hfil \thepage} 706 | \def\theeventpf@@t{} 707 | \def\theoddtpf@@t{} 708 | 709 | \def\theevencphe@d{} 710 | \def\theoddcphe@d{} 711 | \def\theevencpf@@t{} 712 | \def\theoddcpf@@t{} 713 | 714 | \def\internalmsg{Preliminary version for evaluation: Please do not 715 | circulate without the permission of the author(s)} 716 | \def\submittedmsg{SUBMITTED FOR PUBLICATION TO:} 717 | \def\acceptedmsg{ACCEPTED FOR PUBLICATION:} 718 | \def\inpressmsg{(IN PRESS)} 719 | \def\reprintmsg{REPRINTED FROM:} 720 | 721 | % default cover page style (optional cover page) 722 | % ---------------------------------------------- 723 | \def\ps@coverpagestyle{ 724 | \def\@oddhead{\theoddcphe@d} \def\@evenhead{\theevencphe@d} 725 | \def\@oddfoot{\theoddcpf@@t} \def\@evenfoot{\theevencpf@@t} 726 | } 727 | 728 | % default title page style (first page of paper) 729 | % ---------------------------------------------- 730 | \def\ps@titlepagestyle{ 731 | \def\@oddhead{\theoddtphe@d} \def\@evenhead{\theeventphe@d} 732 | \def\@oddfoot{\theoddtpf@@t} \def\@evenfoot{\theeventpf@@t} 733 | } 734 | 735 | % default regular page style 736 | % -------------------------- 737 | \if@twoside 738 | \def\ps@headings{ 739 | \def\@oddhead{\theoddhe@d} 740 | \def\@evenhead{\theevenhe@d} 741 | \def\@oddfoot{\theoddf@@t} \def\@evenfoot{\theevenf@@t} 742 | } 743 | \else 744 | \def\ps@headings{ 745 | \def\@oddhead{\theoddhe@d} 746 | \def\@oddfoot{\theoddf@@t} 747 | \def\@evenhead{} \def\@evenfoot{} 748 | } 749 | \fi 750 | 751 | % For draft mode (no sub-modes allowed) 752 | % ------------------------------------- 753 | \ifdr@ft 754 | \def\leftmark{\sh@rttitle}\let\rightmark\leftmark 755 | \def\theoddf@@t{\footnotesize\today---\t@me\hfil DRAFT} 756 | \def\theevenf@@t{\footnotesize DRAFT\hfil\today---\t@me} 757 | \def\theoddtpf@@t{\footnotesize\today---\t@me\hfil DRAFT} 758 | \def\theeventpf@@t{\footnotesize DRAFT\hfil\today---\t@me} 759 | \fi 760 | 761 | % For submission mode (default plus internal sub-modes allowed) 762 | % ------------------------------------------------------------- 763 | \ifsubm@t 764 | \def\leftmark{\sh@rttitle}\def\rightmark{\titl@line} 765 | \ifintern@l 766 | \def\theeventphe@d{\footnotesize\thepage \hfil \rightmark\hbox{}} 767 | \def\theoddtphe@d{\hbox{}\footnotesize\rightmark \hfil \thepage} 768 | \def\rightmark{\vbox to 0pt{\vss\hbox{\internalmsg} \hbox{\sh@rttitle}}} 769 | \def\leftmark{\vbox to 0pt{\vss\hbox{\internalmsg} 770 | \hbox{\phantom{\internalmsg}\llap{\sh@rttitle}}}} 771 | \else % put date on first page. 772 | \edef\TODAY{\uppercase{\today}} 773 | \def\theeventphe@d{\footnotesize\thepage \hfil \submittedmsg\ 774 | \@journal\@titletext, \TODAY} 775 | \def\theoddtphe@d{\footnotesize\submittedmsg\ 776 | \@journal\@titletext, \TODAY\hfil \thepage} 777 | \def\theevencphe@d{\footnotesize\hbox{} \hfil \submittedmsg\ 778 | \@journal\@titletext, \TODAY} 779 | \def\theoddcphe@d{\footnotesize\submittedmsg\ 780 | \@journal\@titletext, \TODAY\hfil \hbox{}} 781 | \fi 782 | \fi 783 | 784 | % For compressed mode (default, internal, submitted and 785 | % inpress sub-modes allowed) 786 | % ----------------------------------------------------- 787 | \ifc@mpress 788 | \def\leftmark{\sh@rttitle}\def\rightmark{\titl@line} 789 | \ifintern@l 790 | \def\theeventphe@d{\footnotesize\thepage \hfil \rightmark\hbox{}} 791 | \def\theoddtphe@d{\hbox{}\footnotesize\rightmark \hfil \thepage} 792 | \def\rightmark{\vbox to 0pt{\vss\hbox{\internalmsg} \hbox{\sh@rttitle}}} 793 | \def\leftmark{\vbox to 0pt{\vss\hbox{\internalmsg} 794 | \hbox{\phantom{\internalmsg}\llap{\sh@rttitle}}}} 795 | \fi 796 | \ifprepr@nt 797 | \edef\TODAY{\uppercase{\today}} 798 | \def\theeventphe@d{\footnotesize\thepage \hfil \submittedmsg\ 799 | \@journal\@titletext, \TODAY} 800 | \def\theoddtphe@d{\footnotesize\submittedmsg\ 801 | \@journal\@titletext, \TODAY\hfil \thepage} 802 | \def\theevencphe@d{\footnotesize\hbox{} \hfil \submittedmsg\ 803 | \@journal\@titletext, \TODAY} 804 | \def\theoddcphe@d{\footnotesize\submittedmsg\ 805 | \@journal\@titletext, \TODAY\hfil \hbox{}} 806 | \fi 807 | \ifinpr@ss 808 | \def\leftmark{\acceptedmsg\ \@journal\@titletext, \inpressmsg} 809 | \def\theeventphe@d{\footnotesize\thepage \hfil \leftmark\hbox{}} 810 | \def\theoddtphe@d{\hbox{}\footnotesize\leftmark \hfil \thepage} 811 | \fi 812 | \fi 813 | 814 | % For final (evaluate) mode (default, techreport, internal, 815 | % submitted, inpress and reprint sub-modes allowed) 816 | % --------------------------------------------------------- 817 | \ifev@l 818 | \edef\TODAY{\uppercase{\today}} 819 | \def\leftmark{\@journal\@titletext}\def\rightmark{\titl@line} 820 | \def\theeventphe@d{\footnotesize\thepage \hfil \leftmark\hbox{}} 821 | \def\theoddtphe@d{\hbox{}\footnotesize\leftmark \hfil \thepage} 822 | \if@technote % make header a little bigger 823 | \def\theevenhe@d{\small\thepage \hfil \leftmark\hbox{}} 824 | \def\theoddhe@d{\hbox{}\small\rightmark \hfil \thepage} 825 | \def\theeventphe@d{\small\thepage \hfil \leftmark\hbox{}} 826 | \def\theoddtphe@d{\hbox{}\small\leftmark \hfil \thepage} 827 | \fi 828 | \ifintern@l 829 | \def\theeventphe@d{\footnotesize\thepage \hfil \rightmark\hbox{}} 830 | \def\theoddtphe@d{\hbox{}\footnotesize\rightmark \hfil \thepage} 831 | \def\rightmark{\vbox to 0pt{\vss\hbox{\internalmsg} \hbox{\sh@rttitle}}} 832 | \def\leftmark{\vbox to 0pt{\vss\hbox{\internalmsg} 833 | \hbox{\phantom{\internalmsg}\llap{\sh@rttitle}}}} 834 | \fi 835 | \ifprepr@nt 836 | \def\leftmark{\submittedmsg\ \@journal\@titletext, \TODAY} 837 | \fi 838 | \ifinpr@ss 839 | \def\leftmark{\acceptedmsg\ \@journal\@titletext, \inpressmsg} 840 | \fi 841 | \ifrepr@nt 842 | % reset page size on second and following pages b/c no copyright info 843 | \let\oldshipout\shipout 844 | \gdef\shipout{\global\textheight 243.5mm\oldshipout} 845 | \def\theeventpf@@t{\footnotesize\hfil\@ieeecopyright\hfil} 846 | \def\theoddtpf@@t{\footnotesize\hfil\@ieeecopyright\hfil} 847 | \def\leftmark{\reprintmsg\ \@journal\@titletext} 848 | \fi 849 | \fi 850 | 851 | %% Defines the command for putting the header. footernote{TEXT} is the same 852 | %% as markboth{TEXT}{TEXT}. Here for compatibility with other style files. 853 | \def\markboth#1#2{\def\leftmark{#1}\def\rightmark{#2}} 854 | \def\footernote#1{\markboth{#1}{#1}} 855 | 856 | % ************************************************************************** 857 | % ***** Citation/Bibliography Definitions ****************************** 858 | % ************************************************************************** 859 | %% separate citations with "], [" 860 | \def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi 861 | \def\@citea{}\@cite{\@for\@citeb:=#2\do {\@citea\def\@citea{], 862 | [}\@ifundefined {b@\@citeb}{{\bf ?}\@warning {Citation `\@citeb' on 863 | page \thepage \space undefined}}% 864 | {\csname b@\@citeb\endcsname}}}{#1}} 865 | 866 | \def\@cite#1#2{[{#1\if@tempswa, #2\fi}]} 867 | 868 | %% Allow short (name-less) citations, when used in conjunction with a 869 | %% bibliography style that creates labels like \citename{, } 870 | \let\@internalcite\cite 871 | \def\cite{\def\citename##1{##1}\@internalcite} 872 | \def\shortcite{\def\citename##1{}\@internalcite} 873 | \def\@biblabel#1{\def\citename##1{##1}[#1]\hfill} 874 | 875 | \def\thebibliography#1{\section*{\refname}\footnotesize\list 876 | {\hss[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth 877 | \advance\leftmargin\labelsep \itemsep 0pt plus .5pt 878 | \usecounter{enumi}} 879 | \def\newblock{\hskip .11em plus .33em minus .07em} 880 | \sloppy\clubpenalty4000\widowpenalty4000 881 | \sfcode`\.=1000\relax 882 | \ifev@l\else\normalsize\fi %added by GLP 883 | } 884 | \let\endthebibliography=\endlist 885 | 886 | % ************************************************************************** 887 | % ***** Appendix/Appendices Definitions ******************************** 888 | % ************************************************************************** 889 | \newcounter{numappendices}\setcounter{numappendices}{0} 890 | \newif\ifappendix \appendixfalse 891 | %% appendix command for one single appendix 892 | \def\appendix{\par 893 | \appendixtrue 894 | \typeout{appendices: \arabic{numappendices}} 895 | \setcounter{section}{0}\setcounter{subsection}{0} 896 | \gdef\thesection{\Alph{section}} 897 | \ifnum \value{numappendices}>1 898 | \section*{\appendicesname} 899 | \else 900 | \section*{\appendixname} 901 | \fi 902 | \setcounter{numappendices}{0} 903 | } 904 | %% appendices command for multiple appendicies 905 | \def\appendices{\par 906 | \appendixtrue 907 | \typeout{appendices: \arabic{numappendices}} 908 | \setcounter{section}{0}\setcounter{subsection}{0} 909 | \gdef\thesection{\Alph{section}} \section*{\appendicesname} 910 | \setcounter{numappendices}{0} 911 | } 912 | \AtEndDocument{\if@filesw\immediate\write\@auxout{\string\setcounter{numappendices}{\arabic{numappendices}}}\fi} 913 | 914 | % ************************************************************************** 915 | % ***** Title Definitions ********************************************** 916 | % ************************************************************************** 917 | \def\titl@line{\sh@rttitle} %for the header at the top of the page. 918 | 919 | \def\@title{\typeout{ieee: Warning! No \noexpand\title given!}} 920 | \def\title{\@ifnextchar [{\titlea}{\titleb}}%] 921 | 922 | \def\set@title#1{\gdef\@title{#1}\global\def\set@title##1{}} 923 | \def\setsh@rttitle#1{\gdef\sh@rttitle{#1}\global\def\setsh@rttitle##1{}} 924 | \def\titlea[#1]#2{\set@title{#2}\setsh@rttitle{\uppercase{#1}}} 925 | \def\titleb#1{\set@title{#1}\setsh@rttitle{\uppercase{#1}}} 926 | 927 | \def\authorinfo#1{\let\\\relax\thanks{#1}} 928 | 929 | \ifev@l 930 | \if@technote 931 | \def\member#1{} 932 | \else 933 | \def\member#1{, \emph{#1, IEEE}} 934 | \fi 935 | \else 936 | \def\member#1{} 937 | \fi 938 | 939 | \def\and{\unskip% % \begin{tabular} 940 | \end{tabular}% 941 | \hskip 0pt plus 0.1pt% 942 | \begin{tabular}[t]{@{}c@{}}\ }% 943 | 944 | \def\@author{\typeout{ieee: Warning! No \noexpand\author given!}} 945 | \def\author{\@ifnextchar [{\authora}{\authorb}}%] 946 | \def\set@author#1{\gdef\@author{#1}\global\def\set@author##1{}} 947 | \def\settitl@line#1{\gdef\titl@line{#1}\global\def\settitl@line##1{}} 948 | \def\authora[#1]#2{\set@author{#2}\if@non\else\settitl@line{#1: \sh@rttitle}\fi} 949 | \def\authorb#1{\set@author{#1}} 950 | 951 | \def\date#1{\def\today{#1}\edef\TODAY{\uppercase{\today}}} 952 | 953 | \long\def\maketitle{% 954 | \begingroup 955 | \let\@thanks\@empty 956 | \renewcommand\thefootnote{} % the \thanks{} mark type is empty 957 | \iftitlep@ge\begin{titlepage}\@maketitlepage\@thanks\end{titlepage}% 958 | \let\@thanks\@empty\fi 959 | \thispagestyle{titlepagestyle} 960 | \if@twocolumn 961 | \if@technote 962 | %\if@twoside\newpage\cleardoublepage\else\newpage\fi% 963 | \newpage\global\@topnum\z@ 964 | \ifrepr@nt 965 | \ifx\@loginfo\undefined\typeout{ieee: Warning! No \noexpand\loginfo 966 | given!}\else\let\\\relax\thanks{\@loginfo}\fi% 967 | \fi 968 | \@maketitle 969 | \else 970 | \ifnum \col@number=\@ne 971 | \ifrepr@nt 972 | \ifx\@loginfo\undefined\typeout{ieee: Warning! No \noexpand\loginfo 973 | given!}\else\let\\\relax\thanks{\@loginfo}\fi% 974 | \fi 975 | \@maketitle 976 | \else \twocolumn[% 977 | \ifrepr@nt% 978 | \ifx\@loginfo\undefined\typeout{ieee: Warning! No \noexpand\loginfo% 979 | given!}\else\let\\\relax\thanks{\@loginfo}\fi% 980 | \fi% 981 | \@maketitle]% 982 | \fi 983 | \fi 984 | \else 985 | \newpage 986 | \global\@topnum\z@ % Prevents figures from going at top of page. 987 | \ifrepr@nt 988 | \ifx\@loginfo\undefined\typeout{ieee: Warning! No \noexpand\loginfo 989 | given!}\else\let\\\relax\thanks{\@loginfo}\fi 990 | \fi 991 | \@maketitle 992 | \fi 993 | \thispagestyle{titlepagestyle}% 994 | \@thanks 995 | \endgroup 996 | \setcounter{footnote}{0}% 997 | \global\let\thanks\relax \global\let\maketitle\relax 998 | \global\let\@maketitle\relax \global\let\@thanks\@empty 999 | \global\let\@author\@empty \global\let\@date\@empty 1000 | \global\let\@title\@empty \global\let\title\relax 1001 | \global\let\author\relax \global\let\date\relax 1002 | \global\let\and\relax 1003 | } 1004 | 1005 | \long\def\@maketitle{\unskip\newpage% 1006 | \begin{center}\blsone 1007 | \let \footnote \thanks 1008 | \if@technote 1009 | {\bfseries\@title\par}\if@non\else\vskip 1.3em{\lineskip .5em 1010 | \noindent\begin{tabular}[t]{@{}c@{}}\@author\end{tabular}}\fi\par 1011 | \else\unskip 1012 | \noindent{\Huge\@title\par}% 1013 | \if@non\else\vskip1.0em% 1014 | \noindent{\large\lineskip .5em% 1015 | \begin{tabular}[t]{@{}c@{}}\@author\end{tabular}}% 1016 | \fi\par% 1017 | \if@nvited\vskip1.0em\noindent\emph{\large(Invited Paper)}\par\fi 1018 | \fi 1019 | \ifrepr@nt 1020 | \ifx\@lognumber\undefined\typeout{ieee: Warning! No 1021 | \noexpand\pubitemident or \noexpand\lognumber 1022 | given!}\else\thanks{\@lognumber}\fi% 1023 | \fi 1024 | \end{center}\par\vskip 0.5em}% 1025 | 1026 | \long\def\@maketitlepage{\newpage% 1027 | \mbox{}\vfil 1028 | \begin{center}\blsone 1029 | \let \footnote \thanks 1030 | \if@technote 1031 | {\bfseries\@title\par}\vskip 1.3em{\lineskip .5em 1032 | \noindent\begin{tabular}[t]{@{}c@{}}\@author\end{tabular}\par} 1033 | \else 1034 | \vskip0.2em{\Huge\@title\par}\vskip1.0em% 1035 | \iftitlep@ge\vfil\fi 1036 | \noindent{\large\lineskip .5em% 1037 | \begin{tabular}[t]{@{}c@{}}\@author\end{tabular}\par}% 1038 | \fi 1039 | \end{center}\par\vfil\mbox{}} 1040 | 1041 | \def\@journal{\typeout{ieee: Warning! No \noexpand\journal given!}} 1042 | \def\journal#1{\def\@journal{\uppercase{#1}}} 1043 | 1044 | \def\@ieeecopyright{\typeout{ieee: Warning! No \noexpand\ieeecopyright given!}} 1045 | \def\ieeecopyright#1{\def\@ieeecopyright{#1}} 1046 | 1047 | \def\lognumber#1{\def\@lognumber{IEEE Log Number #1.}} 1048 | \def\pubitemident#1{\def\@lognumber{Publisher Item Identifier #1.}} 1049 | \long\def\loginfo#1{\long\def\@loginfo{\hbox{\vrule height 3ex width \z@}#1}} 1050 | 1051 | \def\sh@rttitle{} 1052 | \def\@titletext{} 1053 | \def\titletext#1{\def\@titletext{#1}} 1054 | 1055 | \def\firstpage#1{\setcounter{page}{#1}} 1056 | 1057 | % ************************************************************************** 1058 | % ***** Abstract Definition ******************************************** 1059 | % ************************************************************************** 1060 | \def\abstract{% 1061 | \if@twocolumn 1062 | \small\bfseries{\itshape\abstractname\/---}% 1063 | \else 1064 | \begin{center}\vspace{-0.8em}\small\bf\abstractname\end{center} 1065 | \quotation\small 1066 | \fi\ignorespaces} 1067 | \def\endabstract{\vspace{0.6em}\par\if@twocolumn\else\endquotation\fi 1068 | \normalsize\normalstyle} 1069 | 1070 | % ************************************************************************** 1071 | % ***** Keywords Definition ******************************************** 1072 | % ************************************************************************** 1073 | \def\keywords{\vspace{-.3em} 1074 | \if@twocolumn 1075 | \small\bfseries{\itshape\keywordsname\/---}% 1076 | \else 1077 | \begin{center}\small\bf\keywordsname\end{center}\quotation\small 1078 | \fi\ignorespaces} 1079 | \def\endkeywords{\vspace{0.6em}\par\if@twocolumn\else\endquotation\fi 1080 | \normalsize\normalstyle} 1081 | 1082 | % ************************************************************************** 1083 | % ***** Fix Section Numbering ****************************************** 1084 | % ************************************************************************** 1085 | \gdef\@punct{.\ \ } % Punctuation after run-in section heading 1086 | \def\@sect#1#2#3#4#5#6[#7]#8{% 1087 | \ifnum #2>\c@secnumdepth 1088 | \def\@svsec\@empty 1089 | \else 1090 | \refstepcounter{#1}% 1091 | \protected@edef\@svsec{% 1092 | %\ifnum #2=1\Roman{#1}.\fi\ifnum #2=2\Alph{#1}.\fi 1093 | \ifnum #2=1\thesection.\fi 1094 | \ifnum #2=2\thesubsection.\fi 1095 | \ifnum #2>2{\csname the#1dis\endcsname}\if@technote.\fi\fi \hskip .5em} 1096 | \ifnum #2=1\ifappendix\stepcounter{numappendices}\fi\fi 1097 | \fi 1098 | \@tempskipa #5\relax 1099 | \ifdim \@tempskipa>\z@ 1100 | \begingroup #6\relax 1101 | \@hangfrom{\hskip #3\relax\@svsec}{\interlinepenalty \@M #8\par} 1102 | \endgroup 1103 | \csname #1mark\endcsname{#7} 1104 | \addcontentsline{toc}{#1}{\ifnum #2>\c@secnumdepth\else 1105 | \protect\numberline{\csname the#1\endcsname}\fi#7} 1106 | \else 1107 | \def\@svsechd{#6\hskip #3\@svsec #8\@punct\csname #1mark\endcsname{#7} 1108 | \addcontentsline{toc}{#1}{\ifnum #2>\c@secnumdepth \else 1109 | \protect\numberline{\csname the#1\endcsname}\fi#7}} 1110 | \fi 1111 | \@xsect{#5}} 1112 | 1113 | \def\@ssect#1#2#3#4#5{\@tempskipa #3\relax 1114 | \ifdim \@tempskipa>\z@ 1115 | \begingroup #4\@hangfrom{\hskip #1}{\interlinepenalty \@M #5\par}\endgroup 1116 | \else \def\@svsechd{#4\hskip #1\relax #5\@punct}\fi 1117 | \@xsect{#3}} 1118 | 1119 | % ************************************************************************** 1120 | % ***** Section Definitions ******************************************** 1121 | % ************************************************************************** 1122 | \def\section{\@startsection{section}{1}{\z@}{2.0ex plus .5ex 1123 | minus .2ex}{1.0ex plus .2ex}{\centering\scshape}} 1124 | \def\subsection{\@startsection{subsection}{2}{\z@}{2.0ex plus .5ex 1125 | minus .2ex}{1.0ex plus .2ex}{\itshape}} 1126 | \if@technote 1127 | \def\subsubsection{\@startsection{subsubsection}{3}{\z@}{2.0ex plus .5ex 1128 | minus .1ex}{0pt}{\itshape}} 1129 | \else 1130 | \def\subsubsection{\@startsection{subsubsection}{3}{\z@}{2.0ex plus .5ex 1131 | minus .2ex}{1.0ex plus .2ex}{\normalstyle}} 1132 | \def\paragraph{\@startsection{paragraph}{4}{\z@}{1.0ex plus .5ex 1133 | minus .2ex}{0ex}{\normalstyle}} 1134 | \fi 1135 | 1136 | % ************************************************************************** 1137 | % ***** Special Environment Definitions ******************************** 1138 | % ************************************************************************** 1139 | \def\QED{\mbox{\rule[0pt]{1.5ex}{1.5ex}}} 1140 | \def\proof{\noindent\hspace{1em}{\it Proof: }} 1141 | \def\endproof{\hspace*{\fill}~\QED\par\endtrivlist\unskip} 1142 | \def\@begintheorem#1#2{\tmpitemindent\itemindent\topsep 0pt\normalstyle\trivlist 1143 | \item[\hskip \labelsep{\indent\it #1\ #2:}]\itemindent\tmpitemindent} 1144 | \def\@opargbegintheorem#1#2#3{\tmpitemindent\itemindent\topsep 0pt\normalstyle \trivlist 1145 | \item[\hskip\labelsep{\indent\it #1\ #2\ \normalstyle(#3)}]\itemindent\tmpitemindent} 1146 | \def\@endtheorem{\endtrivlist\unskip} 1147 | 1148 | % ************************************************************************** 1149 | % ***** Special Environment Definitions ******************************** 1150 | % ************************************************************************** 1151 | \if@twoside\else\raggedbottom\fi 1152 | 1153 | %% Definition for Big letter at the beginning of a paragraph 1154 | %% 1155 | \def\PARstart#1#2 {\begingroup\def\par{\endgraf\endgroup\lineskiplimit=0pt} 1156 | \setbox2=\hbox{\uppercase{#2} }\newdimen\tmpht \tmpht \ht2 1157 | \advance\tmpht by \baselineskip\font\hhuge=cmr10 at \tmpht 1158 | \setbox1=\hbox{{\hhuge #1}} 1159 | \count7=\tmpht \count8=\ht1\divide\count8 by 1000 \divide\count7 by\count8 1160 | \tmpht=.001\tmpht\multiply\tmpht by \count7\font\hhuge=cmr10 at \tmpht 1161 | \setbox1=\hbox{{\hhuge #1}} \noindent \hangindent1.05\wd1 1162 | \hangafter=-2 {\hskip-\hangindent \lower1\ht1\hbox{\raise1.0\ht2\copy1}% 1163 | \kern-0\wd1}\copy2\lineskiplimit=-1000pt} 1164 | 1165 | \def\PARstartCal#1#2 {\begingroup\def\par{\endgraf\endgroup\lineskiplimit=0pt} 1166 | \setbox2=\hbox{\uppercase{#2} }\newdimen\tmpht \tmpht \ht2 1167 | \advance\tmpht by \baselineskip\font\hhuge=cmsy10 at \tmpht 1168 | \setbox1=\hbox{{\hhuge #1\/}} 1169 | \count7=\tmpht \count8=\ht1\divide\count8 by 1000 \divide\count7 by\count8 1170 | \tmpht=.001\tmpht\multiply\tmpht by \count7\font\hhuge=cmsy10 at \tmpht 1171 | \setbox1=\hbox{{\hhuge #1\/}} \noindent \hangindent1.05\wd1 1172 | \hangafter=-2 {\hskip-\hangindent \lower1\ht1\hbox{\raise1.0\ht2\copy1}% 1173 | \kern-0\wd1}\copy2\lineskiplimit=-1000pt} 1174 | 1175 | \def\PARstartLyX#1{\PARstart #1} 1176 | \def\PARstartCalLyX#1{\PARstartCal #1} 1177 | 1178 | \if@technote\def\PARstart#1#2{#1#2}\fi % if technical note, disable it 1179 | \if@technote\def\PARstartCal#1#2{#1#2}\fi % if technical note, disable it 1180 | \if@technote\def\PARstartLyX#1{#1}\fi % if technical note, disable it 1181 | \if@technote\def\PARstartCalLyx#1{#1}\fi % if technical note, disable it 1182 | 1183 | % ************************************************************************** 1184 | % ***** Misc. Definitions ********************************************** 1185 | % ************************************************************************** 1186 | %Restore single spacing 1187 | \newcommand{\blsone}{\renewcommand\baselinestretch{1}% 1188 | \renewcommand\arraystretch{1.2}\setlength{\parindent}{\parindentsave}% 1189 | \normalsize} 1190 | \newcommand{\capitem}[1]{{\hspace{0.2ex}(#1)}~} 1191 | \newcommand{\insdate}{} 1192 | 1193 | % ************************************************************************** 1194 | % ***** MATH Definitions *********************************************** 1195 | % ************************************************************************** 1196 | \def\eqnarray{% 1197 | \stepcounter{equation}% 1198 | \def\@currentlabel{\p@equation\theequation}% 1199 | \global\@eqnswtrue 1200 | \m@th 1201 | \global\@eqcnt\z@ 1202 | \tabskip\@centering 1203 | \let\\\@eqncr 1204 | $$\everycr{}\halign to\displaywidth\bgroup 1205 | \hskip\@centering$\displaystyle\tabskip\z@skip{##}$\@eqnsel 1206 | &\global\@eqcnt\@ne\hskip \eqnarr@ysep\hfil${##}$\hfil 1207 | &\global\@eqcnt\tw@ \hskip \eqnarr@ysep 1208 | $\displaystyle{##}$\hfil\tabskip\@centering 1209 | &\global\@eqcnt\thr@@ \hb@xt@\z@\bgroup\hss##\egroup 1210 | \tabskip\z@skip 1211 | \cr 1212 | } 1213 | \def\endeqnarray{% 1214 | \@@eqncr 1215 | \egroup 1216 | \global\advance\c@equation\m@ne 1217 | $$\@ignoretrue 1218 | } 1219 | 1220 | % ************************************************************************** 1221 | % ***** Biography Definitions ****************************************** 1222 | % ************************************************************************** 1223 | % This is the main code for the biography environment of the IEEE 1224 | % transactions class. The previous biography code had some known 1225 | % problems which were difficult to fix. The crux of the issue was that 1226 | % the photo frame was overlaid by text when \baselinestretch>1 or when 1227 | % the biography consisted of multiple short paragraphs. 1228 | % 1229 | % The fix was done by extracting code from the excellent package: 1230 | % 'picinpar.sty' version 1.2a as of july 13, 1993 1231 | % by Friedhelm Sowa 1232 | % 1233 | % (At least most of) The bugs you find in this code were introduced 1234 | % unwittingly by myself. 1235 | % 1236 | %---------------- 1237 | % Known problems: 1238 | % 1239 | % - Don't use multiple blank lines to separate paragraphs. A single 1240 | % blank line works well, but multiple blank lines will confuse 1241 | % the code. This has something to do with the \def\par{\\\indent} 1242 | % line, but I can't think of an appropriate fix. Similarly, make 1243 | % sure the environment doesn't end with an extra blank line. 1244 | % - Don't use \samepage 1245 | % - Use \footnotemark within and \footnotetext outside the 1246 | % window-environment instead of \footnote 1247 | % - When using the epic-package load picinpar before epic 1248 | % like \documentstyle[...,picinpar,epic]{...} 1249 | % 1250 | % Counts 1251 | \newcount\br \newcount\nb \newcount\tcdsav \newcount\tcl \newcount\tcd 1252 | \newcount\tcn \newcount\cumtcl 1253 | % Dimens 1254 | \newdimen\rtside \newdimen\hpic \newdimen\vpic \newdimen\strutilg 1255 | \newdimen\picwd \newdimen\topheight \newdimen\ilg \newdimen\lpic 1256 | \newdimen\lwindowsep \newdimen\rwindowsep % VK 10 Feb 93 1257 | \lwindowsep0.5\baselineskip % " 1258 | \rwindowsep0.5\baselineskip % " 1259 | \newdimen\cumpar 1260 | % Tokens 1261 | \newtoks\twa \newtoks\la \newtoks\ra \newtoks\ha \newtoks\pictoc 1262 | % Boxes 1263 | \newbox\rawtext \newbox\holder \newbox\windowbox \newbox\wartext 1264 | \newbox\finaltext \newbox\aslice \newbox\bslice \newbox\wbox 1265 | \newbox\wstrutbox \newbox\picbox \newbox\waslice \newbox\wbslice 1266 | \newbox\fslice 1267 | % Another strut 1268 | \def\wstrut{\relax\ifmmode\copy\wstrutbox\else\unhcopy\wstrutbox\fi} 1269 | % 1270 | 1271 | \def\getpic#1{\sbox{\@tempboxa}{\includegraphics{#1}}% 1272 | \newcount\tmpcta \tmpcta=\ht\@tempboxa% 1273 | \newcount\tmpctb \tmpctb=\wd\@tempboxa% 1274 | \divide\tmpctb by 100% 1275 | \divide\tmpcta by\tmpctb% 1276 | \ifnum\tmpcta>133% 1277 | \typeout{ieee: Biography picture `#1' too tall.}% 1278 | \frame{\hbox to 25mm{\hfil\resizebox{!}{32mm}{\usebox{\@tempboxa}}\hfil}}% 1279 | \else \ifnum\tmpcta<123% 1280 | \typeout{ieee: Biography picture `#1' too wide.}% 1281 | \frame{\vbox to 32mm{\vss\hbox{\resizebox{25mm}{!}{\usebox{\@tempboxa}}}\vss}}% 1282 | \else% 1283 | \resizebox{25mm}{32mm}{\usebox{\@tempboxa}} 1284 | \fi\fi} 1285 | 1286 | \long\def\biographyLyX#1{\if@non\else\begin{biography} #1\end{biography}\fi} 1287 | 1288 | \if@non 1289 | \long\def\biography{} 1290 | \else 1291 | \long\def\biography{\@ifnextchar [{\@biographyb}{\@biographya[{\unitlength 1292 | 1mm\hbox{\framebox(25,32){}}}]}} 1293 | \fi 1294 | 1295 | \long\def\@biographyb[#1]{\@biographya[\getpic{#1}]} 1296 | 1297 | \long\def\@biographya[#1]#2{\bgroup 1298 | \footnotesize\bigskip\bigskip\bigskip\parskip=0pt\par% 1299 | \rule{0pt}{35mm}\vspace*{-35mm}\par% garantees correct page breaking 1300 | \begin{main@bio}[{#1}]% 1301 | \noindent{\bf #2}% 1302 | } 1303 | \def\endbiography{\if@non\else\end{main@bio}\egroup\fi} 1304 | 1305 | \long\def\main@bio[#1]{% #1 is the material for setting a graphic box 1306 | \vskip\parskip\everypar{} 1307 | \global\cumpar=0pt 1308 | \global\cumtcl=0 1309 | \tcd=0 1310 | \rtside=0pt 1311 | % \hpic=\linewidth 1312 | \twa={} \la={} \ra={} \ha={} 1313 | \setbox\wbox=\hbox{(} 1314 | \computeilg 1315 | \pictoc={#1} 1316 | \setbox\windowbox=\vbox{\hbox{#1}} 1317 | \picwd=\wd\windowbox 1318 | \hpic=\picwd 1319 | \vpic=\ht\windowbox\advance\vpic\dp\windowbox 1320 | \rtside=\linewidth\advance\rtside-\picwd 1321 | \setbox\picbox=\vbox{\hsize=\hpic\vbox to\vpic{\box\windowbox}}% \vfill}}% 1322 | 1323 | \vpic=\ht\picbox\advance\vpic\dp\picbox 1324 | \ifdim\rtside>0pt\advance\rtside-\rwindowsep\fi % " 1325 | \global\br=\rtside 1326 | \ifnum\picwd=0 1327 | \ifdim\vpic>0pt\picwd=\hpic 1328 | \else\vpic=\ht\picbox\advance\vpic\dp\picbox 1329 | \fi 1330 | \fi 1331 | \global\tcl=0 \lpic=0pt 1332 | \loop\global\advance\tcl by 1 \lpic=\tcl\baselineskip 1333 | \ifdim\lpic<\vpic\repeat 1334 | \vpic=\lpic 1335 | \global\cumtcl=\tcl 1336 | % 1337 | % Here we know exactly the number of indented lines and 1338 | % are able to generate the tokens for the \parshape list 1339 | % 1340 | \ifnum\br>0\ra={ 0pt \rtside}\fi 1341 | \ifnum\tcd>0\ha={ 0pt \linewidth}\fi 1342 | \ifnum\tcl<1\global\tcl=1\fi 1343 | \createparshapespec 1344 | \tcd=0 % restore the lintel 1345 | \global\tcdsav=0 1346 | % 1347 | % This is a very tricky part of the package. Some day there 1348 | % will exist a detailed documentation. 1349 | % 1350 | \def\par{\\\indent} 1351 | % 1352 | % This is where we start to pick up the paragraph(s) 1353 | % 1354 | \setbox\rawtext=\vbox\bgroup\unvbox\rawtext\unskip 1355 | \clubpenalty=0\widowpenalty=0 1356 | \ifnum\brokenpenalty<\maxdimen\else\brokenpenalty=9999\fi 1357 | \tolerance=1000 1358 | \parshape=\tcn \the\twa } 1359 | % 1360 | \def\endmain@bio{% 1361 | %\par 1362 | \global\tcd=\tcdsav 1363 | \egroup\vskip\parskip\parshape=0 % reset parshape; end \box\rawtext 1364 | \vbadness=10000 1365 | \splittopskip=0pt 1366 | % 1367 | % Now we build the boxes beside the window 1368 | % 1369 | \global\topheight=\tcl\baselineskip 1370 | \ifnum\br>0\setbox\holder=\vsplit\rawtext to\topheight\fi 1371 | \tcn=\tcl \nb=0 1372 | \ifnum\br>0\nb=\tcn\fi 1373 | % 1374 | % text on the right side 1375 | % 1376 | \ifnum\nb>0 1377 | \loop\advance\nb -1 1378 | \setbox\bslice=\vsplit\holder to\baselineskip 1379 | \prune\bslice\rtside 1380 | \setbox\wbslice=\vbox{\unvbox\wbslice\hbox 1381 | to\rtside{\box\bslice\hfil}} 1382 | \ifdim\ht\holder>0pt\repeat 1383 | \fi 1384 | %GLP add fix to make sure bio starts at top of picture 1385 | \setbox\wbslice=\vbox to\topheight{\unvbox\wbslice\vfill\vss} 1386 | % 1387 | % fixing the dimensions of the window part 1388 | % 1389 | \topheight=\ht\wbslice 1390 | % 1391 | % ship out the window material to the main vertical list 1392 | % 1393 | \setbox\windowbox=\vbox{\hbox to\linewidth{% 1394 | \vbox to\topheight{\hrule width\picwd height0pt depth0pt\vskip0pt% 1395 | \vfill\unvbox\picbox% 1396 | \ifnum\picwd>0\vfill\fi% 1397 | \vss}\ifnum\br>0\hfill\vbox{\box\wbslice}\fi}}% 1398 | % 1399 | \unvbox\windowbox% 1400 | \loop% lines below picture.... 1401 | \setbox\bslice=\vsplit\rawtext to\baselineskip 1402 | \prune\bslice\linewidth 1403 | \setbox\wbslice=\vbox{\hbox to\linewidth{\box\bslice\hfil}} 1404 | \unvbox\wbslice 1405 | \ifdim\ht\rawtext>0pt 1406 | \repeat 1407 | %GLP 1408 | %\ifnum\nb>0\topheight=\nb\baselineskip %\advance\topheight by\ilg 1409 | %\vspace*{\topheight} 1410 | %\fi 1411 | }% FINITO 1412 | % 1413 | % What else do we need? 1414 | % 1415 | \def\prune#1#2{ 1416 | % take a \vbox containing a single \hbox, 1417 | % \unvbox it, and cancel the \lastskip 1418 | % put in a \hbox of width #2 1419 | \unvbox#1 \setbox#1=\lastbox % \box#1 now is an \hbox 1420 | \ifdim\ht#1=\parskip 1421 | \setbox#1=\hbox to#2{\vrule height\parskip depth0pt width0pt\hfill} 1422 | \else\ifdim\ht#1=0pt\relax 1423 | \else\setbox#1=\hbox to#2{\wstrut\unhbox#1\unskip}\fi\fi} 1424 | % 1425 | % Here the token \twa is generated. 1426 | % It's not so difficult as it looks like. 1427 | % 1428 | \def\createparshapespec{% 1429 | \global\tcn=0 1430 | \ifnum\br>0\global\tcn=\tcl\fi 1431 | \nb=0 1432 | \ifnum\br>0\nb=\tcn\fi 1433 | \global\advance\tcn by\tcd \global\advance\tcn by1 1434 | \ifnum\tcd>0 1435 | \loop\twa=\expandafter{\the\twa\the\ha}\advance\tcd -1 1436 | \ifnum\tcd>0\repeat 1437 | \fi 1438 | \ifnum\nb>0 1439 | \loop\twa=\expandafter{\the\twa\the\ra}\advance\nb -1 1440 | \ifnum\nb>0\repeat 1441 | \fi 1442 | \global\twa=\expandafter{\the\twa 0pt \the\linewidth}} 1443 | % 1444 | \def\computeilg{% compute the interline glue 1445 | \tcl=0\ilg=0pt\strutilg=0pt 1446 | \loop\setbox\wbox=\hbox{\char\tcl} 1447 | \ifdim\ht\wbox>\ilg\ilg=\ht\wbox\fi 1448 | \ifdim\dp\wbox>\strutilg\strutilg=\dp\wbox\fi 1449 | \advance\tcl by 1 1450 | \ifnum\tcl<128\repeat 1451 | \ht\wbox=\ilg 1452 | \dp\wbox=\strutilg 1453 | \strutilg=\ht\wbox %\advance\strutilg by\ilg 1454 | \ifdim\strutilg>\baselineskip 1455 | \typeout{character with height greater baselineskip found in font} 1456 | \typeout{baselineskip changed to 1.5 of that height!} 1457 | \baselineskip=1.5\strutilg 1458 | \fi 1459 | \global\ilg=\baselineskip 1460 | \global\advance\ilg-\ht\wbox \global\advance\ilg-\dp\wbox 1461 | \strutilg=\ht\wbox \advance\strutilg by\ilg 1462 | \setbox\wstrutbox=\hbox{\vrule height\strutilg depth\dp\wbox width0pt}} 1463 | 1464 | 1465 | % the following code from version.sty by Stephen Bellantoni 1990, loosely 1466 | % based on "annotation.sty" by Tom Hofmann. Used to exclude "biography" from 1467 | % anonymous mode. 1468 | \begingroup 1469 | \catcode`@=11\relax% 1470 | \catcode`{=12\relax\catcode`}=12\relax% 1471 | \catcode`(=1\relax \catcode`)=2\relax% 1472 | \gdef\glpinclude#1(% 1473 | \expandafter\gdef\csname #1\endcsname% 1474 | ()% 1475 | \expandafter\gdef\csname end#1\endcsname% 1476 | ()% 1477 | )% 1478 | \gdef\glpexclude#1(% 1479 | \expandafter\gdef\csname #1\endcsname% 1480 | (\@bsphack\catcode`{=12\relax\catcode`}=12\relax\csname #1@NOTE\endcsname)% 1481 | \long\expandafter\gdef\csname #1@NOTE\endcsname ##1\end{#1}% 1482 | (\csname #1END@NOTE\endcsname)% 1483 | \expandafter\gdef\csname #1END@NOTE\endcsname% 1484 | (\@esphack\end(#1))% 1485 | )% 1486 | \endgroup 1487 | 1488 | %------- 1489 | \def\@confplacedate{\typeout{ieee: Warning! No \noexpand\confplacedate set!} 1490 | \bfseries `confplacedate' needs to be set. For example, to: Stanford, CA, USA, 1491 | September 29--30, 1991} 1492 | \def\confplacedate#1{\def\@confplacedate{#1}} 1493 | 1494 | %%%%%%%%%%%%%%%%%%%%%%%%% End of ieee.cls %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1495 | -------------------------------------------------------------------------------- /doc/ieeefig.sty: -------------------------------------------------------------------------------- 1 | % ===================================================================== 2 | % --------------------------------------------------------------------- 3 | % 4 | % XX XX XX X 5 | % X X X 6 | % XX XXX XXX XXX XXX XX XXX XXXX XXX X X 7 | % X X X X X X X X X X X X X X X 8 | % X XXXXX XXXXX XXXXX X X X X XXX X X X 9 | % X X X X X X X X XX X X X X X 10 | % XXX XXX XXX XXX XXX XXX XXXX XX XXXX XX XXXX 11 | % X X 12 | % XXXX XXXX 13 | % --------------------------------------------------------------------- 14 | % ===================================================================== 15 | % ieeefig.sty --- For managing figures in LaTeX2e documents. 16 | % --- Written by Gregory Plett, Sept 1997 17 | % ===================================================================== 18 | % The following macros provide a systematic yet flexible method for 19 | % incorporating figures in a LaTeX2e document. They are especially well 20 | % suited for paper preparation using the ieee.cls and psfrag 21 | % style. Each figure has its own .tex file. When used with psfrag, it 22 | % will also have its own .eps file. In the main text, 23 | % \figdef{figure} 24 | % loads the file `figure.tex', which contains all the LaTeX commands 25 | % format that particular figure. (The figure will be centered) 26 | % To insert an EPS file, `figure.tex' should contain the 27 | % \inserteps{figure.eps} command, and any psfrag commands required 28 | % to format that figure. 29 | % Options defined below control the formating of figures. 30 | % If using psfrag, the figure.tex file will be of the form: 31 | % \begin{psfrags} \psfrag{xx}{yy} ... \inserteps{figure.eps} 32 | % \end{psfrags} 33 | % ===================================================================== 34 | % ********************************************************************* 35 | % ****** ************************************* 36 | % ***** LaTeX2e INITIALIZATION ************************************ 37 | % ****** ************************************* 38 | % ********************************************************************* 39 | \NeedsTeXFormat{LaTeX2e}[1993/11/11] % Oldest acceptable version of LaTeX2e 40 | \ProvidesPackage{ieeefig}[1996/01/26] % Name of package provided, date 41 | 42 | %====================== Initial Code & Declaration of Options 43 | \newif\iffigdr@ft \figdr@ftfalse % defines draft or regular mode. 44 | 45 | \newif\iffigframe \figframefalse % if figures are framed, w/ labels 46 | \newif\ifshowfigs \showfigstrue % if false, only figure name shown. 47 | \newif\ifdraftfigs \draftfigsfalse % if true, blank space left for fig. 48 | \newif\ifsc@leoverride % override scale when doing figs. 49 | 50 | \DeclareOption{draft}{\figdr@fttrue\typeout{ieeefig: Draft option selected.}} 51 | \DeclareOption{final}{\figdr@ftfalse\typeout{ieeefig: Final option selected.}} 52 | \DeclareOption{blank}{\draftfigstrue\typeout{ieeefig: Blank option selected.}} 53 | \DeclareOption{noblank}{\draftfigsfalse\typeout{ieeefig: Blank option de-selected.}} 54 | \DeclareOption{hide}{\showfigsfalse\typeout{ieeefig: Hide option selected.}} 55 | \DeclareOption{show}{\showfigstrue\typeout{ieeefig: Show option selected.}} 56 | \DeclareOption{frame}{\figframetrue\typeout{ieeefig: Frame option selected.}} 57 | \DeclareOption{noframe}{\figframefalse\typeout{ieeefig: Frame option de-selected.}} 58 | 59 | \ProcessOptions 60 | \RequirePackage[final]{graphics} 61 | \RequirePackage{graphicx,ifthen} 62 | 63 | \newcommand{\figw@rning}[1]{\typeout{Warning: #1\space on page \thepage}} 64 | %====================================================================== 65 | % LaTeX input file and is input by the figure commands. The figure can 66 | % be "larger than life" and these routines will scale the figures by 67 | % a constant amount to fit into the paper or book. 68 | % 69 | % \setfigscale{scale} Changes the scaling factor applied to each figure 70 | % (which is initialized to 1). If changed inside the main LaTeX 71 | % code, then the new scale will apply to all figures from that 72 | % point on. If changed within the figure file, it will apply only 73 | % to that figure. 74 | % 75 | % \figdef[dim]{figname} This command inputs a figure 76 | % TeX file of name "figname.tex". If the file "figname.tex" does 77 | % not exist, a warning is output and the figure name is displayed 78 | % in a framed box. A warning is also output if an eps file of name 79 | % "figname.eps" does not exist. The optional dimension [dim] is 80 | % the vertical space skipped when draftfigs is true. 81 | % 82 | % \scalefig[dim]{figname}{scale} This is the same as \figdef, except 83 | % that it overrides any scaling in the "figname.tex" file. 84 | % 85 | % \showfigsfalse This command will cause figdef to print the figure's 86 | % name in a framed box instead of including the figure. Saves 87 | % time. Note that the figures are "short" since they are just 88 | % the height of the text. 89 | % \showfigstrue (default) figdef returns to the regular mode of display- 90 | % ing the figures, not just the name. 91 | % 92 | % \figframetrue This command will cause figdef to draw a frame around 93 | % the figure so that you can adjust the bounding box. Also prints 94 | % the figure name in the margin of the page. 95 | % \figframefalse (default) Turns off the figure framing. 96 | % 97 | % \draftfigstrue Leaves an empty space *of correct vertical dimension* 98 | % on the page for the figure. (speeds up LaTeX since it does not 99 | % need to search for the figure on the disk). 100 | % \draftfigsfalse (default) Draws the figure instead. 101 | % 102 | % Use \renewcommand{\figfontsize}{\scriptsize}, for example, to change the 103 | % default font size for the figure labels. 104 | % Using \renewcommand{\figfontstyle}{\sffamily}, for example, to change the 105 | % default figure font style to sans-serif. 106 | %====================================================================== 107 | \newcommand{\setfigscale}[1]{\gdef\figsc@le{#1}} 108 | \setfigscale{1} 109 | \newsavebox{\figb@x} 110 | \newdimen\htpl@sdp 111 | \newif\ifdr@fteps 112 | \newdimen\b@xwidth 113 | \def\figfontsize{\footnotesize} 114 | \def\figfontstyle{\rmfamily} 115 | 116 | \newcommand{\d@fig}[2]{\begingroup\figfontsize\reset@font\figfontstyle% 117 | \b@xwidth=\hsize \advance\b@xwidth by -9\arrayrulewidth 118 | \xdef\figh@ight{#2}% 119 | \xdef\figscales@ve{\figsc@le}% save the global scale factor. 120 | \IfFileExists{#1.tex}{% 121 | \ifsc@leoverride\xdef\figsc@le{\sc@lefig}\fi% 122 | % 123 | \ifshowfigs% 124 | % show figs true... 125 | \ifdraftfigs% 126 | % show figs true and draft figs true... 127 | \vspace*{-2\arrayrulewidth}\frame{\vbox to #2{\vss \hbox to \b@xwidth{\hfill #1 \hfill}\vss}}% 128 | \else% 129 | % show figs true and draft figs false... 130 | \iffigframe% 131 | % showfigstrue, draftfigsfalse, figframetrue... 132 | \vspace*{-2\arrayrulewidth}\hfill\frame{\let\par\relax\input{#1}}\hfill% 133 | \sbox{\figb@x}{\let\par\relax\input{#1}}% read box to get the height! 134 | \htpl@sdp=\ht\figb@x\advance\htpl@sdp by \dp\figb@x% 135 | \smash{\rlap{\vbox{\hbox{\footnotesize\quad\tt{ht=}\the\htpl@sdp\typeout{#1: \the\htpl@sdp}}% 136 | \hbox{\footnotesize \quad #1}}}}% 137 | \else% 138 | % showfigstrue, draftfigsfalse, figframefalse... 139 | \iffigdr@ft% 140 | % showfigstrue, draftfigsfalse, figframefalse, draft mode true... 141 | \hbox to \hsize{\hss\let\par\relax\input{#1}\hss\smash{\rlap{\footnotesize\quad#1}}}% 142 | \else% 143 | % showfigstrue, draftfigsfalse, figframefalse, draft mode false... 144 | %\hbox to \hsize{\hss\let\par\relax\input{#1}\hss\smash{\rlap{}}}% 145 | \noindent{\hfill\let\par\relax\input{#1}\hfill}% 146 | %\hbox to \hsize{\hss\let\par\relax\input{#1}\hss}% 147 | %\centerline{\let\par\relax\input{#1}}% 148 | \fi% end \iffigdr@ft 149 | \fi% end \iffigframe 150 | \fi% end \ifdraftfigs 151 | \else% 152 | % show figs is false... 153 | \centerline{\fbox{#1}}% 154 | \fi% end \ifshowfigs 155 | }{% 156 | \figw@rning{#1.tex not found!}% 157 | \centerline{\frame{\vbox to #2{\vss\hbox{\hskip 1in\relax #1 (missing from disk!)\hskip 1in}\vss}}}% 158 | }% end IfFileExists #1.tex 159 | \xdef\figsc@le{\figscales@ve} 160 | \ifdr@fteps% 161 | \vspace*{0.05in}% 162 | \centerline{\large \bf This is a draft figure!}% 163 | \fi% 164 | \endgroup 165 | }%end \fgdf 166 | 167 | %====================================================================== 168 | % \inserteps[options]{epsfilename} 169 | % The specified eps file will be inserted into a figdef environment 170 | % (such as when using psfrag). If the file does not exist, a box is 171 | % left on the page, of height specified by the \figdef command, with 172 | % a warning message. The "options" can be any options supported by 173 | % the \includegraphics command. 174 | % 175 | % A recommended variant of this command is: 176 | % \inserteps[trim=a b c d]{filename.eps}. This is especially useful 177 | % when using \psfrags if the frags fall outside the original bounding 178 | % box of the eps file. The parameters a,b,c,d are the amount to trim 179 | % from the left, bottom, right and top of the figure, respectively. 180 | % Their units are in points. To see if you need to modify the bounding 181 | % box in this way, use the \figframetrue command. (If the arguments a,b, 182 | % c, or d are negative, then the bounding box is expanded. This is 183 | % probably the most common situation). 184 | % 185 | % \insertdrafteps{epsfilename} 186 | % The specified file is inserted just as above. Below the figure, and 187 | % centered on the page is a framed message stating that the figure is 188 | % a draft figure. 189 | %====================================================================== 190 | \def\insert@eps[#1]#2{\IfFileExists{#2}{\ifsc@leoverride% 191 | \includegraphics[scale=\sc@lefig,#1,clip=]{#2}\else% 192 | \includegraphics[scale=\figsc@le,#1,clip=]{#2}\fi}{% 193 | \figw@rning{file #2 is missing!}\vspace*{-2\arrayrulewidth}% 194 | \frame{\vbox to \figh@ight{\vss \hbox{\mbox{\qquad #2 195 | (missing from disk)\qquad}}\vss}}}\global\dr@ftepsfalse} 196 | 197 | \def\inserteps{\@ifnextchar [{\insert@eps}{\insert@eps[angle=0]}} 198 | 199 | \newcommand{\insertdrafteps}[1]{\inserteps{#1}\global\dr@ftepstrue} 200 | 201 | \def\figdef{\@ifnextchar [{\figdefa}{\figdefa[0.5in]}} 202 | \def\figdefa[#1]#2{\sc@leoverridefalse\d@fig{#2}{#1}} 203 | \def\scalefig{\@ifnextchar [{\@scalefiga}{\@scalefiga[0.5in]}} 204 | \def\@scalefiga[#1]#2#3{\xdef\sc@lefig{#3}\sc@leoverridetrue\d@fig{#2}{#1}} 205 | 206 | -------------------------------------------------------------------------------- /doc/mostfreq.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobflagg/Topic-Networks/d7bd6d283a7674a9aff2182c118087a61f32f0e5/doc/mostfreq.pdf -------------------------------------------------------------------------------- /doc/overlap-network.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobflagg/Topic-Networks/d7bd6d283a7674a9aff2182c118087a61f32f0e5/doc/overlap-network.pdf -------------------------------------------------------------------------------- /doc/topic-network.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobflagg/Topic-Networks/d7bd6d283a7674a9aff2182c118087a61f32f0e5/doc/topic-network.pdf -------------------------------------------------------------------------------- /doc/topic-networks.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobflagg/Topic-Networks/d7bd6d283a7674a9aff2182c118087a61f32f0e5/doc/topic-networks.pdf -------------------------------------------------------------------------------- /doc/topic-networks.tex: -------------------------------------------------------------------------------- 1 | \documentclass[% 2 | %draft, 3 | %submission, 4 | %compressed, 5 | final, 6 | % 7 | %technote, 8 | %internal, 9 | %submitted, 10 | %inpress, 11 | %reprint, 12 | % 13 | %titlepage, 14 | notitlepage, 15 | %anonymous, 16 | narroweqnarray, 17 | inline, 18 | %twoside, 19 | %invited, 20 | ]{ieee} 21 | \usepackage{graphicx} 22 | \usepackage{hyperref} 23 | \usepackage{listings} 24 | \lstset{ 25 | language=R, 26 | basicstyle=\scriptsize\ttfamily, 27 | commentstyle=\ttfamily\color{gray}, 28 | numbers=left, 29 | numberstyle=\ttfamily\color{gray}\footnotesize, 30 | stepnumber=1, 31 | numbersep=5pt, 32 | backgroundcolor=\color{white}, 33 | showspaces=false, 34 | showstringspaces=false, 35 | showtabs=false, 36 | frame=single, 37 | tabsize=2, 38 | captionpos=b, 39 | breaklines=true, 40 | breakatwhitespace=false, 41 | title=\lstname, 42 | escapeinside={}, 43 | keywordstyle={}, 44 | morekeywords={} 45 | } 46 | 47 | 48 | \lstloadlanguages{R} 49 | \newcommand{\latexiie}{\LaTeX2{\Large$_\varepsilon$}} 50 | \begin{document} 51 | 52 | \nocite{big} 53 | \nocite{Sh:1} 54 | \nocite{small} 55 | 56 | \title[Topic Networks]{ 57 | Topic Networks \\ 58 | {\Large A mini project for Social Network Analysis} \\ 59 | {\large Final Version} 60 | } 61 | %\author[Bob Flagg]{Bob Flagg} 62 | 63 | %\firstpage{} 64 | 65 | 66 | \maketitle 67 | % ---------------------------------------------------------------------------- % 68 | % Introduction % 69 | % ---------------------------------------------------------------------------- % 70 | \section{Introduction} 71 | 72 | \PARstart Automatic text summarization is a challenging problem whose solution 73 | would allow users to browse large document collections and quickly view highlights 74 | and drill down for details. 75 | %would provide a valuable tool in dealing with the {\it information explosion} 76 | %by allowing users to browse large document collections and quickly view highlights 77 | %and drill down for details. 78 | In this project we attempt to bring the power of social network analysis to bear on 79 | this problem by developing 80 | a new approach to summarizing document collections, using topic models and bipartite 81 | graphs. 82 | 83 | Our method first builds a topic model for a document collection using 84 | \href{http://en.wikipedia.org/wiki/Latent_Dirichlet_allocation}{Latent Dirichlet allocation}\cite{lda}. 85 | This topic model naturally defines a \href{http://en.wikipedia.org/wiki/Bipartite_graph}{bipartite graph}\cite{bipartite} 86 | between documents and the topics that appear in 87 | them. The bipartite graph is converted into a network of topics by linking 88 | topics if they appear in the same document. By analyzing a simple sample corpus, we explore 89 | properties of these {\em topic networks} in hopes that they will 90 | provide insights useful in summarizing the 91 | underlying document collection. 92 | 93 | 94 | \section{A Simple Example} 95 | 96 | \PARstart To demonstrate topic networks we will use a simple example consisting of 97 | texts of 102 speeches given by Barack Obama prior to his 2009 Inauguration scraped from 98 | \href{http://obamaspeeches.com/}{obamaspeeches.com}\cite{speeches} on April 12, 2013. 99 | We'll use the {\bf R} programming language\cite{cran} for this demo. All the steps 100 | are reproduced below and in an R source file available on 101 | \href{https://github.com/bobflagg/Topic-Networks}{GitHub}\cite{github}. We have 102 | borrowed a lot of ideas from Solomon Messing's blog post\cite{messing} on 103 | working with bipartitie/affiliation networks in {\bf R}. 104 | 105 | \subsection{The Document-Term Matrix} 106 | 107 | \PARstart If the path to the directory containing the texts of Obama speeches is in 108 | the variable {\tt corpus.source}, then we can build the corpus and document-term matrix 109 | with the following commands: 110 | 111 | \begin{verbatim} 112 | 113 | # Load the text mining package 114 | require(tm, quietly=TRUE) 115 | # Build the corpus. 116 | corpus.source <- DirSource(corpus.directory, 117 | encoding="UTF-8") 118 | corpus <- Corpus(corpus.source) 119 | corpus.copy <-corpus 120 | # Build the document term matrix. 121 | corpus.dtm <- DocumentTermMatrix( 122 | corpus, 123 | control = list( 124 | stemming = TRUE, 125 | stopwords = TRUE, 126 | minWordLength = 3, 127 | removeNumbers = TRUE, 128 | removePunctuation = TRUE 129 | ) 130 | ) 131 | \end{verbatim} 132 | 133 | \subsection{Frequent Words} 134 | 135 | \PARstart To gain some preliminary insight into this corpus, we'll 136 | look at a bar chart of most frequent words and a word cloud. 137 | 138 | \begin{verbatim} 139 | 140 | # Load required packages: 141 | require(RColorBrewer, quietly=TRUE) 142 | # Sort terms by frequency: 143 | word.freq <- sort(col_sums(corpus.dtm), 144 | decreasing=TRUE) 145 | # barplot with the top 20 most frequent terms 146 | top.terms <- head(word.freq, n=20) 147 | # complete the stems and fix missing values and errors: 148 | completions <- stemCompletion(names(top.terms), 149 | dictionary=corpus.copy, type="prevalent") 150 | completions<-ifelse(completions == "", names(top.terms), 151 | completions) 152 | names(top.terms) <-completions 153 | names(top.terms)[10] <-"every" 154 | pdf("mostfreq.pdf") 155 | op <- par(mar = c(4,6.1,.1,.2)) 156 | barplot(top.terms, las=2, horiz=TRUE) 157 | dev.off() 158 | # wordcloud 159 | pal2 <- brewer.pal(8,"Dark2") 160 | top.terms <- head(word.freq, n=1200) 161 | completions <- stemCompletion(names(top.terms), 162 | dictionary=corpus.copy, type="prevalent") 163 | completions<-ifelse(completions == "", names(top.terms), 164 | completions) 165 | names(top.terms) <-completions 166 | pdf("wordcloud.pdf") 167 | par(mar = c(0,0,0,0)) 168 | wordcloud( 169 | words=names(top.terms), 170 | freq=top.terms, 171 | min.freq=20, 172 | random.order=F, 173 | colors=pal2, 174 | rot.per=.15 175 | ) 176 | dev.off() 177 | \end{verbatim} 178 | 179 | \begin{figure}[ht!] 180 | \centering 181 | \includegraphics[width=90mm]{mostfreq.pdf} 182 | \caption{Most frequent words} 183 | \label{fig:barchart} 184 | \end{figure} 185 | 186 | \begin{figure}[ht!] 187 | \centering 188 | \includegraphics[width=90mm]{wordcloud.pdf} 189 | \caption{Wordcloud: frequency $\geq$ 20} 190 | \label{fig:wordcloud} 191 | \end{figure} 192 | 193 | \subsection{The Topic Model} 194 | 195 | \PARstart Before building a topic model, we want to filter out ``unimportant'' words from 196 | the corpus. For this we will use the tf-idf matrix. 197 | 198 | \begin{verbatim} 199 | # Build the tf-idf matrix: 200 | term.tfidf <- tapply( 201 | corpus.dtm$v/row_sums(corpus.dtm)[corpus.dtm$i], 202 | corpus.dtm$j, mean) * 203 | log2(nDocs(corpus.dtm)/col_sums(corpus.dtm > 0)) 204 | # Filter out "unimportant" terms: 205 | dtm <- corpus.dtm[,term.tfidf >= 0.01] 206 | dtm <- dtm[row_sums(dtm) > 0,] 207 | \end{verbatim} 208 | 209 | Now we build the topic model and collect collect relevant data in a data frame. 210 | 211 | \begin{verbatim} 212 | require(topicmodels, quietly=TRUE) 213 | # Build a topic model: 214 | corpus.tm <- LDA(dtm, k = 22) 215 | corpus.tm.terms <- terms(corpus.tm, 3) 216 | corpus.tm.topics <- topics(corpus.tm, 4) 217 | topic.labels <- apply(corpus.tm.terms, 2, 218 | function(x) paste(x, collapse=", ")) 219 | document.labels <- colnames(corpus.tm.topics) 220 | dt.df <- data.frame( 221 | document=rep(document.labels, each=4), 222 | topic=as.vector(corpus.tm.topics) 223 | ) 224 | # Replace doucment labels with numbers: 225 | dt.df$document <- as.numeric(gsub(".txt","", 226 | dt.df$document)) 227 | # Order the data according to document number: 228 | dt.df <- dt.df[order(dt.df$document),] 229 | \end{verbatim} 230 | 231 | 232 | \subsection{The Document-Topic Network} 233 | \PARstart The first network we'll consider has two modes: documents and topics. 234 | The {\tt igraph} package allows us to construct a network from an incidence 235 | matrix as follows. 236 | 237 | \begin{verbatim} 238 | require(igraph, quietly=TRUE) 239 | # Build the incidence matrix: 240 | dt.matrix <- as.matrix(table(dt.df)) 241 | # Build the document-topic network: 242 | dt.network <- graph.incidence(dt.matrix) 243 | 244 | 245 | corpus.tm <- LDA(dtm, k = 22) 246 | corpus.tm.terms <- terms(corpus.tm, 3) 247 | corpus.tm.topics <- topics(corpus.tm, 4) 248 | topic.labels <- apply(corpus.tm.terms, 2, 249 | function(x) paste(x, collapse=", ")) 250 | document.labels <- colnames(corpus.tm.topics) 251 | dt.df <- data.frame( 252 | document=rep(document.labels, each=4), 253 | topic=as.vector(corpus.tm.topics) 254 | ) 255 | # Replace doucment labels with numbers: 256 | dt.df$document <- as.numeric(gsub(".txt","", 257 | dt.df$document)) 258 | # Order the data according to document number: 259 | dt.df <- dt.df[order(dt.df$document),] 260 | \end{verbatim} 261 | 262 | Figure \ref{fig:dtn}, which was generated with the code below, 263 | shows the document-topic network, with 264 | topic nodes displayed as large green dots to distinquish them from 265 | document nodes. 266 | 267 | 268 | \begin{verbatim} 269 | n.docs <- nrow(dt.matrix) 270 | n.topics <- ncol(dt.matrix) 271 | n.vertices <- n.docs + n.topics 272 | V(dt.network)$color[1:n.docs] <- 273 | rgb(1,0,0,.4) 274 | V(dt.network)$color[(n.docs+1):n.vertices] <- 275 | rgb(0,1,0,.5) 276 | V(dt.network)$label <- NA 277 | V(dt.network)$size[1:n.docs] <- 2 278 | V(dt.network)$size[(n.docs+1):n.vertices] <- 6 279 | E(dt.network)$width <- .5 280 | E(dt.network)$color <- rgb(.5,.5,0,.4) 281 | pdf("dtn.pdf") 282 | plot(dt.network, 283 | layout=layout.fruchterman.reingold) 284 | dev.off() 285 | \end{verbatim} 286 | 287 | 288 | \begin{figure} 289 | \centering 290 | \includegraphics[width=90mm]{dtn.pdf} 291 | \caption{Document-Topic Network} 292 | \label{fig:dtn} 293 | \end{figure} 294 | 295 | 296 | \subsection{The Topic Network} 297 | 298 | \PARstart The topic network is the one of most interest to us. To build it 299 | we create its adjacency matrix by multiplying the transpose of the document-topic 300 | matrix with itself. 301 | 302 | \begin{verbatim} 303 | # Create the topic network: 304 | topic.network.matrix <- t(dt.matrix) %*% 305 | dt.matrix 306 | topic.network <- graph.adjacency( 307 | topic.network.matrix, mode = "undirected") 308 | \end{verbatim} 309 | 310 | Figure \ref{fig:topic-network}, which was created with the code below, shows the 311 | topic network, with 312 | topic nodes labelled by the three most probable terms in the corresponding 313 | topic distribution. 314 | 315 | \begin{verbatim} 316 | E(topic.network)$weight <- 317 | count.multiple(topic.network) 318 | topic.network <- simplify(topic.network) 319 | # Set vertex attributes 320 | V(topic.network)$label <- topic.labels 321 | V(topic.network)$label.color <- rgb(0,0,0,1) 322 | V(topic.network)$label.cex <- .75 323 | V(topic.network)$size <- 8 324 | V(topic.network)$color <- rgb(0,1,0,.6) 325 | # Set edge gamma according to edge weight 326 | egam <- (log(E(topic.network)$weight)+.3)/ 327 | max(log(E(topic.network)$weight)+.3) 328 | E(topic.network)$color <- rgb(.5,.5,0,egam) 329 | pdf("topic-network.pdf") 330 | plot(topic.network, layout=layout.kamada.kawai) 331 | dev.off() 332 | \end{verbatim} 333 | 334 | 335 | \begin{figure} 336 | \centering 337 | \includegraphics[width=90mm]{topic-network.pdf} 338 | \caption{Topic Network} 339 | \label{fig:topic-network} 340 | \end{figure} 341 | 342 | As Figure~\ref{fig:topic-network} shows, the topic network is very busy, suggesting 343 | that we've not done a good job choosing the most import topics for each document. 344 | In fact, as the code below shows, the average degree, at $19.3$, is very high. 345 | 346 | \begin{verbatim} 347 | # Compute the average degree of our network: 348 | degrees <- V(topic.network)$degree 349 | topic.network.average.degree <- sum(degrees) / 350 | length(V(topic.network)) 351 | \end{verbatim} 352 | 353 | \noindent This problem can probably be fixed if rather than taking the top 4 topics for each 354 | document in the document-topic network, we were to choose only those topics whose 355 | probability of appearing in the document is above a certain threshold. We plan to 356 | investigate that approach but don't have time to pursue it here. 357 | 358 | Once we've solved the previous problem, we plan to systematically investigate the connections between important 359 | properties of the topic network and the underlying corpus. As an example, consider 360 | centrality: 361 | 362 | \begin{verbatim} 363 | # Betweenness centrality 364 | V(topic.network)$btwcnt <- betweenness(topic.network) 365 | V(topic.network)$label[order(V(topic.network)$btwcnt)] 366 | \end{verbatim} 367 | 368 | \noindent This measure suggests that the most central topics in the corpus are 369 | \begin{itemize} 370 | \item tonight, mccain, page 371 | \item religion, bankruptcy, christian 372 | \item oil, fuel, auto 373 | \item iraq, iraqi, troop 374 | \end{itemize} 375 | 376 | 377 | \subsection{The Overlap Network} 378 | 379 | \PARstart Another interesting view of this data takes into account the 380 | percent overlap between topics, which gives rise to a directed network. 381 | To create this graph, we divide each row by the diagonal to get the 382 | adjacency matrix. 383 | 384 | \begin{verbatim} 385 | overlap.matrix <- topic.network.matrix / 386 | diag(topic.network.matrix) 387 | overlap.network <- graph.adjacency( 388 | overlap.matrix, weighted=T) 389 | \end{verbatim} 390 | 391 | We use the density plot show in Figure~\ref{fig:density} to choose 392 | a reasonable cut-off value for removing some noise in the edges before plotting this 393 | network. 394 | 395 | \begin{verbatim} 396 | pdf("density.pdf") 397 | plot(density(overlap.matrix), main=NA, xlab=NA) 398 | dev.off() 399 | overlap.matrix[overlap.matrix < 0.2] <- 0 400 | overlap.network <- graph.adjacency(overlap.matrix, 401 | weighted=T) 402 | overlap.network <- simplify(overlap.network, 403 | remove.multiple=FALSE, remove.loops=TRUE) 404 | overlap.network$layout <- layout.kamada.kawai( 405 | overlap.network) 406 | V(overlap.network)$label <- topic.labels 407 | tkplot(overlap.network) 408 | overlap.network$layout <- tkplot.getcoords(1) 409 | \end{verbatim} 410 | 411 | 412 | The final step to display this network in a way to make the 413 | important properties visable requires some manual work. We'll use the 414 | tkplot gui tool to help us layout nodes so that labels are clearly 415 | visible. Once we're done arranging nodes, the layout can be saved 416 | using {\tt tkplot.getcoords(1)}: 417 | 418 | 419 | \begin{verbatim} 420 | overlap.network$layout <- layout.kamada.kawai( 421 | overlap.network) 422 | V(overlap.network)$label <- topic.labels 423 | tkplot(overlap.network) 424 | overlap.network$layout <- tkplot.getcoords(1) 425 | \end{verbatim} 426 | 427 | \noindent Finally, we set a number of properties to improve the 428 | visualization: 429 | 430 | 431 | \begin{verbatim} 432 | V(overlap.network)$label.color <- rgb(0,0,.2,.6) 433 | V(overlap.network)$label.cex <- .75 434 | V(overlap.network)$size <- 6 435 | #V(topic.network)$frame.color <- NA 436 | V(overlap.network)$color <- rgb(0,1,0,.6) 437 | 438 | # Set edge gamma according to edge weight 439 | egam <- (E(overlap.network)$weight+.1)/max( 440 | E(overlap.network)$weight+.1) 441 | E(overlap.network)$color <- rgb(.5,.5,0,egam) 442 | E(overlap.network)$arrow.size <- .3 443 | V(overlap.network)$label.cex <- 444 | degree(overlap.network)/(max(degree( 445 | overlap.network)/2))+ .3 446 | pdf("overlap-network.pdf") 447 | plot(overlap.network) 448 | dev.off() 449 | \end{verbatim} 450 | 451 | \begin{figure} 452 | \centering 453 | \includegraphics[width=90mm]{density.pdf} 454 | \caption{Density Plot} 455 | \label{fig:density} 456 | \end{figure} 457 | 458 | \noindent Figure~\ref{fig:overlap-network} shows the results. 459 | 460 | \begin{figure} 461 | \centering 462 | \includegraphics[width=90mm]{overlap-network.pdf} 463 | \caption{Topic Overlap Network} 464 | \label{fig:overlap-network} 465 | \end{figure} 466 | 467 | 468 | 469 | %% 470 | % ---------------------------------------------------------------------------- % 471 | % Conclusions % 472 | % ---------------------------------------------------------------------------- % 473 | \section{Conclusions} 474 | 475 | \PARstart Our simple example suggests that topic networks may be useful in analyzing 476 | document collections. However, we have only scratched the surface 477 | here and much more work is required to confirm this hypothesis as well as to investigate 478 | properties of topic networks and applications to document collection summarization. 479 | 480 | \begin{thebibliography}{1} 481 | 482 | \bibitem{bipartite} 483 | From Wikipedia, the free encyclopedia \\ 484 | \newblock {\em Bipartite graph}, \\ 485 | \newblock \url{http://en.wikipedia.org/wiki/Bipartite_graph} 486 | 487 | \bibitem{github} 488 | Topic Networks GitHub repository \\ 489 | \newblock \url{https://github.com/bobflagg/Topic-Networks} 490 | 491 | \bibitem{lda} 492 | From Wikipedia, the free encyclopedia \\ 493 | \newblock {\em Latent Dirichlet allocation}, \\ 494 | \newblock \url{http://en.wikipedia.org/wiki/Latent_Dirichlet_allocation} 495 | 496 | \bibitem{messing} 497 | Solomon Messing, \\ 498 | \newblock {\em Working with Bipartite/Affiliation Network Data in R}, \\ 499 | \newblock \url{http://solomonmessing.wordpress.com/2012/09/30/working-with-bipartiteaffiliation-network-data-in-r/} 500 | 501 | \bibitem{speeches} 502 | Best Speeches of Barack Obama through his 2009 Inauguration \\ 503 | \newblock \url{http://obamaspeeches.com/} 504 | 505 | 506 | \bibitem{cran} 507 | R Core Team (2012), 508 | \newblock {\em R: A language and environment for statistical computing.}, 509 | \newblock \url{http://www.R-project.org} 510 | 511 | \bibitem{smartlab} 512 | Jorge L. Reyes-Ortiz, Davide Anguita, Alessandro Ghio, Luca Oneto, 513 | \newblock {\em Human Activity Recognition Using Smartphones Dataset.}, 514 | \newblock Smartlab - Non Linear Complex Systems Laboratory 515 | 516 | \bibitem{r-markdown} 517 | R Core Team (2012), 518 | \newblock {\em R Markdown}, 519 | \newblock \url{http://www.rstudio.com/ide/docs/authoring/using_markdown} 520 | \newblock Accessed 2/12/2013 521 | 522 | \bibitem{elemstatlearn} 523 | Trevor Hastie, Robert Tibshirani, Jerome Friedman 524 | \newblock {\em The Elements of Statistical Learning}, 525 | \newblock Springer, 2011. 526 | 527 | 528 | \end{thebibliography} 529 | 530 | \end{document} 531 | 532 | 533 | 534 | 535 | In particular, we compute the degree distribution 536 | and investigate centrality, path length and community structure. 537 | 538 | Below we demonstrate topic networks on a small corpora of 539 | 540 | Source code for our work is available at ... 541 | % ---------------------------------------------------------------------------- % 542 | % Methods % 543 | % ---------------------------------------------------------------------------- % 544 | 545 | \begin{verbatim} 546 | # Build the document term matrix. 547 | corpus.dtm <- DocumentTermMatrix( 548 | corpus, 549 | control = list( 550 | stemming = TRUE, 551 | stopwords = TRUE, 552 | minWordLength = 3, 553 | removeNumbers = TRUE, 554 | removePunctuation = TRUE 555 | ) 556 | ) 557 | \end{verbatim} 558 | -------------------------------------------------------------------------------- /doc/wordcloud.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bobflagg/Topic-Networks/d7bd6d283a7674a9aff2182c118087a61f32f0e5/doc/wordcloud.pdf -------------------------------------------------------------------------------- /r/topic-networks.R: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | ## topic-networks.R A sample analysis of a document collection using some ## 3 | ## standard NLP techniques and a new approach with topic networks. ## 4 | ## ## 5 | ## To run this code you must first download and extract the sample corpus ## 6 | ## corpus.zip ## 7 | ## and set the corpus.directory variable to point to the corpus directory. ## 8 | ## ## 9 | ## Requires the following packages: ## 10 | ## igraph ## 11 | ## ggplot2 ## 12 | ## RColorBrewer ## 13 | ## slam ## 14 | ## tm ## 15 | ## topicmodels ## 16 | ## wordcloud ## 17 | ## ## 18 | ## Much of the analysis below is based on ideas from Solomon Messing's blog ## 19 | ## post ## 20 | ## Working with Bipartite/Affiliation Network Data in R ## 21 | ## at ## 22 | ## http://solomonmessing.wordpress.com/2012/09/30/ ## 23 | ## ## 24 | ################################################################################ 25 | # Set the path to the corpus directory. # 26 | # ---------------------------------------------------------------------------- # 27 | corpus.directory <- '/home/birksworks/Projects/topic-networks/corpus' 28 | setwd('/home/birksworks/Projects/topic-networks/Topic-Networks/doc/') 29 | # ---------------------------------------------------------------------------- # 30 | # Load required libraries. # 31 | # ---------------------------------------------------------------------------- # 32 | require(igraph, quietly=TRUE) 33 | require(RColorBrewer, quietly=TRUE) 34 | require(ggplot2, quietly=TRUE) 35 | require(slam, quietly=TRUE) 36 | require(tm, quietly=TRUE) 37 | require(topicmodels, quietly=TRUE) 38 | require(wordcloud, quietly=TRUE) 39 | # ---------------------------------------------------------------------------- # 40 | # Load the corpus data. # 41 | # ---------------------------------------------------------------------------- # 42 | corpus.source <- DirSource(corpus.directory, encoding="UTF-8") 43 | corpus <- Corpus(corpus.source) 44 | corpus.copy <-corpus 45 | # ---------------------------------------------------------------------------- # 46 | # Build the document term matrix. # 47 | # ---------------------------------------------------------------------------- # 48 | corpus.dtm <- DocumentTermMatrix( 49 | corpus, 50 | control = list( 51 | stemming = TRUE, 52 | stopwords = TRUE, 53 | minWordLength = 3, 54 | removeNumbers = TRUE, 55 | removePunctuation = TRUE 56 | ) 57 | ) 58 | # ---------------------------------------------------------------------------- # 59 | # Visualize frequent words. # 60 | # ---------------------------------------------------------------------------- # 61 | word.freq <- sort(col_sums(corpus.dtm), decreasing=TRUE) 62 | # barplot with the top 20 most frequent terms 63 | top.terms <- head(word.freq, n=20) 64 | # complete the stems and fix missing values and errors: 65 | completions <- stemCompletion(names(top.terms), dictionary=corpus.copy, type="prevalent") 66 | completions<-ifelse(completions == "", names(top.terms), completions) 67 | names(top.terms) <-completions 68 | names(top.terms)[10] <-"every" 69 | pdf("mostfreq.pdf") 70 | op <- par(mar = c(4,6.1,.1,.2)) 71 | barplot(top.terms, las=2, horiz=TRUE) 72 | dev.off() 73 | png("mostfreq.png") 74 | op <- par(mar = c(4,6.1,.1,.2)) 75 | barplot(top.terms, las=2, horiz=TRUE) 76 | dev.off() 77 | # wordcloud 78 | pal2 <- brewer.pal(8,"Dark2") 79 | top.terms <- head(word.freq, n=1200) 80 | completions <- stemCompletion(names(top.terms), dictionary=corpus.copy, type="prevalent") 81 | completions<-ifelse(completions == "", names(top.terms), completions) 82 | names(top.terms) <-completions 83 | pdf("wordcloud.pdf") 84 | par(mar = c(0,0,0,0)) 85 | wordcloud(words=names(top.terms), freq=top.terms, min.freq=20, random.order=F, colors=pal2, rot.per=.15) 86 | dev.off() 87 | png("wordcloud.png") 88 | par(mar = c(0,0,0,0)) 89 | wordcloud(words=names(top.terms), freq=top.terms, min.freq=20, random.order=F, colors=pal2, rot.per=.15) 90 | dev.off() 91 | # ---------------------------------------------------------------------------- # 92 | # Build the tf-idf matrix and use it to filter the document term matrix. # 93 | # ---------------------------------------------------------------------------- # 94 | term.tfidf <- tapply(corpus.dtm$v/row_sums(corpus.dtm)[corpus.dtm$i], corpus.dtm$j, mean) * log2(nDocs(corpus.dtm)/col_sums(corpus.dtm > 0)) 95 | dtm <- corpus.dtm[,term.tfidf >= 0.01] 96 | dtm <- dtm[row_sums(dtm) > 0,] 97 | # ---------------------------------------------------------------------------- # 98 | # Build a topic model and collect relevant data in data frames. # 99 | # ---------------------------------------------------------------------------- # 100 | corpus.tm <- LDA(dtm, k = 22) 101 | corpus.tm.terms <- terms(corpus.tm, 3) 102 | corpus.tm.topics <- topics(corpus.tm, 4) 103 | topic.labels <- apply(corpus.tm.terms, 2, function(x) paste(x, collapse=", ")) 104 | document.labels <- colnames(corpus.tm.topics) 105 | dt.df <- data.frame( 106 | document=rep(document.labels, each=4), 107 | topic=as.vector(corpus.tm.topics) 108 | ) 109 | dt.df$document <- as.numeric(gsub(".txt","",dt.df$document)) 110 | dt.df <- dt.df[order(dt.df$document),] 111 | # ---------------------------------------------------------------------------- # 112 | # Build the incidence matrice and document-topic network. # 113 | # ---------------------------------------------------------------------------- # 114 | dt.matrix <- as.matrix(table(dt.df)) 115 | dt.network <- graph.incidence(dt.matrix) 116 | # ---------------------------------------------------------------------------- # 117 | # Visualize the document-topic network. # 118 | # ---------------------------------------------------------------------------- # 119 | n.docs <- nrow(dt.matrix) 120 | n.topics <- ncol(dt.matrix) 121 | n.vertices <- n.docs + n.topics 122 | V(dt.network)$color[1:n.docs] <- rgb(1,0,0,.4) 123 | V(dt.network)$color[(n.docs+1):n.vertices] <- rgb(0,1,0,.5) 124 | V(dt.network)$label <- NA 125 | V(dt.network)$size[1:n.docs] <- 2 126 | V(dt.network)$size[(n.docs+1):n.vertices] <- 6 127 | E(dt.network)$width <- .5 128 | E(dt.network)$color <- rgb(.5,.5,0,.4) 129 | tkplot(dt.network) 130 | dt.network$layout <- tkplot.getcoords(1) 131 | 132 | pdf("dtn.pdf") 133 | plot(dt.network, layout=layout.fruchterman.reingold) 134 | plot(dt.network) 135 | dev.off() 136 | png("dtn.png") 137 | plot(dt.network, layout=layout.fruchterman.reingold) 138 | dev.off() 139 | # ---------------------------------------------------------------------------- # 140 | # Create the topic network. # 141 | # ---------------------------------------------------------------------------- # 142 | topic.network.matrix <- t(dt.matrix) %*% dt.matrix 143 | topic.network <- graph.adjacency(topic.network.matrix, mode = "undirected") 144 | E(topic.network)$weight <- count.multiple(topic.network) 145 | topic.network <- simplify(topic.network) 146 | # Set vertex attributes 147 | V(topic.network)$label <- topic.labels 148 | V(topic.network)$label.color <- rgb(0,0,0,1) 149 | V(topic.network)$label.cex <- .75 150 | V(topic.network)$size <- 8 151 | #V(topic.network)$frame.color <- NA 152 | V(topic.network)$color <- rgb(0,1,0,.6) 153 | 154 | # Set edge gamma according to edge weight 155 | egam <- (log(E(topic.network)$weight)+.3)/max(log(E(topic.network)$weight)+.3) 156 | E(topic.network)$color <- rgb(.5,.5,0,egam) 157 | tkplot(topic.network) 158 | topic.network$layout <- tkplot.getcoords(2) 159 | 160 | pdf("topic-network.pdf") 161 | plot(topic.network, layout=layout.kamada.kawai) 162 | dev.off() 163 | png("topic-network.png") 164 | plot(topic.network, layout=layout.kamada.kawai) 165 | dev.off() 166 | # ---------------------------------------------------------------------------- # 167 | # Topic overlap. # 168 | # ---------------------------------------------------------------------------- # 169 | overlap.matrix <- topic.network.matrix / diag(topic.network.matrix) 170 | overlap.network <- graph.adjacency(overlap.matrix, weighted=T) 171 | # Degree 172 | V(overlap.network)$degree <- degree(overlap.network) 173 | # Betweenness centrality 174 | V(overlap.network)$btwcnt <- betweenness(overlap.network) 175 | # Plot the connection strength: 176 | plot(topic.network, layout=layout.kamada.kawai) 177 | pdf("density.pdf") 178 | plot(density(overlap.matrix), main=NA, xlab=NA) 179 | dev.off() 180 | overlap.matrix[overlap.matrix < 0.2] <- 0 181 | overlap.network <- graph.adjacency(overlap.matrix, weighted=T) 182 | overlap.network <- simplify(overlap.network, remove.multiple=FALSE, remove.loops=TRUE) 183 | overlap.network$layout <- layout.kamada.kawai(overlap.network) 184 | V(overlap.network)$label <- topic.labels 185 | tkplot(overlap.network) 186 | overlap.network$layout <- tkplot.getcoords(3) 187 | 188 | # Set vertex attributes 189 | V(overlap.network)$label.color <- rgb(0,0,.2,.6) 190 | V(overlap.network)$label.cex <- .75 191 | V(overlap.network)$size <- 6 192 | #V(topic.network)$frame.color <- NA 193 | V(overlap.network)$color <- rgb(0,1,0,.6) 194 | 195 | # Set edge gamma according to edge weight 196 | egam <- (E(overlap.network)$weight+.1)/max(E(overlap.network)$weight+.1) 197 | E(overlap.network)$color <- rgb(.5,.5,0,egam) 198 | E(overlap.network)$arrow.size <- .3 199 | V(overlap.network)$label.cex <- degree(overlap.network)/(max(degree(overlap.network)/2))+ .3 200 | pdf("overlap-network.pdf") 201 | plot(overlap.network) 202 | dev.off() 203 | png("overlap-network.png") 204 | plot(overlap.network) 205 | dev.off() 206 | --------------------------------------------------------------------------------