掌上百科 - PDAWIKI

 找回密码
 免费注册

QQ登录

只需一步,快速开始

查看: 2013|回复: 5

[求助] stardict词典的同义词条如何合并

[复制链接]

该用户从未签到

发表于 2015-1-18 04:35:56 | 显示全部楼层 |阅读模式
本帖最后由 LYX1692 于 2015-1-18 04:38 编辑 $ D+ W' i+ M5 {7 _& F) z

1 Z7 |* q, p, |9 V不知道有没有大神以前做过星际译王的词典,有个问题求教。1 F9 f) {/ m: w, |
我喜欢用Kindle多看看书,里面的词典采用的stardict格式的。
7 r5 `, s2 ?5 b
  ~9 d$ b; w* @3 ^0 n% [请问,stardict格式的词典,同义词条该如何合并?
3 b& [9 V- e5 @  y2 I$ _' C比如说搜索centre,自动导向center。, b6 e' B8 [/ Z" l4 u. X- @

! Q8 g! ^& Z. n百度找了好久,只找到一个说要编辑.syn格式的文件。
( r- R$ {. s& m3 O2 X可是连最起码的用什么工具编写,又怎么编译都没交待。* N% h. Y* E7 W2 V1 w* A
2 q3 s3 B! m% A/ v  O9 a! f1 a

) i3 Z! }- R' i8 ^8 ~The .syn file contains information for synonyms, that means, when you input a
+ H* N! |2 s" y" Psynonym, StarDict will search another word that related to it./ L1 c  t; S) @" C" b
0 g5 \+ ~7 x, X/ R9 {
The format is simple. Each item contain one string and a number.0 b, J' j7 @% N" i4 v5 u" Q
synonym_word;  // a utf-8 string terminated by '\0'.+ h& c5 W7 z$ L9 m/ p* F
original_word_index; // original word's index in .idx file.
; c( h, X3 G- g  ]/ r- vThen other items without separation.
+ _3 ^* T1 N, ~5 Y. YWhen you input synonym_word, StarDict will search original_word;0 B( u. d' Z6 ?% e" Z2 J
/ j( A* B6 H( O% i/ S- @  t# T
The length of "synonym_word" should be less than 256. In other / f7 l5 g" i3 r, B  \9 @4 o
words, (strlen(word) < 256).
2 n0 {. ^$ A# Uoriginal_word_index is a 32-bits unsigned number in network byte order.
6 R! \! D4 w# YTwo or more items may have the same "synonym_word" with different $ G$ a" n$ A" U8 _9 _/ |* N
original_word_index.
6 U, g  @$ M+ pThe items must be sorted by stardict_strcmp() with synonym_word.

该用户从未签到

发表于 2015-1-19 04:06:52 | 显示全部楼层
.idx .ifo .syn是编译后的文件,需要提取出文本,修改后再编译。
6 W8 o' }8 ]" c6 I! T; \) B提取文本和编译软件StarDict Editor  ^% ^- s+ `8 u% c
StarDict Editor支持Babylon文本格式的编译
& O; d% e( _8 ~+ L- D8 Y1 r例:
+ x9 v: p8 b2 I7 Tbabylon 格式
* r) E) m. D4 fapple|apples$ M& C4 p+ u$ F/ d9 {
the meaning of apple8 G$ R' x6 ^5 G$ w6 n" b, P0 Q
& I2 a" r, d) M. I
eeeee1 {0 g5 Z) J6 n& m7 f
kkkkk
0 Q" ~7 I& ^& ]+ z% g) D5 R  ~  U
===3 r) ~4 ~! u4 g
apple|apples
: Q9 \, n8 j! w& e编译后会生成xxx.syn文件,查apple或apples都会直接指向同一个解释,”the meaning of apple“。& \' H1 w) |/ j: k/ @1 C0 y
这是用Babylon格式的方法。) w  @* O8 C: t

