Print

Print


On Mon, May 30, 2011 at 12:44 AM, Jim Henry <[log in to unmask]> wrote:

> On Mon, May 30, 2011 at 12:30 AM, MorphemeAddict <[log in to unmask]>
> wrote:
> > Does anyone know of an easy way to mark the first occurrence of a word (a
> > type, not just a token) in a text without doing it by hand?
>
> In what kind of context, and what do you mean by "mark"?
>

By "mark" I mean some sort of highlight or underline to make the word stand
out from the surrounding text.

For instance, if you have a text file, you could do

grep word file.txt | head -1

on a Unix system to see the line of the file containing the first
occurrence of that word.  One could write a short Perl script to edit
the file in place and put some kind of delimiters around the first
occurrence of a given word.  I expect one could write a Word macro do
to the same within a Word document.

Or are you not talking about a specific word, but the first occurrence
of any word?  So taking this email as an example, each word in "In
what kind of context, and" would get delimiters or highlighting, and
then the second instance of "what" wouldn't get them, and then "do you
mean by "mark"?" would get highlighted...?
Yes, just so. You never know from one text to another what the words will be
or what order they'll come in.
stevo

--

>  Jim Henry
> http://www.pobox.com/~jimhenry/
>