Skip to content

Commit 12dfc03

Browse files
committed
开源wordjoy到github
0 parents  commit 12dfc03

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+64120
-0
lines changed

ChangeLog

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
0.3.0
2+
3+
1: 原来对gtk的需要为2.16,现在把gtk的版本改为2.14, 因为很多朋友的系统自带的2.14, 原来的一个办法就是直接修改所有glade目录下的xml文件,手动将其中的gtk版本号修改为2.14,现在想想直接退回去。我自己在用其它系统的时候,也遇到了麻烦。
4+
5+
虽然失去了一些新的特性,但是在能让用户运行之前,我想最重要的是先运行起来再说。
6+
7+
在ubuntu上查询你的gtk版本号:
8+
$ pkg-config --modversion gtk+-2.0
9+
2.16.1
10+
11+
我的系统为ubuntu 9.04,已经安装了2.16
12+
13+
界面丑就丑点吧!
14+
15+
2: 以前版本上面写只包含2700个单词,其实是笔误。更正为:
16+
目前词库为27000个单词,可能没有你需要的单词。
17+
18+
3:增加三个词库管理的脚本,方便用户直接管理数据库。
19+
a:带上添加单词的脚本,这个脚本可以向数据库里面添加里面没有的词汇(当然,前提是这个单词在网上查找得到)。
20+
21+
b: 还附带一个去除重复单词的脚本,虽然只需要用一条SQL语句就行了。
22+
23+
c: 附带一个将数据库里面的所有词汇导出的脚本。
24+
25+
26+
4:通过本软件生成书本的功能,有时可用,有时不可用。如果不用可的时候,退出再试吧。没有找到原因。
27+
28+
5:背完一组单词,就退出后再重新选择单词吧。
29+
30+
6:功能远不完善,请多担待!
31+
32+
33+

README.rst

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
=========
2+
WordJoy
3+
=========
4+
5+
6+
介绍
7+
~~~~
8+
9+
WordJoy是一个用pygtk编写的英文背单词软件, 运行平台为Linux。
10+
11+
12+
WordJoy基于TualatriX大侠的MyWord改写而成,而MyWord又是继承于Stardict作者HuZheng(功德藏菩萨)的reciteword背单词软件而来。具体请参看这两款软件的信息。
13+
14+
15+
本程序的特色
16+
~~~~~~~~~~~~
17+
18+
本程序的特色:
19+
20+
1. 采用全部的书本格式,争取做到更加简洁、明了、实用。
21+
2. 每个单词配以三个例句,让你在句子中学习单词的意思与用法。
22+
3. 支持使用WyabdcRealPeopleTTS真人语音包发音。
23+
4. 支持单词测试,随时掌握自己的学习情况。
24+
5. 支持背诵的遗忘曲线,采用记录的方式提醒你,今天该背诵的单词。
25+
6. 支持自定义词库,自己制作背诵的书本(只需要给出单词列表,即可自动生成)。
26+
27+
更多特色由你来扩展,本项目現在进行当中,期待你的参与……
28+
29+
有关词库,请参照books/里面的词库说明。
30+
31+
32+
安装
33+
~~~~
34+
35+
请参考doc/INSTALL文件。
36+
37+
38+
语音库的安装
39+
~~~~~~~~~~~~
40+
41+
1. 下载真人语音库:
42+
43+
本程序利用的是stardict的真人发音库包。
44+
45+
自己去网上找WyabdcRealPeopleTTS.tar.bz2这个包,有81M左右。
46+
47+
2. 进入语音库的下载目录:然后执行解压命令::
48+
49+
$ sudo tar -jxvf WyabdcRealPeopleTTS.tar.bz2 -C /usr/share/

books/joy_books/CET4/cet4.book

1.2 MB
Binary file not shown.

books/joy_books/CET6/cet6.book

790 KB
Binary file not shown.

books/joy_books/VOA_special/xaa.book

