SPUG: Software to expand contractions?
Cantrall, Christopher W
christopher.w.cantrall at BOEING.COM
Mon Oct 27 11:13:13 CST 2003
And you can build a list of the contration-like words in your book automatically.
#!/usr/bin/perl -wln
/\b(\w+[']\w+)\b/;
print "$1" if $1;
It'll print all of the words which contain apostrophes, so you'll get more than just contractions, but it's quick.
...
BTW, for some reason I can't seem to get this to work as a one-liner, but I think that's because my shell-fu is weak. If you're morbidly curious:
cwc9144 at esg2776:<45> perl -wln -e'/\b(\w+\'\w+)\b/; print "$1" if $1;' file
/usr/bin/ksh: 0403-057 Syntax error: `)' is not expected.
__________________________________________
Christopher Cantrall
Structural Engineer, 777 Body Join
phone: 425-266-2936
Christopher.W.Cantrall at Boeing.com
> -----Original Message-----
> From: Cantrall, Christopher W
> Sent: Monday, October 27, 2003 8:39 AM
> To: Tim Maher; spug-list at pm.org
> Cc: Damian Conway
> Subject: RE: SPUG: Software to expand contractions?
>
>
> You could use a dispatch table of sorts. This let's you take
> care of the easy substitutions and worry about the
> is/has/possesive hard ones later.
>
> %substitutions{
> can't => can not,
> won't => will not,
> isn't => is not,
> shouldn't => should not,
> wouldn't => would not,
> wasn't => was not,
> they're => they are,
> we're => we are,
> I'm => I am,
> I'll => I will,
> };
>
> Of course, these will need to be properly quoted, and the
> apostrophes properly escaped, but it's Monday morning and I
> know I'll foul that up if I try before my first coffee.
>
> Good luck, I love the book so far.
>
> ____________________________________________
> Chris Cantrall
> Structural Engineer, 777 Fuselage, Boeing
> Christopher.W.Cantrall at Boeing.com
> chris at cantrall.org
> http://perlmonks.org/index.pl?node=Louis_Wu
> http://spugwiki.perlocity.org/index.cgi?LouisWu
>
>
> > -----Original Message-----
> > From: Tim Maher [mailto:tim at consultix-inc.com]
> > Sent: Saturday, October 25, 2003 10:43 AM
> > To: spug-list at pm.org
> > Cc: Damian Conway
> > Subject: SPUG: Software to expand contractions?
> >
> >
> > Dudes,
> >
> > I'm getting complaints from some early reviewers of my book
> > about all the "contractions" I'm using in my writing!
> > So last night I set out to write a Perl script to make changes
> > like the following:
> >
> > That's => That is
> > He's => He is
> > They're => They are
> > We're => We are
> >
> > Then I realized that the 's ending usually needs replacement by
> > "is", so I tried
> >
> > "'s" => ' is'
> > which doesn't quite work, because of the undesirability of changing
> >
> > Larry's hat => Larry is hat
> >
> > After making an exception for that case, I found other
> complications,
> > such as
> >
> > wouldn't => would not
> > can't => can not
> >
> > These follow different rules, because the 'wouldn' loses its
> > 'n', but the
> > 'can' doesn't!
> >
> > So at that point I realized that this is a bigger problem
> than I first
> > thought, and decided to look for a solution on CPAN. Searching for
> > "contractions" didn't turn up anything relevant, so now I'm
> > wondering if
> > anybody knows of a module that will do this job -- convert a
> > standard set of English
> > contractions into their expanded forms.
> >
> > Can't y'all gimme the help I'm searchin' for?
> >
> > -Tim
> > *------------------------------------------------------------*
> > | Tim Maher (206) 781-UNIX (866) DOC-PERL (866) DOC-UNIX |
> > | tim(AT)Consultix-Inc.Com TeachMeUnix.Com TeachMePerl.Com |
> > *+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-*
> > | UNIX Fundamentals Class: 11/10-13 Perl Class: 12/01-05 |
> > | Watch for my Book: "Minimal Perl for Shell Programmers" |
> > *------------------------------------------------------------*
> > _____________________________________________________________
> > Seattle Perl Users Group Mailing List
> > POST TO: spug-list at mail.pm.org http://spugwiki.perlocity.org
> > ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
> > MEETINGS: 3rd Tuesdays, U-District, Seattle WA
> > WEB PAGE: http://www.seattleperl.org
> >
> >
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
> POST TO: spug-list at mail.pm.org http://spugwiki.perlocity.org
> ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays, U-District, Seattle WA
> WEB PAGE: http://www.seattleperl.org
>
>
More information about the spug-list
mailing list