|
发表于 2009-2-15 19:46:42
|
显示全部楼层
回复 4楼 happyer2000 的帖子
作索引最好的辦法是用關係數據庫的grouping 操作。/ ^( X4 i3 L8 r
比如某字典(dictA)辭條的格式爲:辭目、注音、釋義三個字段。你想做的是注音到辭目的索引。/ K" U D( ^& E$ b0 w" }8 R
) \* ?$ m: F9 U+ N8 Y% y( C( i; s先將字典txt import 到數據表dict 中,假設字段名爲headword(辭目),pronunc(注音),definition(釋義)。
7 [* ?) P$ F: A2 u9 X0 \3 ?/ y+ y5 @4 t3 Y/ C6 O2 @
獲得注音索引的sql語句爲(以sqlite爲例):
: G: n( e, b7 D9 c, i6 f5 d( ucreate table pronunc_idx as8 y% o) _9 e0 u* S
select pronunc, group_concat(headword) as hws2 w4 u; b2 u K, ?
from dict group by pronunc., Q9 ]0 F& u4 d% v3 v4 q
/ N, `* |, S( K然後把所得的索引表 pronunc_idx導出到txt文檔。 |
|