Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 21 Mar 2010 10:16:22 -0400
From:      "b. f." <bf1783@googlemail.com>
To:        Gary Kline <kline@thought.org>
Cc:        freebsd-questions@FreeBSD.org
Subject:   Re: shell script to cap first letter?
Message-ID:  <d873d5be1003210716l833bf5l6fd7f8c8aa85a028@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
>i'm wondering if there is a script that i could run my plaintext
>files thru that would capitalize thef first letter of each
>sentence [[ assuming the character wasn't already a cap!]]
>
>more and more, in recent years, i have posted questions or
>written things that have been sloppily or casually hacked
>together in all lower case.  this filter would have to determine
>what was and was not a sentence.  or a sentence fragment.
>[ai]spell can catch "i've" and suggest "I've", etc.

You're asking a lot from a simple filter if you want it to
discriminate between uses of "." to terminate a sentence, and other
uses of "." that do not require the following word to be capitalized,
such as the use of "." in abbreviations -- a lot of fairly
sophisticated spelling and grammar checkers can fail to do this
reliably.  But if you want a naive filter you could use textproc/gsed,
with the /U GNU extension (our BSD sed(1) doesn't understand it),
e.g.:

gsed -e 's|\(\.[.[:space:].]\)\([a-z]\)|\1\U\2|g'

or you could use BSD sed(1), together with a more cumbersome
capitalization script, like the cflword[12345].sed scripts at:

http://sed.sourceforge.net/grabbag/scripts/#txfo

Or you could use Perl.  Or awk(1). Or script a [non-]interactive call
to a more sophisticated spelling or grammar checker. Or roll your own.
 For questions like this, try searching the web first.

b.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?d873d5be1003210716l833bf5l6fd7f8c8aa85a028>