We illustrate SMARTedit by showing how it automates a simple text processing task. Suppose the user has some HTML with comments embedded in it and would like to remove the comment tags and all the text inside the comments. An HTML comment is a string delineated by the tokens <!-- and -->. The comment may span multiple lines and contain arbitrary characters. In order to delete all such comments, a Microsoft Word user would have to enter a regular expression of the form \<!--*--\> into the search-and-replace dialog box. While this syntax may look straightforward to programmers, even this author took several tries to figure out the correct syntax to use for that regular expression. In SMARTedit, however, no arcane syntax is required. The user simply demonstrates the desired functionality by deleting the first HTML comment, and the system is able to do the rest. Let's walk through this example to illustrate exactly what SMARTedit can do.
SMARTedit works like a simple macro recorder and follows the familiar macro recording interface. To begin creating a SMARTedit macro, the user pushes a start-recording button. The button then turns red, indicating that her actions are being recorded. She then begins demonstrating what she wants SMARTedit to do. In this task, she first moves the cursor to the beginning of the next HTML comment, right before the <!-- characters, using any combination of cursor-motion keys or mouse clicks. The blue block is the position of the insertion cursor; the status bar indicates that the user is recording, and the record-button has turned red to indicate recording is active.
She then presses the delete key to delete the entire HTML comment.
After completing the demonstration, the user presses the stop-recording button to indicate that she is finished. At this point SMARTedit has constructed a version space containing only those text-editing programs that are consistent with the demonstration the user has just performed. The user can now ask SMARTedit to execute its learned program by pressing the "Step through macro" button. SMARTedit then guesses what action she's likely to take next.
SMARTedit's first guess is that the user wants to move the cursor after the next occurrence of the string "ample", with 36% probability. Obviously this is incorrect. However the reason SMARTedit guessed this is because the first HTML comment happened to come after the word "sample" --- SMARTedit is examining the context surrounding each action to figure out why the user had moved the cursor to that particular location.
Since this guess is wrong, the user presses the "Try another guess" button to cycle to SMARTedit's next most likely guess: moving to the start of the next HTML comment, with 26% probability.
This guess is correct. SMARTedit was initialized with a hypothesis space containing all the text-editing actions that its designers thought users were likely to want to perform. Given a demonstration, SMARTedit removes all the hypotheses from that space that are inconsistent with the demonstration. The remaining consistent hypotheses form SMARTedit's predictions, ranked according to probability.
After the user verifies that SMARTedit has performed the correct action, she steps to the next action by invoking the "Step through macro" button again. This time, it correctly predicts with 26% probability that she will delete the extent of the HTML comment. The action is visualized by striking through the region that is to be deleted, rather than deleting it without warning (which caused confusion in an earlier implementation).
The user has now finished deleting the second HTML comment in the file. When she then invokes the "Step" button again, SMARTedit immediately positions the cursor at the beginning of the next HTML comment with a very high probability (93%).
SMARTedit has been learning from its interactions with the user. At this point it has learned from two demonstrations: the first where the user deleted the HTML comment by hand, and the second as the user corrected SMARTedit's guesses.
Once the user is confident that SMARTedit has learned the correct program, she can invoke the "Run program" button and SMARTedit will continue executing its learned program until it runs out of HTML comments to delete.