A script to flag commonly misused words

D

David Delony

This is my first real program, and being a good open source citizen, I'd
like to share it. It flags what Strunk and White thought were commonly
misued words and expressions. Share and enjoy!

#! /usr/bin/perl -w

=head1 NAME

misused_words - flag common usage errors in text

=head1 SYNOPSIS

misused_words [filename]

=head1 DESCRIPTION

miused_words takes files or standard input if no filename is given, and
checks
for commonaly misused words as defined and Strunk and White's "Elements of
Style." The program prints lines where misued words are found, with the
matches
in square brackets. The user should then consider revising the line.

=head1 AUTHOR

David Delony <[email protected]>

=head1 BUGS

The program is not nearly as smart as a human proofreader, only faster.

=head1 SEE ALSO

William Strunk, Jr., E.B. White, I<The Elements of Style> 4th Ed.
Allyn & Bacon, 2000. ISBN 0-205-30902-X

=head1 COPYRIGHT

Copyright (c) 2007 David Delony. All Rights Reserved.

This program is free software. You may copy or redistribute it under the
same
terms as Perl itself.

=cut

use strict;

while (<>) { # Our friend, the magic filehandle.
&word_check;
}


sub flag() {
chomp;
print "$.:$`\[$&\]$'\n"; #Print a line number and the line with
pattern match
} # in brackets.

sub word_check () { # Brace yourself, it's going to be a long one!
&flag if /aggravat|irritat/i; # aggravate or irratate. Allowing for
gerunds.
&flag if /all right/i;
&flag if /allud|allusion/i; # Allude and friends
&flag if /alternate|alternative/;
&flag if /among|between/i;
&flag if /and\/or/i;
&flag if /anticipat/i; # Anticipate, anticipation.
&flag if /anybody/i;
&flag if /anyone/i;
&flag if /as good or better than/i;
&flag if /as to whether/i;
&flag if /as yet/i;
&flag if /being/i;
&flag if /but/i;
&flag if /can/i; # Troublesome word, but great band!
&flag if /care less/i;
&flag if /case/i;
&flag if /certainly/i;
&flag if /character/i;
&flag if /claim/i;
&flag if /clever/i;
&flag if /compar/i; # Compare, comparing.;
&flag if /compris/i;# Comprise, comprising.
&flag if /consider/i;
&flag if /contact/i;
&flag if /cope|coping/i;
&flag if /currently/i;
&flag if /data/i;
&flag if /different than/i;
&flag if /disinterested/i;
&flag if /divided into/i;
&flag if /due to/i;
&flag if /each and every one/i;
&flag if /effect/i;
&flag if /enormity/i;
&flag if /enthuse/i;
&flag if /etc/i;
&flag if /fact/i;
&flag if /facilit/i; # Ugh, "facilities.";
&flag if /factor/i;
&flag if /farther|further/i;
&flag if /feature/i;
&flag if /finalize/i;
&flag if /fix/i;
&flag if /flammable/i;
&flag if /folk/i; # This program hates folk music.
&flag if /fortuitous/i;
&flag if /got/i;
&flag if /gratuitous/i; # We will not have any gratuitous sax or
violins in our program!
&flag if /is a.who|that/i; # "He is a man who" and other constructions.
&flag if /hopefully/i;
&flag if /however/;
&flag if /illusion/i;
&flag if /imply|impli|infer/i; # Imply, infer. Different words.
&flag if /importanly/i;
&flag if /in regard to/i;
&flag if /in the last analysis/i;
&flag if /inside/i;
&flag if /insightful/i;
&flag if /in terms of/i;
&flag if /interesting/i;
&flag if /irregardless/i; # That's not even a word!
&flag if /ize/i; # PHB "-ize" contructions.
&flag if /kind of/i;
&flag if /lay/i;
&flag if /leave/i;
&flag if /less/i;
&flag if /like/i;
&flag if /line|along these lines/i;
&flag if /literal|literally/i;
&flag if /loan/i;
&flag if /meaningful/i;
&flag if /memento/i;
&flag if /most/i;
&flag if /nature/i;
&flag if /nauseous|nauseated/i;
&flag if /nice/i;
&flag if /nor/i;
# Right here is where I would flag nouns used as verbs, but I think
that is an NP-complete problem
&flag if /one/i;
&flag if /one of the most/i;
&flag if /oriented/i;
&flag if /partially/i;
&flag if /ing/i; # participle check.
&flag if /people/i;
&flag if /personal/i;
&flag if /posess/i;
&flag if /presently/i;
&flag if /prestigoius/i;
&flag if /refer/i;
&flag if /regeretful/i;
&flag if /relate/i;
&flag if /respective/i;
&flag if /firstly|secondly|thirdly|fourthly/i;
&flag if /shall|will/i;
&flag if /so/i;
&flag if /sort of/i;
&flag if /to.*ly/i; # Split infinitive check
&flag if /state/i;
&flag if /student body/i;
&flag if /than/i;
&flag if /thank* in advance/i;
&flag if /that|which/i;
&flag if /the foreseeable future/i;
&flag if /the* is/i; # The truth is, the fact is.
&flag if /they|he|she/i;
&flag if /this/i;
&flag if /thrust/i;
&flag if /tortuous|torturous/i;
&flag if /try/i;
&flag if /type/i;
&flag if /unique/i;
&flag if /utilize/i; # That word drives me nuts!
&flag if /verbal/i;
&flag if /very/i;
&flag if /while/i;
&flag if /\w+wise/i; # "-wise" words
&flag if /worth.while/i;
&flag if /would/i;
} # Phew!
 
L

Lars Eighner

the said:
This is my first real program, and being a good open source citizen, I'd
like to share it. It flags what Strunk and White thought were commonly
misued words and expressions. Share and enjoy!

The first rule in real programming is research. Seems 'diction' has done
this for years, has some modest phrase handling and suggestion ability, and
although it started with Strunk & White, has acquire many other items and
comes in several language flavors, allowing a supplemental rules file from
the user with or without disabling the default file.

A real advance would be to give diction a nice curses interface and stream
handling abilities like aspell or ispell.
 
D

David Delony

Please note that the purpose of this critique is not to discourage you
but to help you improve. Hope it helps.

I appreciate the suggestions. I was hoping the Perl hackers would help me
see better ways of implenting this program. Bitter medicice, perhaps. but
the patient needs it. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top