Category Archives: Tools for Writers

Finding doubled words using perl

I recently switched to Scrivener for writing my documents. Much more enjoyable interface than Word, with lots of nifty features for writers. One big issue: I’m still getting used to Scrivener’s spellchecker. Microsoft Word finds doubled words right out of the box, but Scrivener does not.

The script below is written in perl, which comes pre-installed on Macs. If you paste it into a text file, make the file executable, and then run it in the same directory with a file called “infile.txt” (a cut/paste from Word to the file will do nicely), it will report your doubled words.

*update* – the script won’t catch things like: “bang bang” because the quotes make it think it’s 2 patterns.  Working on it 🙂

Example input (infile.txt):

This is a line
This is another line
And yet another line
wow I sure do a lot of lines, "Don't I?" he said (in a funny voice)...
Wow it sure is is fune typing all this
I like dogs and cats and stuff.
Big big is funner than small people.
how are are the dodgers doing this year? Nobody knows.
more lines and stuff...
etc. etc.
good things come to those who write scripts in perl and post them on the internet

Example Output:

is is ---->  Wow it sure is is fune typing all this
big big ---->  Big big is funner than small people.
are are ---->  how are are the dodgers doing this year? Nobody knows.
etc. etc. ---->  etc. etc.

And now the script: rep.pl

#!/usr/bin/perl
open(FILE,"infile.txt") or die "Can't open infile.txt: $!";
$section_breaks = "*";  # I have * * * as section breaks. The script sees them as words and should ignore them.
while(<FILE>) {
   chomp();
   $a_line = $_;
   @line = split(/ /, $_);
   $prev = 0;   
   foreach $i (@line) {
      $i = lc($i);
      if ($i eq $prev && $i ne $section_breaks) {
         print "$prev $i ---->  $a_line\n";
      }
      $prev = $i;
   }
}
close(FILE);
Advertisement

10 Comments

Filed under Grammar/Punctuation, Tools for Writers, Writing in general

Need a good app to record stuff…

I came up with two cool phrases today but I only remember one of them: “corporate cute.”  Sounds like something already invented, but not yet a cliche so I’m still happy with it.

The other one was better.  I really need to carry around a tape device, or get an app that I can take notes with while driving, or right before bed, etc.  Anyone have a favorite app?

*Update*

Folks over on kboards.com are recommending “Evernote” and “Voice Talk”.  Also, apparently iPhones have a built-in notes functionality where you speak and it records it.

2 Comments

Filed under Tools for Writers

Goodreads Quiz

One of my brilliant, beautiful readers suggested I create a quiz on Goodreads for Kick, so I did.

The Quiz

2 Comments

Filed under Tools for Writers

Re-blog: writing in the cloud on a Chromebook

pthyltonP.T. Hylton, author of “Regulation 19”, has this to say about writing in the cloud on a Chromebook.  He also makes fun of Best Buy, which is fun and appropriate.

Leave a comment

Filed under Tools for Writers

My gift to writers everywhere: agent query letter template

Everyone knows Christmas is the time for sharing, giving, and also receiving. This year I’ve received so much. I published my first novel and to my surprise it’s been well received. I know if I have any hope to keep receiving in 2014 I need to “give back” sometimes.

The agent query letter template below is my gift to the writing community, which sometimes retweets me and/or clicks “like” on my blog posts and/or clicks “like” on my facebook posts.  To the writing community, I’d like to see a little more “and” and a little less “or.”  But whatever.  That’s just how you are, I guess.

Dear [Agent’s Name],

Recently, I read a book on how to write and sell “fiction” to make money. The book said if I wanna make the big bucks I need a “literary agent.”

[Agent’s Name]: that’s where you come in.

The book went on to say that many literary agents are just failed writers who try to get rich by latching onto the success of people who actually have talent.  Now, I know that sounds bad, and trust me, I don’t think the author of that book was talking about you personally. But it has to be true for some agents, doesn’t it?  And let’s just assume it’s true in your case and you have no talent. Is that such a bad thing? Why not take me on as a “client,” and we’ll ride the gravy train to riches and fame together? You don’t have to be a failure forever—and neither do I!

The title of my book is [Book Title].  We can change the title to anything, I don’t care. It’s the “contents” of a book that matter, right? [Book Title] is an action-packed, fast-paced, rip-roaring adventure/mystery that’s hilarious yet sometimes sad.  And yes, I can take out any sad parts if needed, no worries. I only threw them in to get more women to read the book.

