Kongzi Beta 7 Milestone 6

I’ve been working on Kongzi a lot recently. There are THREE major new features.

1. Mix and match now works again (although I suppose it always needs more testing).

2. Kongzi now supports split dictionary and user files. That means if you are running a class (versus studying on your own) each student can have their own profile but the dictionary data can be edited in one place. VERY convenient.

And 3.. perhaps the most interesting, most-discussed, and most debated feature regarding this program.. well.. what is it? Well let me introduce it to you. Recall the Browse Entries screen from previous versions; here I am showing the Chinese-English dictionary highlighting some vocabulary from the BLI system:

Image

Now, there’s a secret key; Select some entries (as many as you wish) and press F2:

Image

I’ve removed the window title to build suspense, but there is a clue in this image as to what I am working on. Are you ready to see this? It’s so awesome.. scroll down:

Image

Ahh, there it is! Kongzi’s FULLY INTEGRATED, FULLY DEBUGGED spaced repetition flashcard system!

It works off the dictionary so it’s completely configurable in every way all the quizzes are. I use it to teach myself Chinese and Japanese, and I use it to teach my students English. You can even configure your hints. I’ve included one more shot of a standard Chinese – Pinyin – English setup below; this is what you might see after clicking the “hint” button twice:

Image

Wow, I can’t tell you how proud I am of this system! It took Kongzi in a fresh direction and brought me back to working on the project big time. Although I must say, that the dual savefile structure was more difficult (in the sense that I had to keep track of a very large number of things at one time).

All in all, the dual savefile structure was really necessary for classroom instruction. That’s the biggest bit of info which came out of the recent 6 month beta test. And, oddly enough, it was sort of required for the SRS system because the SRS system would only be useful for one “user”.

So, now we’re at 0.7.6. The only thing left for Beta-8 is to add Audio quizzing. I’m a little unsure of how I should do this. There will be audio only quizzing which will repeat the word twice, but due to audio issues I may also include a “replay audio” button. That is, i’ve noticed audio issues in a lot of similar programs on a wide variety of computers, so I want to get that done right before I release it too.

beyond that, what else? A text analyzer, full-script cloze generator, and some sort of guide/helper would all be great but I think they are not going to be necessary to make a release-quality program. So after the audio (which itself might be thrown out and I’ll just release with the current set of features)… Working on those textbooks is now a big priority.

Okay so I am kind of rambling here, bouncing ideas off the wall, so that will be my decision. then. I’ll do a feature freeze now, put Kongzi back into another 2 months of beta testing to test the split savefile system and the SRS system in the classroom. I’ll work on the textbooks and stick to that June release schedule.

This is going to be a big release for me. I am very happy about this program!

If you’d like to be in the next beta test or you’d like to make any comments or suggestions, please, comment! Tell me what you want in a program like this. It’s going to be the best! Gotta be the best! ^^

Advertisements

Kongzi Beta-8 announced for June

Okay. Kongzi Beta-7 has been in classroom-use testing for about 6 months now and it seems pretty solid. A lot of changes have gone on under the hood. It’s using a database for the main type of save files now and you can merge (import) data from other files without destroying your user info. This will be tuned as time goes by, but as of now it is solid for general use.

Image

All the quizzes have gotten a swift kick up in power, they now don’t just present random items but will sometimes present items which are similar to the correct answer. To do this I have created an engine which analyzes the user’s expected knowledge level and searches for similar words .This works in any language and with sentences (shown below) as well as with words (shown above).

Another thing which I’ve done is add the list of test mistakes to the score screen for easy studying. The following example is from the dictionary I use to teach “Let’s Talk in English” to Chinese students.

Image

Once I give the manual a once-over and double check a few features on my to-do list, I’m going to have to start looking at how to package this beast.

For one, I plan to blow away the competition by offering a companion textbook with preloaded vocabulary. The MCI Chinese project (see the navbar up top) isn’t dead at all and has actually expanded with sister projects such as MCI Japanese and so forth. Here are some shots of the MCI Japanese book, “Welcome to Japanese”:

Image

Image

Image

Image

As you can probably guess I’m really excited to have reached this point in the Kongzi project and I will be able to package and offer these materials to YOU (well, to anyone) very soon. Target is this summer, around June for a complete Chinese/Japanese/Korean package which will take you from step one to “fluency”.

