200 likes | 421 Views
FREEDIC. A SymbianOS based multilingual dictionary for the Nokia 7710. Contents. Load Dictionary file Dictionary class design Database Lookup Function Plan to show main GUI window Implementing main GUI Window and source code. Load Dictionary file. Format of Dictionary file
E N D
FREEDIC A SymbianOS based multilingual dictionary for the Nokia 7710
Contents • Load Dictionary file • Dictionary class design • Database Lookup Function • Plan to show main GUI window • Implementing main GUI Window and source code
Load Dictionary file • Format of Dictionary file • Contain three files - .ifo .idx .dict • .ifo file describe general information about the dictionary. # of word entries, etc. • .idx file is a index file of .dict file. It record word string and its offset in .dict file. • .dict file contain the detail translation and explanation of each word.
Load Dictionary file • How is it load into memory? • Very important to reduce memory consumption.
Dictionary class design • The dictionary will be divide into following classes. • Application core class contains GUI, and it generally describes all functions of the e-dictionary. • Libs class contains all dictionaries, and it handles all the function calls from AppCore, and forward them to each Dictionary. • Dict class contains everything about a particular dictionary, the INDEX file, the DATA file, and how to lookup a key word in dictionary. • Index class only deal with index file, constructing the page table, looking up words from index and return its offset in DATA file.
Database Lookup Function • Three type of lookup function
Database Lookup Function • Interface of Lookup Function • bool SimpleLookupWord(const gchar* sWord, glong & iWordIndex, int iLib); • sWord is the string of the keyword, • iWordIndex will return the offset to the DATA file • iLib will determine which dictionary to search. (Since it is will load several dictionary page table into memory.) • bool LookupWithFuzzy(const gchar *sWord, gchar *reslist[], gint reslist_size); • sWord is the string of the keyword, • reslist[] will return a group of similar word entries. • reslist_size will determine maximum similar words to find. • gint LookupWithRule(const gchar *sWord, gchar *reslist[]);
Database Lookup Function • Source code for lookup page table & entries within a page while (iFrom<=iTo) { iThisIndex=(iFrom+iTo)/2; //divide the table into half cmpint = stardict_strcmp(str, get_first_on_page_key(iThisIndex)); //comparing if (cmpint>0) // if the word is in second half, iFrom=iThisIndex+1; //reduce searching range by cutting first half else if (cmpint<0) // if the word is in first half, iTo=iThisIndex-1; //reduce searching range by cutting second half else { // if the word is found bFound=true; //mark the flag break; //need no more search, break the loop } }
Plan to show • Format of Dictionary file • The main GUI window will be used for users to input text for dictionary searches. • Left pane : text editor for search word and list of matches • Right pane : contents or details for the currently selected word • As the focus moves within the List pane, the right pane updates dynamically.
Implementation Main Window • Main menu • Dictionary file • Select Language • Background • Exit
Main Menu details • Dictionary file • Select the dictionary database among several dictionaries • Select Language • Select the language what we want to know that’s meaning • Background • Call the background process function • This will be explained later. • Exit
Source code for main window - 1 • Code for Text Edit Box RESOURCE CONTROLS texteditor_view { controls = { EDWIN { flags=0; width=5; lines=1; maxlength=20; } }; } RESOURCE TBUF texteditor_view_label { buf="Input:"; } CEikEdwin* iEdwin; iEdwin = new ( ELeave ) CEikEdwin(TGulBorder::ENone); iEdwin->ConstructL(CEikEdwin::EOnlyASCIIChars,10,32,5); iEdwin->SetContainerWindowL(*this); iEdwin->SetPosition(TPoint(20,20)); RESOURCE TBUF texteditor_view_label { buf=""; }
Source code for main window - 2 • Code for Text List Box RESOURCE ARRAY r_textlist_array_strings { items= { TBUF { buf="My List Item 1"; }, TBUF { buf="My List Item 2"; } }; } RESOURCE LISTBOX r_freedic_textlist { array_id=r_textlist_array_strings; } RESOURCE DIALOG r_textlist_dialog { // specify the title, flags, and buttons if needed items= { DLG_LINE { type=EEikCtListBox; id=EMyTextListbox; control=r_textlistbox; } }; }
Background monitoring • Monitor the clipboard and events from the background • Currently works on the emulator but not on the hardware
Future work • Loading dictionary • Read index and dict file. By 4.8 • Construct page table. By 4.15 • Searching algorithm • Port simple search algorithm By 4.29 • Port other search algorithm By 5.6 • Implement B-plus-tree structure for Asian word searching. (Optional)
Future work • Problem in Main GUI Windows • Controls like Text edit box and Text list box was not viewed • Searching the solution of this problem in several sample source code and posted Q&A in Nokia Forum webpage • Implementing “Select Language” menu with Combo Box
Future work • Display Asian fonts • Monitor events from the background in hardware