






Hotspots: Admin Pages | Turn-in Site |
Current Links: Case Final Project Summer 2007
BwL M7
The writeup for this milestone is here: Fall 2003 M7: Expand your Guide's functionality
Our Final UML

Three things were required for this milestone, so it wasn't too bad. We were given a list of 5 tasks to create for our Guide (to show that our engine was flexible enough to be changed quickly to use other tasks). During a demonstration, we had to account for the fact that the user may not have performed the task, or did something crazy. Basically it meant we had to check for dependencies from previous steps in the task.
Parsing Free Form
We had to update our search feature with the ability to parse free-form text. Joe created a parser to do just that. He kept his already-written search parser to tokenate the search string by spaces:
aString findTokens: ' '.
Then he wrote some methods to find all the punctuation in the tokens, then lowercase all, and finally omit frequently used words.
- doParse - This method first loops through the collection, doing the procedure on each element. The procedure is as follows:
- Get the current token as a string
- Create a temp string for the compilation of "to-keep" chars
- Get each character in the token and do the following:
- Get each char in the token
- Call checkChar to drop out the punctuation (checkChar is below)
- If checkChar returns true (to keep the char) copy it into temp as a lowercase char
- Drop the token if it is in the omitList
- Add it to the list of parsed tokens
doParse: aCollection
"Parses the free-form text"
| parsed cur temp curChar |
parsed := OrderedCollection new.
1 to: (aCollection size) do: [:index |
cur := (aCollection at: index) asString.
temp := String new.
1 to: (cur size) do: [:pos |
curChar := (cur at: pos) asCharacter.
(self checkChar: curChar) "Dropping out the punctuation"
ifTrue: [temp := temp copyWith: curChar asLowercase].
].
(temp) ifNotNil: [
(temp isEmpty) ifFalse: [
(omitList includes: temp)
ifFalse: [parsed add: temp].
].
].
].
^parsed.
- checkChar - This method returns whether or not the character sent to it should be kept or removed. Basically, I used an ASCII chart to get the values of all the punctation on the keyboard. Then I took the character value passed in, got the ASCII value for it, then made sure that it was not in one of the ranges of punctuation.
checkChar: aChar
"Figures out whether a character should be in the list or not, and returns true/false"
| val |
val := aChar asCharacter asciiValue.
((val>=33) and: [val<=47]) ifFalse: [
((val>=58) and: [val<=64]) ifFalse: [
((val>=91) and: [val<=96]) ifFalse: [
((val>=123) and: [val<=126]) ifFalse: [
^true.
].
].
].
].
^false.
Demonstration Engine
The way we set up our tasks involved putting a lot of code into the XML task files. The files actually made function calls to move the avatar around, open windows, and manipulate squeak in different ways. Some of these tasks were repetetive, so, rather than recoding them in each XML file, each repetetive task was put into the demonstration engine (basically used as a function library). Here are some of the ingenious functions found inside it:
- blueClick - simulates a "blue button" mouse click
blueClick
"blue click the cursor"
| mouseDownEvent mouseUpEvent |
mouseDownEvent := MouseButtonEvent new
setType: #mouseDown
position: playHand position
which: 0
buttons: 0
hand: playHand
stamp: Time millisecondClockValue.
mouseDownEvent toggleBlueButton.
mouseUpEvent := MouseButtonEvent new
setType: #mouseUp
position: playHand position
which: 0
buttons: 0
hand: playHand
stamp: Time millisecondClockValue.
mouseUpEvent toggleBlueButton.
"click the button"
playHand handleEvent: mouseDownEvent resetHandlerFields.
DemoEngineLib wait: 50.
playHand handleEvent: mouseUpEvent resetHandlerFields.
- type - this message types out text a character at a time, sort of like a typewriter effect
type: text buttons: buttons
| typeKeyEvent |
text do: [:char |
DemoEngineLib wait: 100.
typeKeyEvent := KeyboardEvent new
setType: #keystroke
buttons: buttons
position: playHand position
keyValue: char asciiValue
hand: playHand
stamp: Time millisecondClockValue.
playHand handleEvent: typeKeyEvent.
].
- initialize - this code sets the cursor and world up for manipulation by the demonstration engine's functions
initialize: startPosition
"init our cursor"
playHand := HandMorph new.
playHand position: startPosition.
World addHand: playHand.
playHand newKeyboardFocus: World.
playHand userInitials: 'Demo' andPicture: nil.
To understand some of this, you really need to look at the XML syntax, some of which is right here -> Task 2
After a few tweaks to the step-viewing bubble's "showme" and "next" button code, Wes and Luigi worked on adding the "check" code (this code checked to see if the user had done what the step said, and if not it ran code to do it for the user).
Links to this Page
- Bears with Lightsabers last edited on 7 December 2003 at 1:59 am by ga-cmng-cuda1-c6a-a-78.atlaga.adelphia.net
- BwL M3 last edited on 7 December 2003 at 3:01 pm by colima-win.cc.gatech.edu