Thank you for keeping patient all these years. The wait has been difficult for me, too! But it is almost ready now, for real!

One step at a time..

An old draft from September 2009…

In just a few short days I seem to have come far enough that I am regaining my confidence working on this project.

I’ve re-integrated all the old logic back into the forms and re-created the “kong” and “ze” graphics from the calligraphy work I had done before. I’ve also identified several key areas which could be improved. For example, Beta-3 had a selective export feature. I asked myself, why was this necessary? If someone wanted to selectively export something they could just delete the stuff they didn’t want and then save it. So, this seems to make more sense, just save everything at once.

I also found and fixed a bug in my unicode encoder-decoder ring. Additionally I’ve completed the new export dialog design and as soon as I hook it up I can delete the old code for exporting tags and what not.

There’s just one problem. I don’t know what look and feel I was using. You can see a blue tint on the screenshots. I like that. And I can’t remember what I was doing. Ungh. I’ll figure it out later. Top priority is getting the anki/stackz-style flashcards up and running.

One step at a time… I’ve been reminded why I’ve been so successful with Kongzi so far. One step at a time, keep chewing away…

Modifying Selection Properties of a JTree, JList or JTable

I like to write programs for those times that I come up with something elegant. What I really mean by that is when I learn something I didn’t really know before. Here’s today’s challenge:

You have a very long JTree, and a need to select several things in that JTree (This could be a JTable, JList, etc.). The idea here is that if you make a mistake and click on something you will erase all your previous selections. So, you want to change the default behavior of click-select.

The why is simple: it’s a royal pain to remember to hold down the control key. Plus being as paranoid as I am about data entry I would constantly scroll up and down the list before clicking accept – just to make sure everything I needed was properly selected.

I kept telling myself how nice it would be to just click to toggle the selected status instead of having to control-click. To have toggling as the default behavior.

There are a few ways to do this, but the best way I could come up with was to handle the mouse click itself. JTree, JList, and JTable all have methods for determining which item is being clicked based on the getX() and getY() methods from the mouse event. So I declared a mouse click handler for my JTree (list, whatever). This is what it looks like:


private void specialClickSelectionHandler(java.awt.event.MouseEvent evt)
{
if((evt.getButton() == evt.BUTTON2) || evt.getButton() == evt.BUTTON3)
{
TreePath tmp = tagview.getClosestPathForLocation(evt.getX(), evt.getY());
if (tagview.isPathSelected(tmp))
{
tagview.removeSelectionPath(tmp);
}
else
{
tagview.addSelectionPath(tmp);
} // if it's currently selected
} // if it's a mouse2 or mouse3 event.

return;
}

Now, when the user right clicks, it will toggle the selection.

Digging around I found some similar code for tables and lists on Sun’s Swing Archive, but keep in mind the code there uses isPopupTrigger(), and therefore needs to be modified for cross-platform use (since isPopupTrigger() works differently on different systems – see javadoc).

You could also use this technique to change the default action of the left mouse button, which might be a better idea. I don’t want any chance of mistakenly pressing left click and accidentally removing selections off-screen where I won’t see them dissapear. Well, there’s one headache gone. Now I can relax a bit more while entering the thousands of Chinese words I need into my database 🙂

Populating Trees and Lists in Java

I’d like to comment on what went into the new Font Chooser dialog for Kongzi Beta-5. The problem can be posed as follows:

Create a dialog box that takes, as input, existing data.
Complication: Selecting a value on some lists will change the contents of the others.

Obviously this sort of design pattern would have important usages; configuration boxes, persistant user profiles, and so forth. Or, for example, a specialized Font Chooser – which is the example I’ll discuss. Take a look at this screenshot from Kongzi Beta-4:

Kongzi Beta-4 Japanese Fonts

I remember how fiendishly difficult this was to code the first time around, so the second time around I was prepared. The problem would be that I had to follow a special order: populate the language box, select the language, then use that event to populate the font box. But then I had to interrupt the normal order of things and populate the font box before I selected the font from pre-existing data. I couldn’t think of a way to do that without cutting and pasting code or creating a very convoluted logic.

But worrying about that before I wrote any code would drive me insane. So I plunged in head first, fleshing out the dialog box in Netbeans, then adding several methods to find and select values in the list, such as “SelectLanguage(String)”. That way whenever I wanted to, I could populate the dialog box with pre-existing data, in this case, the language and font data that had been selected previously. This is important, of course, to provide a smooth user experience.

