
Annecy.France
看了點文件,想說就來寫寫東西吧,從最簡單的開始。
= = =
另外,沒想到有人替eblib包了個python wrapper!!
Link: http://code.google.com/p/pyeb/

Taidon.Taiwan
Oh, I will survive too, even under this kind of tremendous pressure.
Just....don't bite me. It hurts.
====
Here are some notes about what obstacles I encountered while writing this small app.
1. use python 2.5 instead of python 2.6
If you are using python version other than 2.5, it'd better that you install python2.5 too.
It will prevent you from bumping into a out-of-nowhere debugging error.
(I spent some time on finding this out on my ubuntu 9.0)
2. There's new_project_temple folder in the SDK root directory. That's where you can start with.
3. Do not use urllib from python library. Use urlfetch from google.appengine.api instead.
4. You can only upload/update your files to google app server, but you CANNOT download these files from the server!!
So, remeber to back up your files and use version control systems by yourself.
LINK:
http://onlinedict.appspot.com
REF:
http://code.google.com/intl/zh-TW/appengine/

Ricoh GRD
Annecy, France
2008.06.22
la Fete de la Musique
很難在午夜時分,還能在安納西看到這麼多遊客。
****
onlinedic的word list目前使用上還算穩定,
所以今天把這個branch merge到主要的trunk上。
久沒用tortoisesvn了,只好再查一下它的用法。
下面是官方網頁的解釋:
Merging

(Ricoh GRD Semnoz, Annecy, France)
滑雪滑到一半遇上大雪,多少會讓人覺得很掃興。
買的是一日券,少溜愈多虧愈多。
看著屋外一字排開的滑雪用具和空蕩蕩的桌椅,
還是快進到餐廳裡取暖吧。
****
I need to write it down here to prevent that some day my no-so-working brains forget how I did it. Actually it's not so complicated. Here's the steps:
1. download eb-3.1.tar.gz and compile it. You will find dynamic libraries under eb/.libs and zlib/.libs.
2. download ebmodule-2.0. Modify setup.py and ebmodule.c
2.1 change library path and include path to where you put eb libraries and eb headers.
2.2 modify ebmodule.c. The "static char" is not well written. So gcc will complain about it. You have to modify all the "static char".
2.3 compile! Voila. If everything goes fine, you can test your eblib.py or test.py.
I uploaded a modified version of ebmodule-2.0 (compiled python lib included) to my googlepage. You can find everything you need in the file to start programming with ebmodule. Have fun!
REF:
EB Library
DOWNLOAD:
compiled ebmodule-2.0 module and modified source codes

(Biie, Hokkaide)
一直很討厭在查單字時還要輸入法語的音符,雖然之前找到的輸入方式已經很簡單了,但是如果能夠只輸入一般英文字母就能查詢的話,不是很輕鬆嗎?
要在某些地方偷懶,就要在其他地方付出。
於是,我把Larousse的字典export出來,重新生出了新的字典,裡頭包含了單純字母組成的單字,然後在解釋部分,利用=>來指到原始的單字。另外在stardict.py裡頭,加上識別=>的程式碼。這麼一來,以後就可以只輸入字母查詢啦!
原本Babylon格式的字典檔,也可以支援syncronym,不過我怎麼樣也試不成功,所以只好用自己爛爛的workaround。Anyways, it works now~~

it's awkwardly implemented yesterday. The word list support was not considered in the original design of Dict module so it's hard to find a place to fit it in.
Finally, I decided to add a default function for Dict base class: get_word_list(). Currently, this new feature is only supported for dictionary files with stardict format .
After calling match() from FileDB in stardict module, it will not only return the word explanation, but also provide a list of words that are before and after current word.
When the MainWindow receives SearchDone event, it will upate the left side panel if word list is available. If not, the word list panel won't be displayed.

(Ricoh GRD Cannes, France. 坎城小火車)
南部每個鎮都會有逛市區的小火車,帶著你穿街過巷,在較短的時間內一覽當地名勝和景點。價錢大都落在5歐到10歐之間。車上一般會提供英文和法文的解說,可以帶上耳機或是由司機直接口頭介紹景點。行程則大概是二十分鐘到三十分鐘之間。
我只有在馬賽突然心血來潮坐了一次,登上了馬賽著名的教堂,俯看整個馬賽港。一路上車子緩縱上坡,和兩旁的行人擦肩而過,吹著微風。
****
Psyco,一個號稱可以加速python程式執行速度的module。只要加個兩行code就可以見效。雖然我看不大出來效果,不過還是在onlinedic中加入了這個功能。Psyco需要從其官網另外下載套件才行,目前支援linux和Windows。
REF:
IBM網站上的介紹
Psyco官網

