SPUG: Software to expand contractions?
Cantrall, Christopher W
christopher.w.cantrall at boeing.com
Mon Oct 27 10:38:59 CST 2003
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
>
>
More information about the spug-list
mailing list