% A( D) j) f; s% |' B因为不熟悉stardict格式,可以用StarDict Editor反编译出文本,看看。
9 g* y4 \8 S( m" s===2 T# v. d- a5 V6 |  X# ?
( u6 U5 `: F% E
Tab file(text)' J1 i0 y% U$ L' h8 N; i
apple     the meaning of apple
+ i7 M6 R4 e' g" f, H$ o8 P, Weeeee     kkkkk
' p0 N8 O7 m+ d4 H; N(text格式 synonym信息丢失' y7 A1 ?' a1 g4 i4 M; D
===Textual StarDict dictionary xml格式===, j1 B) T" k: i0 J/ B5 [
0 [. w2 [+ E& @/ c  q
  <?xml version="1.0" encoding="UTF-8" ?>3 S3 h# J; t1 t! s. ~& M* A
- <stardict xmlns:xi="http://www.w3.org/2003/XInclude">% m: z: S2 n, S  W% y
- <info>* v2 B8 T8 ^$ t. s
  <version>2.4.2</version>1 T3 l/ a6 r! v7 V6 K0 N
  <bookname>3</bookname>
0 y' O2 U' Q8 P+ G$ v5 L3 y  <author />( B& T1 N) c0 r( @" J, f
  <email />
6 O& P+ o- @! \  B0 y& C9 a  <website />
) x. a& d+ ~* w/ d5 {+ k- _  <description />
; J" d7 }2 I# B! I, t/ Q  <date />
- {% k* e0 M/ G2 m1 ?$ ?# q  <dicttype />  P0 a% ~; m! @& `- G9 ^' P
  </info>
. Y/ a2 A( p9 t+ Q- <article>
" U! Y0 X- \3 g. |8 x  k  <key>apple</key>$ r# [0 V2 T* V. Z+ ]% ]
  <synonym>apples</synonym>
0 Q( j* V! G7 o+ u! X- <definition type="m">
) v, ?. D, R" P% o<![CDATA[! E* \- x) F$ Z: j: D' i
the meaning of apple
1 P6 |/ T2 @5 R' K9 u  ]]>1 k( R, a9 n. b0 i6 F; J
  </definition>
1 ~3 N; s& A- P  P/ C# n  F  </article>7 ~- X; @7 n4 m% t& L$ b
- <article>
# K" G# `& J7 ]; [3 H& {5 ^8 q. o  <key>eeeee</key>
6 d9 F+ M8 {# |3 i( N0 {' W" Z- <definition type="m">8 p# f; ]$ k' ~0 j7 f
<![CDATA[" p% y- D& w/ E, {3 b1 `
kkkkk
! g' o: W* x6 a% y  ]]>
; p. ?/ \: X% H  </definition>
+ S! T9 `: a0 v: s  </article>
& H* a* h# }$ ~3 j; o# K* e  w  </stardict>; ]" l% K% w1 A. x
======3 q- s8 D9 L( D7 e# }$ o

0 t. |% \6 h6 V# C* i, i

该用户从未签到

发表于 2015-1-19 04:10:05 | 显示全部楼层
本帖最后由 qunwang6 于 2015-1-19 11:29 编辑
" B" P1 O, p$ G( N9 K* L5 p/ S: r1 F9 f
其它
# B6 N6 W/ G; m! |+ Wstardict-textual-dict-example.xml
, e4 J4 t) G) L1 A  yhttp://code.google.com/p/stardic ... e3841c0fda092c68b6f
0 \) c" H' o  G" J2 \+ W2 [) K7 M0 p$ v1 d$ \, c& T4 F
StarDict格式的词典转txt
( ?/ |6 G" k; K5 W方法一:* @7 z) a# u0 N4 u! t$ H  b6 b
StarDict Editor$ N# l) V6 X! b# `+ ~. B1 N
http://code.google.com/p/stardic ... xe&can=2&q=) L  W0 p4 Z( y. Q( t
1.下载、解压StarDict词典的压缩包xxx.tar.bz20 g! m' M% [2 q. d" z4 c* P2 [& f
2.将解压后文件夹内的xxx.dict.dz重命名为xxx.dict.zip然后解开为xxx.dict文本文件6 S7 G! \6 S% R8 D
3.打开StarDict Editor,选DeCompile,文件xxx.ifo, p! ?. e( ^4 U+ n% u, n
4.DeCompile
$ p# V+ q: s, Z# @# y  c1 l方法二:
- {! X! |: Q/ J7 `9 `# CStarDict转txt程序:cvtstardict2txt.zip: z1 G! ?- n2 g- B
http://www.pythonclub.org/python-files/stardict
  v9 n; `; B" A+ |5 C8 }; o* q- j8 ^
1.下载、解压StarDict词典的压缩包xxx.tar.bz2
7 F+ j" \3 i) e; o& ]2.将解压后文件夹内的xxx.dict.dz重命名为xxx.dict.zip然后解开为xxx.dict文本文件
7 ?0 T- y+ J4 e6 j$ R& d/ d! _3.用cvtstardict2txt提取
8 s5 {; W5 v0 N6 V" T3 V方法三:
6 c% Y9 U, ]. ^0 {2 C5 ~2 kpyglossary( K% [* y7 |  F) b% ]1 f: o9 m
https://github.com/ilius/pyglossary
- c: `# y7 I% T  n( \/ j1.下载、解压StarDict词典的压缩包xxx.tar.bz2
6 M' ?; A3 }- s9 I1 t2.cd 词典文件夹
* o  f' U! F) [  q3.python /Applications/Utilities/DictionaryDevelopmentKit/pyglossary/pyglossary.pyw --read-options=resPath=OtherResources --write-format=AppleDict xxx.ifo xxx.xml$ m$ Z' |% }6 y! _, Q" w- |$ ^

9 |* Y' u& O) k2 l5 ^3 v编译成StarDict格式的词典
& W3 U5 q3 c$ p& X% T方法一:7 L6 C5 M8 s7 \, P
StarDict Editor
3 n$ Z. K# w% ^9 C7 u- E1 S2 _" Mhttp://code.google.com/p/stardic ... xe&can=2&q=3 A% i: l& @3 \% }
方法二:
9 g) p0 X4 e6 rpyglossary6 u( M" t8 \0 {% H3 |
https://github.com/ilius/pyglossary; V( y, P% Z5 R  _! j
python /Applications/Utilities/DictionaryDevelopmentKit/pyglossary/pyglossary.pyw --read-options=resPath=OtherResources --write-format=Stardict xxx.txt xxx.ifo
4 A# J, ?8 m8 }* A' q/ c
" U1 z$ b* S( v# b* r
! s4 ~7 s6 A- R7 k9 q3 O5 o===
4 l& S, n% Q- h7 ]6 c' H文本格式
8 N$ _, T6 k" H2 A1 |a     1\n2\n3
+ W. ~' @9 J3 `+ M) \6 O4 {: ^5 gb     4\\5\n6; u( A! I+ ~2 I+ F- k
c     789
7 N, Z* k- A/ M( X$ f  L$ q  `6 h" U/ P
每行开头,是一个单词;接著,是一个Tab符(如果你的文本编辑器有 "Tab=空格" 选项,勿选之);接下来是单词音标及释义。n 表示换行,\ 表示斜线 。词典文件的最后一行,必须是一空行。
) {, |4 ~! C3 k9 p/ M
/ c: n! J, }/ a7 U" d' t<A href='bword://DAKOS'>DAKOS</A>
: H& s% `! m8 B+ f) a1 J' J; I- k1 l  C" d( c: {5 K" C: D' P

, x6 P8 k# n0 N2 i9 Y3 t8 [2 K2 L4 z/ f3 Z  U
How to add HTML tags to StarDict file?' x! D1 K/ [# A" m6 |# S
$ F* K! O" c# G. U! ^

8 C* }; ?+ O. ^8 I1 sa   <span style="font-color:#008000">prep.</span> <i>(en relaciones de proporción, equivalencia)</i> per.5 m2 J5 C" B3 B7 J$ ^6 ?, I* p
abajo   <span style="font-color:green">adv.</span> below.1 j  q  @4 y# _$ k* X. F7 r: Q, g( ~
a mano   by hand.
# V+ O8 {0 E& V" wabarcar   <span style="font-color:green">v.</span> <i>(temas/materias)</i> to cover; <i>(superficie/territorio)</i> to span, cover.
/ O$ p4 n% i6 r; F===
$ n2 M' A/ D  p8 Q/ j0 R+ \9 J% ICompile any supported file format to StarDict dictionary.
" D. y) I8 Y; m" v9 {5 q- M
2 D2 `! {; g1 V  j  ^1 P% \8 x1 r- ]Tab file format* N+ R# k0 d8 M
---------------  I# _% z& i; {7 y0 g' [% ^$ o! h& [
Here is a example dict.tab file:8 L6 E) C5 W) U9 q9 c6 Q4 ]
============6 K# y  C; l+ A5 D" q
a     1\n2\n3- f+ c& P( @9 |8 a4 F+ y- v+ A- J
b     4\\5\n6
- d9 p. W% m; f8 V4 |c     789
& z5 o( v9 ?  _/ E( c============
  e: ^5 y3 i6 ~9 I2 }Each line contains a word - definition pair. The word is splitted from definition with a tab character. You may use the following escapes: \n - new line, \\ - \, \t - tab character.
# V% V  R# ?7 i% E0 _' b3 T: o9 N8 W" A' @! b% y/ u
; }$ E7 ^  J% v# o
Babylon source file format
8 n. \8 G+ V5 v7 w" @3 j6 k--------------------------
6 P/ V% `* ]) l! C: S+ C6 r=====" h3 ?% E# U# c! k
apple|apples
; n3 k, D4 F$ y8 x5 x3 }8 Uthe meaning of apple
$ T/ q; c0 d" a# U+ s
/ z4 G+ \/ ]5 k1 R# S2dimensional|2dimensionale|2dimensionaler|2dimensionales|2dimensionalem|2dimensionalen# A5 Y9 I- z% @# K( i
two dimensional's meaning<br>the second line.& Q1 [3 V% \0 |, l  Q4 ~( K. Y
# L0 q6 M3 P2 Z' t2 [
=====
% f  T: D: r$ V8 m. [) NEach article must be followed by an empty line. The file must end with two empty lines!2 s# U- e; }. L! e( l* |

0 d/ l2 T" k0 _5 M! k4 JYou may specify field like bookname, author, description that will be used in the generated StarDict dictionary. You may specify options effecting processing of the babylon source file. See libbabylongfile.cpp source file for complete list of supported fields and options. To specify options and fields, leave the first line blank, than write options, one option per line. Precede each line with a hash sign.
& [0 w. V9 v3 g, e9 I9 XFor example:& n- I8 K3 o9 V
=====0 ]; ?  ]1 j2 q) Y& M, E% p

