Pages

Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Wednesday, January 16, 2013

Redundancy Checker update

A week ago, I discussed my travails in getting my Java program working.

After some hunting, I've found an improved version of the RTFEditorKit at this site--an AdvancedRTFEditorKit. It's still not perfect, and it still loses smart quotes, but it does allow you to subclass its classes, which is something the old RTFEditorKit did not allow. You could subclass the kit itself, but not any of the classes it used to do the real work, which is what I needed. By subclassing the new RTFReader, I may be able to do some preprocessing and post processing in order to deal with the idiosyncrasies that are showing up. Unfortunately, some experimenting showed that my original idea (replacing \'93 with \ldblquote) won't work, though I suppose I could replace it with straight quotes.

It's all very annoying.  The whole idea of object oriented programming is that I wouldn't have to write an RTF reader from scratch.  I'm beginning to wonder just how much time I'm willing to dedicate to this.

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.