206 KB
Binary file not shown.

books/joy_books/VOA_special/xab.book

207 KB
Binary file not shown.

books/joy_books/VOA_special/xac.book

189 KB
Binary file not shown.

books/joy_books/oyea9le/unit1.book

11 KB
Binary file not shown.

books/joy_books/oyea9le/unit2.book

9 KB
Binary file not shown.

books/joy_books/oyea9le/unit3.book

10 KB
Binary file not shown.

books/opera_book/add_words.py

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#!/usr/bin/env python
2+
#-*- coding:utf-8 -*-
3+
4+
import os
5+
import gtk
6+
7+
from db import ConnectDB
8+
from StringIO import StringIO
9+
import urllib2
10+
from xml.etree.ElementTree import ElementTree, Element, tostring
11+
12+
class CreateBook():
13+
"""创建新书类
14+
"""
15+
def __init__(self, database, table):
16+
17+
db = ConnectDB(database)
18+
# db.create_new_table(table)
19+
20+
missing = open("missing", "a+")
21+
22+
for word in open('words.list'):
23+
word = word.rstrip()
24+
print '正在添加单词…… ' , word
25+
word_xml = GetWord()
26+
word_dic = word_xml.get_word_xml(word)
27+
if word_dic == None:
28+
print '%s Not Found' % word
29+
missing.write(word + '\n')
30+
continue
31+
else:
32+
#print word_dic
33+
db.insert_a_dict(word_dic)
34+
35+
class GetWord():
36+
def __init__(self):
37+
pass
38+
# self.get_word_xml("greyhound")
39+
40+
def __xml_parse(self, word):
41+
"""解析测试
42+
"""
43+
word_dic = {}
44+
45+
word_dic['name'] = word[0].getchildren()[0].text
46+
47+
if word[0].find('pron') is not None:
48+
word_dic['pronounce'] = word[0].getchildren()[2].text
49+
word_dic['meaning'] = word[0].getchildren()[3].text
50+
else:
51+
word_dic['pronounce'] = ""
52+
word_dic['meaning'] = word[0].getchildren()[2].text
53+
54+
word_dic['sentence'] = []
55+
sen_all = word[0].findall("sent")
56+
if sen_all is not None:
57+
for sen_all_child in sen_all:
58+
en = sen_all_child.getchildren()[0].text
59+
zh = sen_all_child.getchildren()[1].text
60+
word_dic['sentence'].append((en, zh))
61+
62+
# print word_dic
63+
return word_dic
64+
def get_word_xml(self, word):
65+
# mini版本
66+
# word_page = "http://dict.cn/mini.php?q=" + word
67+
# xml版本
68+
word_page = "http://dict.cn/ws.php?q=" + word
69+
content = urllib2.urlopen(word_page).read()
70+
# print content
71+
try:
72+
content = unicode(content, 'gbk').encode("utf8")
73+
except UnicodeDecodeError:
74+
return None
75+
# print content
76+
77+
# 删除掉原来文件中编码指示,否则会出错
78+
# content = content.replace(' encoding="GBK" ', '')
79+
# 直接去掉文件头声明
80+
content = content.replace('<?xml version="1.0" encoding="GBK" ?>', '')
81+
82+
tree = ElementTree()
83+
tree.parse(StringIO(content))
84+
85+
word = tree.getiterator("dict")
86+
87+
if word[0].getchildren()[0].text != "Not Found":
88+
89+
audio = word[0].find("audio")
90+
if audio is not None:
91+
word[0].remove(audio)
92+
93+
# print tostring(word[0], 'utf8')
94+
return self.__xml_parse(word)
95+
96+
# 按字符串打印
97+
# return tree
98+
else:
99+
return None
100+
101+
if __name__ == '__main__':
102+
# GetWord()
103+
database = "../wordjoy.book"
104+
table = "wordjoy"
105+
CreateBook(database, table)

0 commit comments

Comments
 (0)