(Ricoh GRD Marseille, France. ile d'if)
到馬賽沒上伊芙島,大概算不上是到過馬賽吧。不過伊芙島卻一點兒也不吸引我。來回的船票要十歐,上了島,還得一定要再交五歐參觀Chateau d'if才行。(如果有買馬賽一日周遊券的話,會比較划算,因為20歐裡面便包含了來回船票,城堡門票,還可以參觀很多市區內的博物館,一日的交通票,Tram,地鐵,巴士坐到爽,還可以坐上山的市區觀光小火車)。可惜我發現有一日券的時間太晚了,所以沒來得及買。
從伊芙島往陸上看去,海的顏色是漸層的,很夢幻。很多家庭拿著食物,就在城堡四周野餐起來,完全不介意這曾經是個關犯人的地方。小時候看過的"基度山恩仇記"早就忘光了,所以不大體會得到被關在這兒的痛苦。
****
from long time ago, I've kept trying to add supports of global hotkeys for onlinedic; however, it's always in vain. Tonight, I finally found a way to achieve it!!! (though it only works for Windows platform) Why didn't I find the API earlier, I keep wondering....
This feature is supported by wxWidgets. As consequences, it's been ported to wxPython too. Actually it's quite easy. All I need to do is to invoke RegisterHotKey provided by Frame.
self.RegisterHotKey(
self.hotKeyIdToggleScan, #a unique ID for this hotkey
MOD_WIN, #the modifier key
VK_F3) #the key to watch for
The usage of the parameters are rather obvious. The last two parameters should be filled in by definitions from win32con. If you don't have installed win32 extension, you can just find out the right definitions you want to used by the second following references.
Once you want to quit the program, you have to unregister the hotkey:
self.UnregisterHotKey(self.hotKeyIdToggleScan)
REF:
Sample of RegisterHotKey for wxpython
Virtual Key Definition in win32con

Though VocabReview ( a small program that I wrote for Windows Mobile system to display vocabularies that have been exported to a text file) works well on my dopod818, I found out that actually I spend more time on my PC than on my PDA. Well... I am kind of otaku, I do not go out often. So, I think it's probably a good idea to create a similar program on my PC too. In this way, I can review the words while I am surfing on the internet.
Since it'll be used on PC, that means I can still use python as I did for onlinedic. It turns out using python is a right choice. I just spent one night to finish this little program, comparing to several day's work I've done for VocabReview on Windows Mobile. Now, it is well integrated into onlinedic too, though it can be used separately.
After updating files on svn server, you can trigger it by using hotkey Ctrl-R, or click it from menu > File. By default, it will open the export file defined by onlinedic and display the vocabularies. You can click "Toggle" button to change the display as the following screenshot.
In the near future, I may change the layout to make it smaller with alpha blending, so that I can put it on the top of the screen. And...the feature manage words (add/remove words) too.

( French Verbs Conjugation)
在很早期,onlinedic就已經加入了法文動詞變位查詢的支援。
當時是直接把別人寫好現成的library拿來用,
因為原本的library就已經有我想要的API,所以沒有特別改什麼。
用了好一陣子之後,覺得它在呈現HTML格式時,有點不大人性化。
從上表可以看出,主要的動詞變化有十一種。
原本的呈現方式是一長條的。
也就是說,以目前的視窗大小,只能看到前三到四種變化。
後面的變化得要透過一旁的捲動列來向下拉才看得到。
對於這點我一直不是很滿意(我實在是太懶了…)
所以今天看了一下Conjugator部分的code,
在convertToHTML的部分加了點code,
讓輸出HTML格式時,能夠以table的方式表示。
這麼一來,我想要有幾欄,有幾列,都變成是件很容易的事。
瞧上面的表格,多麼一目瞭然啊!
Open source就是有這種好處。
只要會一點點程式,遇到使用上不順手的情況,或是看不順眼的地方,
就可以自己動手DIY一下,讓程式符合自己的需要。

(Olympus E300 France.Chamonix)
週日有到夏慕尼滑雪的活動,光是車錢就要18歐。
如果再加上一整天的forfait的話,大概總共要50歐。
還在考慮中…
****
今天在網上找資料時,看到有人說wordreference的解釋比較精確。
我去找了幾個最近在學的les mots familiers,它裡頭大都有明確的英文解釋。
所以,早上花了點時間把它也加到onlinedic裡頭。
跟其他網站不一樣的地方是,wordreference會檢查request的header,
看user-agent是不是一般常用的browser,如果不是的話會擋掉該request。
這麼一來,python提供的最基本的
urllib.urlopen
就派不上用場了。
上網看了一下,要改掉預設的user-agent,得要改用urllib2才行。
大致上的code如下:
import urllib2
req=urllib2.Request(url=url_line,headers={'User-Agent':'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.6) Gecko/20040113'})
f = urllib2.urlopen(req)
source = f.read()
嗯~又多了一個好字典 :)
相關連結:
WordReference