Last but not least, I just want to assure you that I ran spell check on the book like 10 times using Microsoft Word.

Sincerely,

[Your Name]

[Your Phone Number]

p.s., I’m offering 1% commission for the first 10,000 copies sold, 5% if you somehow  sell 50,000, and 10% if we crack 100,000.  But if we get up to a million sold, we need to dial things back down to 5%.  It’s still a mint though, so relax.

2 Comments

Filed under Funny, Submission Tips, Tools for Writers

Thulsa Doom knows

It seems to me that the riddle of steel applies to writing.


We think, “oh we need a better cover” or “website” or some famous person to promote us, but in the end the power isn’t in the tool, it’s the hand that wields it.

2 Comments

Filed under Tools for Writers, Writing in general, Writing Market

Find unbalanced smart quotes in HTML using Perl

So I’m brushing up an HTML document so I can publish it on the Kindle and I’ve discovered lots of unbalanced smart quotes. Smart quotes are double quotes that face to the right or the left, rather than just straight up and down. In HTML, they are rendered as “ldquo” and “rdquo” with an ampersand in front of each and a trailing semi-colon. I wrote a little script to make sure that for every left side I had a right side, and print out the lines in which they do not match.

Here you go:

#!/usr/bin/perl

open(FILE,"./file.html") or die "Can't open file.html: $!\n";

while(<FILE>) {
   chomp();
   $line = "$_";

   $l = "ldquo";
   $r = "rdquo";   
   $lc = 0;
   $rc = 0;   

   $lc = () = $line =~ /$l/g;
   $rc = () = $line =~ /$r/g;

   print "Lc = $lc  Rc = $rc\n";
   if ($lc != $rc) {
      print "\n$line\n";
   }
}
close(FILE);

3 Comments

Filed under Grammar/Punctuation, Tools for Writers

Preliminary homophone finder written in perl

I wrote this little perl script to find homophones in text documents, so if you save your word doc as a text file, in theory you can find all the homophones with it.  I’m using 943 homophones and running the first part of a Winston Churchill speech through it 🙂

To run the script, you’d need to know a little perl and how to use it. So for most people, this isn’t particularly user-friendly.  It’s more for fun, as well as a proof of concept on a hypothetical tool writers could use to keep silly mistakes out of their writing.  While the script runs, you hit ‘enter’ occasionally to go to the next line with one or more homophones in it.

The script needs:

  • words.txt – a list of homophones one after the other  (it makes sense to edit out of this any words you’d never mess up, for example, “I” vs. “eye” or “were” vs. “whirr”)
  • ms.txt –  your manuscript saved as a text file

First, the code:

#!/usr/bin/perl

open(WORDS,"words.txt") or die "Can't open words.txt: $!\n";
@words = <WORDS> ;
close(WORDS);

open(MS,"ms.txt") or die "Can't open ms.txt: $!\n";

while(<MS>) {
   chomp();
   $aline = $_;
   lc($aline);
   $match = 0;
   foreach $i (@words) {
        chomp($i);
      if ($aline=~/\s+$i\s+/g) {
        $match = 1;
        $uppercase = uc($i);
         $aline=~s/\s+$i\s+/ \*$uppercase\* /g;
      }
   }

   if ($match == 1) {
      print "$aline\n";
      print "[ hit enter to continue ]\n";
      $ans= <> ;
   }
}
close(MS);

Here’s what happens to the first part of this famous speech:

I spoke the other day of the colossal military disaster *WHICH* occurred when the French High Command failed *TO* withdraw the northern Armies from Belgium at the moment when they *KNEW* that the French front was decisively broken at Sedan and on the Meuse. This delay entailed the loss of fifteen *OR* sixteen French divisions and *THREW* out of action *FOR* the critical period the whole of the British Expeditionary Force. Our Army and 120,000 French troops *WERE* indeed rescued *BY* the British Navy from Dunkirk *BUT* only with the loss of *THEIR* cannon, vehicles and modern equipment. This loss inevitably took *SOME* weeks *TO* repair, and *IN* the first *TWO* of those weeks the battle *IN* France has *BEEN* lost. When *WE* consider the heroic resistance *MADE* *BY* the French Army against heavy odds *IN* this battle, the enormous losses inflicted upon the enemy and the evident exhaustion of the enemy, it may well *BE* the thought that these 25 divisions of the best-trained and best-equipped troops *MIGHT* have turned the scale. However, General Weygand had *TO* fight without them. Only three British divisions *OR* *THEIR* equivalent *WERE* able *TO* stand *IN* the line with *THEIR* French comrades. They have suffered severely, *BUT* they have *FOUGHT* well. We *SENT* every man *WE* could *TO* France as fast as *WE* could re-equip and transport *THEIR* formations.
[ hit enter to continue ]