+ U9 C! E7 g% J1 ^0 u+ K#bookname=My dictionary0 O& V' v* N4 L5 ]! {
#author=My name
2 Y# c. a. _1 J$ t9 T4 r1 J1 b#description=...
$ P2 S  q( [* d) N( c3 u' u/ O1 D! L5 Z#other fields=" ^: |/ A; k4 T, W! T1 j

. w, U7 C& X& i2 ]3 jarticles...
& ^; h7 ~: X; g. e9 W5 k) R, H=====
$ }- q  v- x- t" N9 S6 W. e$ z) S- \1 a; H
Textual StarDict file format1 f+ f8 T) _; d% L4 t) A
----------------------------
" J8 U% h/ R) z* ^& Y3 C& RSee doc\TextualDictionaryFileFormat in source tarball for information about Textual StarDict dictionary.) R4 e' q7 T9 Z' |# _
$ D! ?' ~/ Y! }
Babylon

3 V- p" |9 k4 n  z" \* t- q( V单词! a* }" y' S4 B) D% C* a
解释(用htm的格式,如<B></B>可以设黑体;<font face=xxx></font>可以设字体等等。4 ]6 G# c0 B7 t; a3 v$ }
(空行)
- q9 s1 s" ~% N下一个单词。。。2 M. g- _, }' g' Z7 b% T
词典文件的最后一行,必须是一空行。
, |* ~' `; m$ ]$ I

