Pages

Saturday, January 05, 2013

Redundancy Checker

As I mentioned in my last post, I've been spending some time learning Java.  In addition to the exercises suggested by the book I'm using, I've also been working on my own project, developing it as my book (Head-First Java) covered each topic that I needed.  I've finally reached the sections on the GUI and saving objects, which means that I have now completed a working alpha version of the code.

Here's what it looks like:
Screenshot from Redundancy Checker
Redundancy Checker loads an RTF file, and scans it.  Every time it finds a word or phrase used repeatedly in close proximity, it marks it as a redundancy and highlights it in the text.  That produces the output above.

You can also change the settings, controlling for how close the words or phrases need to be, and what words should be skipped for being too common:

The Options window

Finally, you can edit the text and save it.  So the program works, and does all the things I set out to do, but it doesn't necessarily do them well.  The biggest issue is that the RTFEditorKit in Java is buggy.  It doesn't read smartquotes properly, and it can lose other basic formatting too.  So loading a file, editing it to fix the redundancies, and saving it  isn't really an option.  I'm not sure how, or even if, I can fix it.  I suppose I could make my own RTF parser, but that would be quite a pain, and I don't really think it would be worth the time.

Update: One thing I've realized is that the source code for the RTFEditorKit is available. Rather than replacing it, I could edit the original. I'd have to check to see how the code was licensed. I should probably create a class that extends the kit, and then only modify the methods I need to.

2 comments:

  1. That looks like a really useful program! Repeated words are something I tend to miss in my writing.

    ReplyDelete
    Replies
    1. Yeah, it's one of those quirks that I notice about my own writing. Even at the late stages of revision, I always seem to catch a few, and who knows how many slip by me entirely?

      Unfortunately, I don't know if I'd be able to share the program, even if I can get all the bugs worked out. Since I did most of it at work (as part of my "Learn Java" task), I'm pretty sure they own it.

      Delete

I moderate comments on posts more than a week old. Your comment will appear immediately on new posts, or as soon as I get a chance to review it for older posts.