Then the nasty null pointer errors started. Basically because of the logic/flow problem I described above. The logic for populating from pre-existing data, and the logic to modify itself based on user input, was too difficult to reconcile. When I tried to populate language, the size box wouldn’t be populated yet, so I couldn’t preview sample text for the new language. If I tried to populate the size box first, this would also trigger a preview event which would crash. The workaround in Kongzi Beta-4 was to include a preview button as shown in the above screenshot. Then I was technically excused from having to do anything. But just because I put a button on it doesn’t mean it wasn’t a giant kludge. For Beta-5 I wanted something smoother. I wanted to use the same logic at all times, the same entry points, and I didn’t want a preview button. I wanted selection events to populate everything.

The key to my final solution was in realizing that when I sent commands to the lists, such as fontList.setSelectedIndex(i), I was going to trigger events which would send me back into the auto-population and auto-selection methods. This is how it had to be, to avoid cutting and pasting code, making a terrible mess. Yes, I wanted to follow “accepted practices” of reusing the same code which auto-populated the lists to accept events and propagate their own data to other lists. Doesn’t everyone?

The first idea I had was checking for null pointers and then skipping over those lines of code. I rejected this almost immediately because of the difficulty it would present to doing any sort of error checking. I would in essence be assuming that any time I encountered a null pointer, I knew why it was there; and that was simply untrue. To write proper code, I would then have to write a second check to determine if the null pointer was there because there was a bug, or simply because the dialog wasn’t fully populated yet.

Or, as an aside, populated properly. I saw the potential for sloppy logic to start creeping in, caused by my abuse of checking for null pointers. In horror, I imagined several cases where entire blocks of code would never execute because they would always be called at a time when null pointers were there. I imagined terrifying cases where a population function would be called four, five, or more times, each time getting sent back with a null pointer, until the dialog was finally ready to accept the input. I recoiled from checking for null pointers, and resolved to find a better way.”

After staring into the monitor for a while, I came up with the idea of using boolean flags to keep track of what procedure I was in. The solution worked like a charm. I created several class-wide variables such as “boolean populatingFontList”. Any time a method dialog was performing an operation on a list where the selection would change as an unintended consequence, I simply set “updatingFontList” or “updatingSelectLanguage” (or whatever) to true. Then, at the beginning of that function (and any other appropriate place) I would put in a clause which prevented anything bad from happening. Usually something like “if (updatingFonts) return;” at the beginning of a troublesome function.

populatingSelectLanguage = true;
selectLanguage.removeAllItems();
populatingSelectLanguage = false;

Then when the program fires off it’s little events as a result of you removing whatever item was selected, you wont get an error because the font list isn’t populated yet. And so forth.

Kongzi Ressurection

You may not know this, but after the last blog post (about Kongzi) back in January 2008, a series of unfortunate events pushed me farther and farther away from developing Kongzi.

I’d like to list them here to help ease my mind. And why, because I’ve decided to focus on finally finishing this promising project.

For one, after I had completely removed all the netbeans auto-gui code, I figured out how to turn off reflection in the gui generator. It all came crashing down. “Shit,” I thought, “I just wasted several days of work”. What was worse is that I would have to redo all the forms because although I had a recent backup I was spending so much time on the project every day that it felt inconceivable to me to go to an old backup. Version Control. Yeah I know, I tried that. It’s a pain in the ass. I don’t want to comment on that. I’ve tried many version control programs for unix, windows, whatever – none of them appealed to me.

Anyways.

I text edited the original files and put back the IDE tags I had removed. So I wasted about a week on that whole adventure. But I finished it and resumed working on the project. Then I did something really dumb, I tried to install a version control system. Version Control systems are great – for large, multiuser projects. For something like this it is a TOTAL waste of time. Backups would have been better. So I lost all my work because the version system wasn’t installed properly, or I typed the wrong flag, or whatever. Poof. You know, I had tried to use version control systems before, really. I am not a novice user by any means. But this was the last straw. I actually had a system up and going which backed everything up for me. But losing all my code.. For fuck sakes – and I do not swear in vain – if I am going to have to back it up anyways I will simply not waste my time with a VCS of any kind.

So you know what I did, I did it all over again.