该用户从未签到

 楼主| 发表于 2015-1-19 15:29:07 | 显示全部楼层
qunwang6 发表于 2015-1-19 04:06
1 |4 C$ Y+ P& w  t.idx .ifo .syn是编译后的文件,需要提取出文本,修改后再编译。
, i8 n! u1 Q) k; {5 d提取文本和编译软件StarDict Editor2 i' O; D% E& A! O
Sta ...

9 K& I* ^9 a- c7 E3 w) ]太谢谢了。我放弃了原来的Txt Tab File,改用Babylon的文本格式。
& B- U/ m1 L  N* `7 E照您说的方式果然生成了同义词条。$ t3 t% W# L$ |$ u' f' ]
太厉害了。
5 @2 y( e6 f1 _0 g" ~, P7 L
  • TA的每日心情
    无聊
    2021-1-15 05:13
  • 签到天数: 271 天

    [LV.8]以坛为家I

    发表于 2017-9-2 04:17:44 | 显示全部楼层
    qunwang6 发表于 2015-1-19 04:10
    . V5 L9 g" n: G2 Y* v- t  c' a其它
    7 M: |1 D5 `% P% G- U; nstardict-textual-dict-example.xml/ k. s0 U) q9 X
    http://code.google.com/p/stardict-3/source/browse/dict/doc/ ...
    # p6 _+ s, Y+ t: g- B% h  [
    大神, 有办法搞定 StarDict 或者 Babylon 格式词典的发音不? 想做成像 MDict 这样声音跟着词条走, 而不是把声音文件打成个大包然后按文件名字匹配单词, 例如一个单词能发英音和美英....
  • TA的每日心情
    开心
    2017-10-25 12:37
  • 签到天数: 8 天

    [LV.3]偶尔看看II

    发表于 2017-10-13 15:48:09 | 显示全部楼层
    <article>
    ' E  ?3 l" o# [2 N5 ~2 L! D<key>krīḍā-bhūmi</key>: n2 G# l0 i& z/ r
    <synonym>krīḍābhūmi</synonym>/ {% i8 s# L# O) i
    <synonym>遊戲其地</synonym>
    6 T) {/ z7 ^$ q4 {+ z<synonym>རྩེ་བའི་ས།</synonym>
    " M' N" S7 U5 S9 r( T
    # S  M. `5 n+ C$ ~& K<definition type="g">+ m) j, w" C+ v5 V* ~( j+ e) k
    <![CDATA[krīḍā-bhūmi- r9 D- {# Z0 n5 @
            遊戲其地
    ( B4 z" E" s) o7 J% v3 f& n        <font size="3" face="Tibetan Machine Uni">རྩེ་བའི་ས།</font>
    : x) V% @8 }9 U8 A3 h& M        rtze ba'i sa]]>
    5 S" [3 }( y% p" h</definition>
    ' f) a6 w6 y  n5 z8 e</article>0 T( i2 P, \6 ]3 o1 s$ v
    ------------------------------------------------
    4 C1 m7 b; k8 `/ _' Q1 k! p% [6 ^
    3 A1 U% Z* m+ s- P( Y5 Y如上,stardict中的同义词词条是用<synonym>***</synonym>
    您需要登录后才可以回帖 登录 | 免费注册

    本版积分规则

    小黑屋|手机版|Archiver|PDAWIKI |网站地图

    GMT+8, 2024-3-29 22:48 , Processed in 0.030773 second(s), 8 queries , MemCache On.

    Powered by Discuz! X3.4

    Copyright © 2001-2023, Tencent Cloud.

    快速回复 返回顶部 返回列表