When I read Harry Potter III, I used three instances of onlinedic: one in Chambers Francais Anglais; one with XMLittre, Francais-Francais Dictionnaire; one in woaifayu-fc 我愛法語法漢字庫.
Most of the time I used the third one, because I can quickly grab the idea of the word, and move on to the following details of the plots.
However, the content of woaifayu-fc (a dictionary file from stardict website) is not well orgnized. All the explanations are crammed together. It's hard to find the meannings that I want.
So, I did a little modifications for the display of woaifayu-fc. As you can see in the screenshot, explanations are separated out with green colored font.
It'll work better when I export them out to text file and read by my ReviewVocab on PocketPC.
:-)

(Ricoh GRD Annecy. Yellow Leaf)
I use my onlinedic a lot recently both in Windows and Ubuntu, for looking up tens or hundreds of french vocabularies coming from notes of classes or from the Harry Potter novel. Under such heavy utilization, I found it quite intolerable for two things:
- I need to check the verb deconjugation first, to see wheter the transformation from, and then, look up for the meaning of the word. If I want to export the vocab in a file, that will be two times of the effort: one for deconjugation, and one for the vocab meaning.
- After exporting explanations to a text file, I can review it in my PocketPC simply by a text reader. However, it's hard to move to the next word or the previous word due to the long explanations for some common used words.
As for the second problem, it will take me longer for coming out a feasible solution. I may need to write a specific application on PockePC to read the exported text file. It will parse the content and make movements between words easily by just clicking on navigation keypad.
I hope I can finish it as a small programming practice sooner or later this week.

(Ricoh GRD 颱風來臨前)
When using onlineDic under Windows platform, I will hide the main window if I am doing other things rather than looking up words in the dictionary. When I want to activate onlineDic again, I will click on the Taskbar icon. But most of the time, although the main window reappears on the task list, it won't move the top layer. As a consequence, I have to manually click on the task list to bring it to the front.
Today, I found the solution.
After calling frame.Show(true), I should also call frame.Raise() to get the effect I want. : ) This feature is not included in 0.9.3. If you want to have this, you can update your svn source, or just add the line in wxGUI.py.

(Ricoh GRD CompanyView 20070814)
雖然已經買了Babylons的字典,但是常常還是會使用自己寫的onlineDic;尤其是在linux底下,Babylons不行用,非得用onlineDic不可。目前光是menu item上列的字典分類,就多達八種,更別說每種分類下,一大串的字典項目。
在主要的視窗上,因為可以把字典依據不同語言,分到不同的選單下,所以不至於造成選單過長;但是,在工具列上的選單,就沒那麼順利了。原本的作法是把所有的字典一字排開,外加Scan, Restore, Quit等選項。遇到螢幕小一點的情況,就會發生整個選單無法一次把所有選項列出的窘況,得要scroll好久才能回到Scan的選項。
這兩天,花了十幾分鐘把它做了修正,讓它可以跟主視窗一樣,依照不同的語言來分類。這麼一來,就不會列一大排了。
****
另外一點是,在用firefox時,雖然可以利用AutoCopy來選擇要查詢的字串,讓onlineDic可以做查詢的動作,但是,遇到單字是在長長的連結裡時,就沒輒了。因為連結一點下去,就連出去了。目前看到有一些firefox的extension可以做出mouseover就查詢的效果,所以我去google了一下。之前有在用的rikaichan,還有昨天找到的cndict都可以做到這種效果。
我把cndict extension的.js檔研究了一番,把它原本線上查詢英漢的地方,換成了呼叫onlineDic。透過這種方式,我的onlineDic在Linux下,也可以用類似mouse over lookup的功能。










