July 2015 Archives

Finding Common Ground ... in Both Directions

Last week I formulated an interesting problem in text processing while working on one of my hobbies.  Since I was only able to devote an hour or two here and there, it took me a few days to get the solution up and running, which indicated to me that it wasn’t as simple as I’d thought it would be at first.  And since “not simple” often means “interesting,” I thought I’d share it here with you.  (Note that I don’t claim this is the best solution, or the most efficient, or the most elegant.  I’m perfectly happy to receive suggestions for improvement if you’re so inclined.)

The exact application isn’t important, 1 so let’s just look at the general parameters.  There’s a series of cards, and each card has one or more powers on it (where a “power” in this case just means a block of text).  I have a file with all the powers in it, and a little script to help me search for patterns within and across the powers.  Let’s assume the powers come in, one per line, like so:

Name of Card / Name of Power : Description text of power.

(They’re not actually formatted like that in the file, but I have another script that transforms them into this.)  So my analyze script lets me search for a given regex (Perl-style, natch) and prints a nice summary of the results, like so:2

About Buddy Burden

user-pic 14 years in California, 25 years in Perl, 34 years in computers, 55 years in bare feet.