Mathieu Tozer's Dev Blog

Cocoa, the development of Words, and other software projects (including those dang assessment tasks).




Words: Lookup


E-mail this post



Remember me (?)



All personal information that you provide here will be governed by the Privacy Policy of Blogger.com. More...



Since I've hit a bit of a wall with smart lists (ideas anyone??), I'm going to put it aside and try to develop in isolation another hairy part of Words. The definition lookup feature.

By isolation I mean that I will start a new project, with a simple UI that is the front end to the lookup class (or classes) that take a word string as an argument, and return 'definition' objects. This is how I envision the system will work.

The following are the notes I took today while thinking and devloping what the screenshot shows below. They don't flow very well!

While I am aiming for language generality, I still believe that there will be language specific things that will need to be handled by a subclass of the generic 'dictionary' object.

LookupUtility has the function "(NSArray *)lookupWord:(NSString *)word inDict:(Dictionary *)dict" which is the interface for whatever needs to lookup a word in whatever dictionary. It returns an array of definition objects for word.

There should only ever be one LookupUtility instance per application.

This diagram shows neither the lookup utility (as I scrapped it in the end) nor a generic 'dict' protocol class (yet to be implemented).

Dictionary is an Abstract Class. The application should create instances of a Dictionary subclass that is applicable to the particular user's needs. Ie, If a user has specified that they are learning Japanese and their native language is English, then the application should instantiate a JapEngDictionary object that can churn out definitions when queried with a string.

The DictProtocolDictionary can be instantiated (not shown in the image), one for each dictionary that can be accessed via the dict protocol. In the user interface, the user might be able to cause this to happen

The user should be able to select which dictionary object the application should use to find definitions to their words by default. The application controller (delegate) should keep check of what dictionary objects are available (a dictionary manager view??). From here a user might be able to select a word and search again in dict:selectedDictionary for example, if they feel they can find better results elsewhere.

So to make the development easier and modularised from the main Words app, I am starting Lookup.xcodeproj (or whatever that filename is these days). With luck, the classes I develop should be able to be imported directly into Words and hooked up to the WordsAppDelegate no problem.

Because Lookup.application doesn't really need to STORE anything, I'll use the Cocoa Application template from within Xcode.

I've created a simple interface in IB, and have created AppController, with an action 'search' and an outlet 'wordToLookup'. Later I will add two NSArrayControllers, which will control the Dictionary and definition objects contained in the NSArrays returned by the dictionary objects. Bindings should take care of the display of this.

First I am going to check that this structure works by creating the classes with stubs that return static example Arrays.

Actually, I've just realised that the AppController doesn't control which dictionaries are available, the NSArrayController called dictionaries does. It can co-ordinate adding and deletion from the model... but in fact we don't want it to be able to do that. We want to do that programatically by asking the Controller nicely if it would please add this new dictionary object we've just created to its trusted care. Then we can autorelease it :-)

Ok, so now I've got some to-be dictionary object in the array.

How I handle these dictionaries has to be separate to how they work.

Later on that night...


I believe I've got the mechanics of it working well. Next step is to test whether its architecture is suitable for scalability. I'll create a new class for a French and English dictionary, and see if I can add it to the list of dictionaries, and ask it for definitions dynamically. Wait a sec... Yahaaa! I had checked 'Automatically Prepares Content' - a throwback to my yesterday Code Data ways. Of course, It's not to automatically prepare any content at all - I'm deciding to do all the work! This also explains the added extra definition object that was being automatically prepared in the Array.



So there I have it, a kind of 'framework' for me to handle multiple languages. A little simplistic, but a proof of concept.

Next is nothing but
1. Adding the code to actually access the dictionary databases (probably messy)
2. Parsing the results into nice rich fields that can go in the definition class / entity.
3. Creating as many Dictionary class subclasses for the dictionary databases that I can find.

And then attaching the whole lot the main Words app and running it all on each word that is input.

---

Brainwave. Have a thesaurus as well so that writers can use Words to search for alternative words, and keep track even of when they have used them.


0 Responses to “Words: Lookup”

Leave a Reply

      Convert to boldConvert to italicConvert to link

 


+RSS | dev blog | Portfolio

About me

My status

Previous posts

  • my del.icio.us
  • my flickr