Folks, I have a number of text files of poetry that I'd like to add line numbers to for concordancing, starting the numbering at 1 and continuing to the last text line, with the line numbers ending up as part of the resulting text file, each number on the relevant line before the text of that line of verse begins.
I've done this before a few times a while ago, but danged if I can remember what I used. I know I didn't write anything to do it, though I assume it's pretty easy to do so. I think it was in a text editor or word processor, but looking at vi and emacs it looks like I can only get the line numbers to display with the file, not to be added to the file, and that's true of some Windows ones as well and of Word, unless there are tricks.
The UNIX/Linux "nl" utility does basically what I want (if I pipe the output to a file, I get my text file back but with a line number and a tab added to the beginning of each line), and I can deal with the output but I remember (possibly from one of those technicolor dreams--you'll let me know!) a more interactive, less command-liney, way of doing this that would make this stage easier.
Thanks for any help.
Murray McGillivray
No answer, I'm afraid, but let me ask that we share the answer to this with the list (and the wiki). This is exactly the type of thing we can use!
-dan
On Tue, 2006-11-14 at 16:07 -0700, Murray McGillivray wrote:
Folks, I have a number of text files of poetry that I'd like to add line numbers to for concordancing, starting the numbering at 1 and continuing to the last text line, with the line numbers ending up as part of the resulting text file, each number on the relevant line before the text of that line of verse begins.
I've done this before a few times a while ago, but danged if I can remember what I used. I know I didn't write anything to do it, though I assume it's pretty easy to do so. I think it was in a text editor or word processor, but looking at vi and emacs it looks like I can only get the line numbers to display with the file, not to be added to the file, and that's true of some Windows ones as well and of Word, unless there are tricks.
The UNIX/Linux "nl" utility does basically what I want (if I pipe the output to a file, I get my text file back but with a line number and a tab added to the beginning of each line), and I can deal with the output but I remember (possibly from one of those technicolor dreams--you'll let me know!) a more interactive, less command-liney, way of doing this that would make this stage easier.
Thanks for any help.
Murray McGillivray
Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm Wiki: http://sql.uleth.ca/dmorgwiki/index.php Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca dm-l mailing list dm-l@uleth.ca http://listserv.uleth.ca/mailman/listinfo/dm-l
I have a Perl script that will assign absolute line numbers, and it can be tweaked not to assign line numbers to ascii lines beginning with <milestone, <lg, <fw, <marginalia, etc. One can supply the </l> by a search/replace operation, or you could use another Perl script to assign </l>. I'll be glad to supply these scripts if something more useful is not generally available. Best, Dug
At 06:14 PM 11/14/2006, you wrote:
No answer, I'm afraid, but let me ask that we share the answer to this with the list (and the wiki). This is exactly the type of thing we can use!
-dan
On Tue, 2006-11-14 at 16:07 -0700, Murray McGillivray wrote:
Folks, I have a number of text files of poetry that I'd like to add line numbers to for concordancing, starting the numbering at 1 and continuing to the last text line, with the line numbers ending up as part of the resulting text file, each number on the relevant line before the text of that line of verse begins.
I've done this before a few times a while ago, but danged if I can remember what I used. I know I didn't write anything to do it, though I assume it's pretty easy to do so. I think it was in a text editor or word processor, but looking at vi and emacs it looks like I can only get the line numbers to display with the file, not to be added to the file, and that's true of some Windows ones as well and of Word, unless there are tricks.
The UNIX/Linux "nl" utility does basically what I want (if I pipe the output to a file, I get my text file back but with a line number and a tab added to the beginning of each line), and I can deal with the output but I remember (possibly from one of those technicolor dreams--you'll let me know!) a more interactive, less command-liney, way of doing this that would make this stage easier.
Thanks for any help.
Murray McGillivray
Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm Wiki: http://sql.uleth.ca/dmorgwiki/index.php Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca dm-l mailing list dm-l@uleth.ca http://listserv.uleth.ca/mailman/listinfo/dm-l
-- Daniel Paul O'Donnell, PhD Department Chair and Associate Professor of English Director, Digital Medievalist Project http://www.digitalmedievalist.org/ Chair, Text Encoding Initiative http://www.tei-c.org/
Department of English University of Lethbridge Lethbridge AB T1K 3M4 Vox +1 403 329-2377 Fax +1 403 382-7191 Email: daniel.odonnell@uleth.ca WWW: http://people.uleth.ca/~daniel.odonnell/
Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm Wiki: http://sql.uleth.ca/dmorgwiki/index.php Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca dm-l mailing list dm-l@uleth.ca http://listserv.uleth.ca/mailman/listinfo/dm-l
You could do it easily with text editors like TextPad or EditPlus on Windows, or BBEdit on Mac.
-----Original Message----- From: dm-l-bounces@uleth.ca [mailto:dm-l-bounces@uleth.ca] On Behalf Of Murray McGillivray Sent: Tuesday, November 14, 2006 3:07 PM To: Digital Medievalist Community mailing list Subject: [dm-l] numbering lines
Folks, I have a number of text files of poetry that I'd like to add line numbers to for concordancing, starting the numbering at 1 and continuing to the last text line, with the line numbers ending up as part of the resulting text file, each number on the relevant line before the text of that line of verse begins.
I've done this before a few times a while ago, but danged if I can remember what I used. I know I didn't write anything to do it, though I assume it's pretty easy to do so. I think it was in a text editor or word processor, but looking at vi and emacs it looks like I can only get the line numbers to display with the file, not to be added to the file, and that's true of some Windows ones as well and of Word, unless there are tricks.
The UNIX/Linux "nl" utility does basically what I want (if I pipe the output to a file, I get my text file back but with a line number and a tab added to the beginning of each line), and I can deal with the output but I remember (possibly from one of those technicolor dreams--you'll let me know!) a more interactive, less command-liney, way of doing this that would make this stage easier.
Thanks for any help.
Murray McGillivray
_______________________________________________ Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm Wiki: http://sql.uleth.ca/dmorgwiki/index.php Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca dm-l mailing list dm-l@uleth.ca http://listserv.uleth.ca/mailman/listinfo/dm-l
Murray McGillivray wrote:
Folks, I have a number of text files of poetry that I'd like to add line numbers to for concordancing, starting the numbering at 1 and continuing to the last text line, with the line numbers ending up as part of the resulting text file, each number on the relevant line before the text of that line of verse begins.
The following bit of perl magic will do it
perl -pi -e"s/$_/$. $_/" filename
I've done this in Excel for my own concordance. You can put the lines in the cells, then in another column you can automatically put 1, 2, 3, etc. down the side by highlighting the first two or three and then by dragging the pointer down to where the end of the text is. You can also modify the numbers in a different format, by selecting a custom format for the cells. Below is a sample of what I did.
Abdullah Alger
<L 1> cyninge <L 2> ðu eart se weallstan þe ða wyrhtan iu <L 3> wiðwurpon to weorce Wel þe geriseð <L 4> þæt þu heafod sie healle mærre <L 5> ond gesomnige side weallas <L 6> fæste gefoge flint unbræcne <L 7> þæt geond eorðbold eall eagna gesihþe
Quoting Murray McGillivray mmcgilli@ucalgary.ca:
Folks, I have a number of text files of poetry that I'd like to add line numbers to for concordancing, starting the numbering at 1 and continuing to the last text line, with the line numbers ending up as part of the resulting text file, each number on the relevant line before the text of that line of verse begins.
I've done this before a few times a while ago, but danged if I can remember what I used. I know I didn't write anything to do it, though I assume it's pretty easy to do so. I think it was in a text editor or word processor, but looking at vi and emacs it looks like I can only get the line numbers to display with the file, not to be added to the file, and that's true of some Windows ones as well and of Word, unless there are tricks.
The UNIX/Linux "nl" utility does basically what I want (if I pipe the output to a file, I get my text file back but with a line number and a tab added to the beginning of each line), and I can deal with the output but I remember (possibly from one of those technicolor dreams--you'll let me know!) a more interactive, less command-liney, way of doing this that would make this stage easier.
Thanks for any help.
Murray McGillivray
Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm Wiki: http://sql.uleth.ca/dmorgwiki/index.php Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca dm-l mailing list dm-l@uleth.ca http://listserv.uleth.ca/mailman/listinfo/dm-l
Why not encode your poem in TEI usind the <l> (or any other element) and output line numbers using XSLT and xsl:number? Best, Notis
On 11/15/06, Abdullah Alger Abdullah.Alger-2@postgrad.manchester.ac.uk wrote:
I've done this in Excel for my own concordance. You can put the lines in the cells, then in another column you can automatically put 1, 2, 3, etc. down the side by highlighting the first two or three and then by dragging the pointer down to where the end of the text is. You can also modify the numbers in a different format, by selecting a custom format for the cells. Below is a sample of what I did.
Abdullah Alger
<L 1> cyninge <L 2> ðu eart se weallstan þe ða wyrhtan iu <L 3> wiðwurpon to weorce Wel þe geriseð <L 4> þæt þu heafod sie healle mærre <L 5> ond gesomnige side weallas <L 6> fæste gefoge flint unbræcne <L 7> þæt geond eorðbold eall eagna gesihþe
Quoting Murray McGillivray mmcgilli@ucalgary.ca:
Folks, I have a number of text files of poetry that I'd like to add line numbers to for concordancing, starting the numbering at 1 and continuing to the last text line, with the line numbers ending up as part of the resulting text file, each number on the relevant line before the text of that line of verse begins.
I've done this before a few times a while ago, but danged if I can remember what I used. I know I didn't write anything to do it, though I assume it's pretty easy to do so. I think it was in a text editor or word processor, but looking at vi and emacs it looks like I can only get the line numbers to display with the file, not to be added to the file, and that's true of some Windows ones as well and of Word, unless there are tricks.
The UNIX/Linux "nl" utility does basically what I want (if I pipe the output to a file, I get my text file back but with a line number and a tab added to the beginning of each line), and I can deal with the output but I remember (possibly from one of those technicolor dreams--you'll let me know!) a more interactive, less command-liney, way of doing this that would make this stage easier.
Thanks for any help.
Murray McGillivray
Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm RSS (announcements) server:
http://www.digitalmedievalist.org/rss/rss2.cfm
Wiki: http://sql.uleth.ca/dmorgwiki/index.php Change membership options:
http://listserv.uleth.ca/mailman/listinfo/dm-l
Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca dm-l mailing list dm-l@uleth.ca http://listserv.uleth.ca/mailman/listinfo/dm-l
Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm Wiki: http://sql.uleth.ca/dmorgwiki/index.php Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca dm-l mailing list dm-l@uleth.ca http://listserv.uleth.ca/mailman/listinfo/dm-l
Abdullah,
I'd second what Notis is suggesting here. Using a format like:
<L 2> ðu eart se weallstan þe ða wyrhtan iu
is really moving backwards in technological development to the 1980s and markup languages like COCOA and OCP. We have lots of stuff in such terrible formats in the Oxford Text Archive, and it is a pain to convert. Using XML, as Notis suggests, would allow you to take advantage of all the existing tools for creating, manipulating, transforming and querying XML. You can always transform from a TEI XML structure like:
<l n="2">ðu eart se weallstan þe ða wyrhtan iu</l>
back to
<L 2> ðu eart se weallstan þe ða wyrhtan iu
really really easily, if that is how some other input program suggests.
Murray: To answer your original question, I remember doing something similar in emacs eons ago. (I've given up on emacs and use oxygen for most text/script/program files and OO for everything else.) I can't remember if it was a built-in function from some package I had installed, or whether I knocked up a bit of elisp to do it. Let me know if you are desperate to do it this way and I can dig back through my old elisp files somewhere.
For the record, the way I would do this now would be one of two ways: 1) For a quick hack where I needed to do it quickly I would add the line numbers automatically to the text file in openoffice and then just cut and paste it back into my text editor. (Inefficient I know...) 2) I have an XSLT script which will read in a plain text file and output everything in <l> (with a new <lg> for any blank lines between stanzas.
However, I would echo what I'd say to Abdullah above. *Why* add line numbers? The *only* reason really to add line numbers these days is if the line numbering is irregular for some reason. (i.e. the text goes 1,2,3,4, *big burnt hole*,12,13,14.) Amazingly, computers are really good at counting, and counting lines is easy. So, mark everything up as <l> and then just number them automatically when producing a presentation version.
Just my tuppence,
-James
Notis Toufexis wrote:
Why not encode your poem in TEI usind the <l> (or any other element) and output line numbers using XSLT and xsl:number? Best, Notis
On 11/15/06, * Abdullah Alger* <Abdullah.Alger-2@postgrad.manchester.ac.uk mailto:Abdullah.Alger-2@postgrad.manchester.ac.uk> wrote:
I've done this in Excel for my own concordance. You can put the lines in the cells, then in another column you can automatically put 1, 2, 3, etc. down the side by highlighting the first two or three and then by dragging the pointer down to where the end of the text is. You can also modify the numbers in a different format, by selecting a custom format for the cells. Below is a sample of what I did. Abdullah Alger <L 1> cyninge <L 2> ðu eart se weallstan þe ða wyrhtan iu <L 3> wiðwurpon to weorce Wel þe geriseð <L 4> þæt þu heafod sie healle mærre <L 5> ond gesomnige side weallas <L 6> fæste gefoge flint unbræcne <L 7> þæt geond eorðbold eall eagna gesihþe Quoting Murray McGillivray <mmcgilli@ucalgary.ca <mailto:mmcgilli@ucalgary.ca>>: > Folks, I have a number of text files of poetry that I'd like to add > line numbers to for concordancing, starting the numbering at 1 and > continuing to the last text line, with the line numbers ending up as > part of the resulting text file, each number on the relevant line > before the text of that line of verse begins. > > I've done this before a few times a while ago, but danged if I can > remember what I used. I know I didn't write anything to do it, though > I assume it's pretty easy to do so. I think it was in a text editor > or word processor, but looking at vi and emacs it looks like I can > only get the line numbers to display with the file, not to be added > to the file, and that's true of some Windows ones as well and of > Word, unless there are tricks. > > The UNIX/Linux "nl" utility does basically what I want (if I pipe the > output to a file, I get my text file back but with a line number and > a tab added to the beginning of each line), and I can deal with the > output but I remember (possibly from one of those technicolor > dreams--you'll let me know!) a more interactive, less command-liney, > way of doing this that would make this stage easier. > > Thanks for any help. > > Murray McGillivray > > _______________________________________________ > Digital Medievalist Project > Homepage: http://www.digitalmedievalist.org > Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm <http://www.digitalmedievalist.org/journal.cfm> > RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm > Wiki: http://sql.uleth.ca/dmorgwiki/index.php <http://sql.uleth.ca/dmorgwiki/index.php> > Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l > Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm > Contact editorial Board: digitalmedievalist@uleth.ca <mailto:digitalmedievalist@uleth.ca> > dm-l mailing list > dm-l@uleth.ca <mailto:dm-l@uleth.ca> > http://listserv.uleth.ca/mailman/listinfo/dm-l > _______________________________________________ Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm <http://www.digitalmedievalist.org/journal.cfm> RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm Wiki: http://sql.uleth.ca/dmorgwiki/index.php <http://sql.uleth.ca/dmorgwiki/index.php> Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca <mailto:digitalmedievalist@uleth.ca> dm-l mailing list dm-l@uleth.ca <mailto:dm-l@uleth.ca> http://listserv.uleth.ca/mailman/listinfo/dm-l
James Cummings wrote:
However, I would echo what I'd say to Abdullah above. *Why* add line numbers? The *only* reason really to add line numbers these days is if the line numbering is irregular for some reason. (i.e. the text goes 1,2,3,4, *big burnt hole*,12,13,14.) Amazingly, computers are really good at counting, and counting lines is easy. So, mark everything up as <l> and then just number them automatically when producing a presentation version.
Actually, my situation is that very one (well, not the *big burnt hole*, but the general idea): I want to have the line numbering in the concordance I'm building be in conformance to line numbering in a "standard reference system" (to use TEI jargon), that is, the line numbering in a standard edition, and there are missing lines and stanzas, duplicated lines, inversions of lines, etc. in my text as compared to the standard line numbering--a pretty common situation in medieval and early modern texts. The standard reference system also has several series of line numbers beginning at 1 and extending to the hundreds. So I can use automatic numbering to generate an initial matching of number to line for each of the chunks, but I need to fiddle a bit around the anomalies and then actually stick the numbers to the lines permanently before concordancing.
Thanks to everyone for the excellent suggestions.
Murray
So I can use automatic numbering to generate an initial matching of number to line for each of the chunks, but I need to fiddle a bit around the anomalies and then actually stick the numbers to the lines permanently before concordancing.
We meet this frequently when our keyers have neglected to capture line numbers, and our best solution, though not ideal, is interactive editing with an editor that allows not only automatic numbering, but easy selection of lines to operate on, easy undo if it goes wrong, and easy numbering from arbitrary starting points and with arbitrary increments, e.g. 'replace every <l> in the selected region with <l n="..."> starting at 238 and incrementing by 2 each time.' TextPad (on Windows) does this well (replace <l> with <l n="\i(238,2)">)
If you have some match point in the 'external reference system' on which to key in inserting numbers, a more elaborate scripted solution suggests itself. But you probably don't.
pfs -------------------------------------------------------------------- Paul Schaffner | pfs@umich.edu | http://www-personal.umich.edu/~pfs/ University of Michigan Digital Library Production Service --------------------------------------------------------------------
Here's something I just whipped up that will number and tab new lines following a carriage return/linefeed. I can change it to split on just a carriage return or just a linefeed, depending on your input documents.
If you had linefeeds for the ends of lines and carriage return/linefeed for breaks between stanzas, I could skip numbering those lines. Might be problematic otherwise.
Slap your text into the textbox and press go. The output will appear below.
http://lacuna.ca/line_numbering.asp
travis
-----Original Message----- From: dm-l-bounces@uleth.ca [mailto:dm-l-bounces@uleth.ca] On Behalf Of Murray McGillivray Sent: Tuesday, November 14, 2006 3:07 PM To: Digital Medievalist Community mailing list Subject: [dm-l] numbering lines
Folks, I have a number of text files of poetry that I'd like to add line numbers to for concordancing, starting the numbering at 1 and continuing to the last text line, with the line numbers ending up as part of the resulting text file, each number on the relevant line before the text of that line of verse begins.
I've done this before a few times a while ago, but danged if I can remember what I used. I know I didn't write anything to do it, though I assume it's pretty easy to do so. I think it was in a text editor or word processor, but looking at vi and emacs it looks like I can only get the line numbers to display with the file, not to be added to the file, and that's true of some Windows ones as well and of Word, unless there are tricks.
The UNIX/Linux "nl" utility does basically what I want (if I pipe the output to a file, I get my text file back but with a line number and a tab added to the beginning of each line), and I can deal with the output but I remember (possibly from one of those technicolor dreams--you'll let me know!) a more interactive, less command-liney, way of doing this that would make this stage easier.
Thanks for any help.
Murray McGillivray
_______________________________________________ Digital Medievalist Project Homepage: http://www.digitalmedievalist.org Journal (Spring 2005-): http://www.digitalmedievalist.org/journal.cfm RSS (announcements) server: http://www.digitalmedievalist.org/rss/rss2.cfm Wiki: http://sql.uleth.ca/dmorgwiki/index.php Change membership options: http://listserv.uleth.ca/mailman/listinfo/dm-l Submit RSS announcement: http://www.digitalmedievalist.org/newitem.cfm Contact editorial Board: digitalmedievalist@uleth.ca dm-l mailing list dm-l@uleth.ca http://listserv.uleth.ca/mailman/listinfo/dm-l