I am *NOT* reciting these facts *FOR* the purpose of recrimination. That *I* judge *TO* *BE* utterly futile and even harmful. We cannot afford it. *I* recite them *IN* order *TO* explain why it was *WE* did *NOT* have, as *WE* could have had, between twelve and fourteen British divisions fighting *IN* the line *IN* this *GREAT* battle instead of only three. Now *I* put *ALL* this aside. *I* put it on the shelf, from *WHICH* the historians, when they have time, will select *THEIR* documents *TO* tell *THEIR* stories. We have *TO* think of the future and *NOT* of the past. This also applies *IN* a small *WAY* *TO* *OUR* own affairs at home. There are many who *WOULD* hold an inquest *IN* the House of Commons on the conduct of the Governments-and of Parliaments, *FOR* they are *IN* it, too-during the years *WHICH* *LED* up *TO* this catastrophe. They seek *TO* *INDICT* those who *WERE* responsible *FOR* the guidance of *OUR* affairs. This also *WOULD* *BE* a foolish and pernicious process. There are *TOO* many *IN* it. Let each man search his conscience and search his speeches. *I* frequently search mine.
[ hit enter to continue ]

Leave a comment

Filed under Grammar/Punctuation, Tools for Writers

Idea for a writer’s tool: homophone finder

I’ve done a little php programming and might make the tool myself since I don’t think it’d be that hard, but it sure would be nice if I could find one (that I could trust – your manuscript would be beyond your control).

Basically, it’d work like this:

  1. Go to: h-t-t-p-://<sitename.com>
  2. click the upload your manuscript button
  3. choose “find homophones”
  4. click “do it”

What follows would be your manuscript, rendered in html, scrolling past and stopping at each homophone it finds and then waiting for you to click “next.” Then you could look up the different meanings, if needed.

Homophone finder would stop at words like:

  • its / it’s
  • their / there / they’re
  • councilors / counselors
  • peak / peek
  • rite / write
  • new / knew
  • etc / etc

There’s nothing more embarrassing than firing off a manuscript you’ve read 300 times and discovering one of these horrors after the fact.

A tool like this would be fairly easy to make.  All it would need is:

  1. a php library to read word docs
  2. a text file of homophones (lots of them out there)
  3. a web server to take input/output

Not sure if anyone else would find something like this useful or not, or just me. If anyone knows of such a tool, I’m not above reading comments 🙂

Leave a comment

Filed under Tools for Writers

Fiction editing tip – leverage your Kindle Fire

I just finished my second official edit of my novel and I thought I’d pass along the experience.  We’ve all heard the various ways you should edit your book:

1) wait a month and read it fresh.

2) change the font and read it fresh.

3) Read it out loud and hear it fresh.

The common theme?  Reading it fresh, or differently than you are used to.  So here’s a new one:

4) publish it to your Kindle Fire and read it fresh!

If you go to your amazon account and click “manage my kindle”, you’ll see a section for personal documents.  Somewhere in the settings you can specify what email addresses can send documents to your amazon account.  There are better resources on how to do the exact steps, but in a nutshell you:

1) save-as your document to “stripped html” or (in office 2011 for mac) just html.

2) send it to <emailaddress@kindle.com>

3) publish to kindle

Once it arrives on your kindle you can read it as an ebook.  The best part is: while you are reading it, you can add notes DIRECTLY ON YOUR KINDLE.  You can highlight bad sections with “the the” or “your” when it should be “you’re”, etc. etc.  After re-reading your book and editing it up, you can easily go through it note by note and put it all back in your document.

That’s what I did this weekend.

Quick notes:

1) publishing to your kindle costs like 2 bucks (or something, very cheap)

2) you can also do this on your other kindle devices (it’s just easier on the Kindle Fire).

3) I’m guessing you can do it on other ebook readers, but that’s just a big fat guess, now ain’t it?

4 Comments

Filed under Tools for Writers