This is late January now. The program was going exceptionally well. I had all the features I had before. Then I did something which taught me a lesson. I started working on the licensing aspect of the program and I got bogged down. I didn’t really want to work on the licensing and the licensing aspect was boring. Slowly the code started to break in places because it had to be slightly redesigned to work with the licensing code I had written. So I lost interest. This is February now and I posted about how I felt but I didn’t say why I had been losing interest.

A few months later I had a motorcycle accident and I couldn’t type or write for a week or two so that was a problem as well. So by this point I was also into guitar and videogames for a while – well I had always been into games like Hitman, Halflife, Max Payne and so on and that sort of occupied my time. That and work. So I had totally given up on the project.

Now, get this. For some reason I seem to have lost my backups of Kongzi.

I don’t mean all my backups. I mean the “recent” backups from February. I’d just as soon snip out all the licensing code and work on the main project a little more but I can’t. So here I am. What am I gonna do.

First I have to justify why I want to do this. Oddly enough although I am working more than I ever have, I see many ways in which I could use Kongzi at work to help me teach English. Especially now that you can get a mini laptop for under $300. What a deal! Or perhaps it could run on one of those phones with windows mobile or a Palm (if they even make those anymore) and so on. I have a lot of ideas. I always did.

I mean, they sell those little electronic dictionaries. I could use that. But with Kongzi I could tailor it to the needs of an English Teacher. I could sell it as a package – a mini laptop and software. I’d make a lot of money like that. Lol. Or something.

So here’s what I did.

1. I pulled up all my old backups. Dec 17th. Dec 30th. January 3rd.
“Aww crap,” I said to myself. I lost a lot of work. Over a week and a half of amazing stuff.

2. I identified the Dec 30th backup as the day before I gutted the GUI code.

3. I put the Jan 3rd backup and the Dec 30th backup into the latest netbeans (installing, which, was an adventure all it’s own but there really is nothing better.. time has certainly shown who won the recent IDE wars)

4. I started bringing the Dec 30th backup “up to speed” with the Jan 3rd backup, minus all the form removal code. File by file. This will serve many purposes least of all refamiliarizing myself with the code.

When I am done, thank god, I also have those extremely convenient screenshots of what I was doing with Kongzi at the time I gave it up, so it should be trivial to redo the ten or so days of work I lost. And given more than half that time was spent on the irrelevant licensinc code… I am actually pretty excited about this now.

All things considered I could have Kongzi NeoBeta ready to accept new code by early October.

By Halloween I should have more work done on Kongzi than ever. By Halloween I expect to start spending most of my time working on the dictionary. By the end of the year I expect I could be completely finished this with a real live distributable CD.

Hmm. Let’s reintegrate that code and look at the screenshots of Beta-4 first 😦

Kongzi on Hold, MCI textbook scrapped

Well, I’m scrapping the MCI Chinese textbook. The reason why is because I discovered LIVE Interactive Chinese Magazine. LIVE is basically exactly what I wanted my MCI textbook to be, minus a proper textbook introduction to the language.

Since anyone interested in learning Chinese will probably pick up a few hundred words on their own, LIVE completely serves the niche I wanted to fill with my textbook. So thats been placed far far back on the back burner.

Kongzi. Well, I’ve had a lot of good feedback so far, and I now have “too many” beta testers 😉

I am currently experiencing a higher workload at my job, and I no longer have that extra 2 or 3 hours a day to both work on kongzi AND play all my videogames. Plus I love playing with my son too. Yes, it’s an excuse, but a damn good one 🙂 I likely won’t feel like working on Kongzi until at least march, and likely not until June since I am going to visit my family around that time and when I get back I’ll have a pretty clean slate project-wise, so working on kongzi should be a priority. Thing is, because of work I don’t have much time because I’m also training tai chi. :/ My spare time is mostly taken up by videogames. And by that time I’ll be on GTA4 for sure, and I don’t know when I’ll come down from that one. I’m still kinda playing GTA3: San Andreas again because I keep thinking about GTA4.

I probably shouldn’t be so lazy about Kongzi. Well, Golden Week is over now so maybe I’ll take another look at it this week. Funny thing, when I’m vegging out I don’t feel like doing anything at all, when I’m actually working on the thing I can’t stop coding

Ok. I *promise* i’ll flip a coin about clicking on netbeans.. tomorrow 🙂