-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDictionaries.py
814 lines (687 loc) · 24.6 KB
/
Dictionaries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
import os
import urllib
import urllib2
import re
import xml.etree.ElementTree as ET
import anki.js
import codecs
from random import randint
from HTMLParser import HTMLParser
from htmlentitydefs import name2codepoint
from .downloadaudio.downloaders.downloader import AudioDownloader
from anki.utils import stripHTML, json
from aqt import mw, utils
import json
version = '0.2.38 Release'
def removeNonAscii(s): return "".join(i for i in s if ord(i)<128)
class Google() :
def write(self,word) :
content = []
fullname = Storage(word).getPath() + word + ".bin.txt"
try :
with open(fullname, 'r') as f: content = f.readlines()
except IOError :
pass
#url = u'http://translate.google.com//translate_a/ex?sl=en&tl=ru&q=' + word
url = u'http://translate.google.com//translate_a/single?client=t&sl=en&tl=ru&dt=ex&q=' + word
user_agent = 'Mozilla/5.0'
request = urllib2.Request(url)
request.add_header('User-agent', user_agent)
response = urllib2.urlopen(request)
if response.code == 200 :
s = response.read()
if len(s) < 20 :
return
s = s.replace("[,,,,,,,,,,,,,[", "")
s = s.replace("]]]]", "]]")
s = s.replace(",,", ",\"\",")
s = s.replace(",,", ",\"\",")
#utils.showInfo(s)
#utils.showInfo(s[2500:])
j = json.loads(s)
l = 0
try :
l = len(j)
except IndexError :
pass
if l > 0 :
with open(fullname, "a") as f1:
for s in j :
st = stripHTML(removeNonAscii(s[0])) + "\n"
try :
if not st in content :
f1.write(st)
except:
utils.showInfo(word)
break
class Sentence() :
def __init__(self) :
self.word = ''
self.content = []
self.sentence = ''
self.rand = -1
def clean(self) :
self.content = []
self.sentence = ''
self.rand = -1
def getOldSentence(self) :
return self.sentence
def getSentence(self, word) :
sentence = ''
fullname = Storage(word).getPath() + word + ".bin.txt"
try :
if word != self.word or len(self.content) == 0:
with open(fullname, 'r') as f: self.content = f.readlines()
self.word = word
self.rand = -1
length = len(self.content)
if length != 0 :
while True :
rand = randint(0,length-1)
if rand != self.rand or length == 1 :
self.rand = rand
break
sentence = self.content[self.rand].strip()
self.sentence = sentence
else :
self.clean()
except IOError :
self.clean()
pass
return sentence
class Storage() :
base = 'c:/users/albert/AppData/Roaming/ParseYourDictionary/ParseYourDictionary/1.0.0.0/'
def __init__(self, word) :
self.word = word
def getPath(self) :
storagePath = Storage.base + self.word[:2] + '/'
try :
os.makedirs(storagePath)
except OSError:
pass
return storagePath
class str_cir(str):
''' A string with a built-in case-insensitive replacement method '''
def ireplace(self,old,new,count=0):
''' Behaves like S.replace(), but does so in a case-insensitive
fashion. '''
pattern = re.compile(re.escape(old),re.I)
str = re.sub(pattern,new,self,count)
pattern = re.compile(re.escape(old[0:-1]),re.I)
str = re.sub(pattern,new,str,count)
return str
class GroupEntities() :
def __init__(self, data, fl) :
self.entities = data
self.fl = fl
class Entity() :
def __init__(self) :
self.meaning = ""
self.examples = []
def setMeaning(self, meaning) :
self.meaning = meaning
def setExample(self, example) :
self.examples.append(example)
def dumps(self) :
json_meaning = json.dumps(self.meaning)
json_examples = json.dumps(self.examples)
json_entity = json.dumps([json_meaning, json_examples])
return json_entity
def loads(self, json_entity) :
arr_entity = json.loads(json_entity)
self.meaning = json.loads(arr_entity[0])
self.examples = json.loads(arr_entity[1])
class EntityEx(Entity) :
def __init__(self) :
Entity.__init__(self)
self.sub = False
def dumps(self) :
json_meaning = json.dumps(self.meaning)
json_examples = json.dumps(self.examples)
json_sub = json.dumps(self.sub)
json_entity = json.dumps([json_meaning, json_examples, json_sub])
return json_entity
def loads(self, json_entity) :
arr_entity = json.loads(json_entity)
self.meaning = json.loads(arr_entity[0])
self.examples = json.loads(arr_entity[1])
self.sub = json.loads(arr_entity[2])
class CollinsDictionaryCommonness(AudioDownloader) :
def __init__(self, word):
self.data = ''
self.word = word
AudioDownloader.__init__(self)
self.icon_url = 'http://www.collinsdictionary.com/'
self.url = 'http://www.collinsdictionary.com/dictionary/american/'
if not self.load() :
word_soup = self.get_soup_from_url(self.url + word)
commonness = word_soup.find(attrs={'class' : 'commonness_image'})
if commonness != None :
self.data = commonness.prettify()
if len(self.data) > 0 :
self.dump()
def format(self) :
return self.data.replace("<img", "<img align='right' ").replace("/static/graphics/commonnessDots/", Storage.base)
def dump(self) :
fp = Storage(self.word).getPath() + self.word + '.cdc'
with open(fp, 'w') as f:
f.write(self.data)
def load(self) :
fp = Storage(self.word).getPath() + self.word + '.cdc'
if os.path.exists(fp) :
with open(fp, 'r') as f:
self.data = f.read()
return True
else :
return False
class MacmillanThesaurusParser(AudioDownloader) :
def __init__(self, word):
AudioDownloader.__init__(self)
self.data = []
self.word = word
self.stars = 0
if not self.load() :
self.url = 'http://www.macmillandictionary.com/thesaurus/american/'
word_soup = self.get_soup_from_url(self.url + word)
HOMOGRAPH = word_soup.find(attrs={'class' : 'HOMOGRAPH'})
if HOMOGRAPH == None : return
stars = HOMOGRAPH.findAll('img')
if stars != None :
self.stars = len(stars)
SENSE = HOMOGRAPH.findAll(attrs={'class' : 'SENSE-BODY'})
if len(SENSE) == 0 : SENSE = HOMOGRAPH.findAll(attrs={'class' : 'phrasalverbsense'})
for s in SENSE:
entity = EntityEx()
meaning = s.span.getText(u' ')
entity.setMeaning(meaning)
cattitle = s.find(attrs={'class' : 'cattitle'})
synonyms = s.find(attrs={'class' : 'synonyms'})
st_cattitle = ''
if cattitle != None : st_cattitle = cattitle.getText() + u' '
st_synonyms = ''
if synonyms != None : st_synonyms = synonyms.getText().replace(",", ", ")
entity.setExample(st_cattitle + st_synonyms)
self.data.append(entity)
SUB_SENSE_CONTENT = s.findAll(attrs={'class' : 'SUB-SENSE-CONTENT'})
for ss in SUB_SENSE_CONTENT :
entity = EntityEx()
entity.setMeaning(ss.span.getText(u' '))
cattitle = ss.find(attrs={'class' : 'cattitle'})
synonyms = ss.find(attrs={'class' : 'synonyms'})
st_cattitle = ''
if cattitle != None : st_cattitle = cattitle.getText() + u' '
st_synonyms = ''
if synonyms != None : st_synonyms = synonyms.getText().replace(",", ", ")
entity.setExample(st_cattitle + st_synonyms)
entity.sub = True
self.data.append(entity)
self.dump()
def dump(self) :
fp = Storage(self.word).getPath() + self.word + '.mtp'
arr_data = []
for e in self.data :
st = e.dumps()
arr_data.append(st)
arr_data_all = [json.dumps(self.stars), json.dumps(arr_data)]
with open(fp, 'w') as f:
json.dump(arr_data_all, f)
def load(self) :
fp = Storage(self.word).getPath() + self.word + '.mtp'
if os.path.exists(fp) :
arr_data_all = []
with open(fp, 'r') as f:
arr_data_all = json.load(f)
self.stars = json.loads(arr_data_all[0])
arr_data = json.loads(arr_data_all[1])
for st in arr_data :
e = EntityEx()
e.loads(st)
self.data.append(e)
return True
else :
return False
def formatStars(self) :
st = ""
for x in range(0, self.stars) :
st += u"<img align='right' style='margin-top: -3px' src='" + Storage.base + u"star.gif'>"
return st
def format(self) :
st = "<ul>"
for e in self.data :
if e.sub :
st += "<dd>"
margin = "40"
else :
st += "<li>"
margin = "20"
st += str_cir(e.meaning.encode('ascii','replace')).ireplace(self.word, " ___ ")
for ex in e.examples :
st += "<p style='margin-left: %spx'>" % (margin) + str_cir(ex.encode('ascii','replace')).ireplace(self.word, " ___ ") + "</p>"
if e.sub :
st += "</dd> "
else :
st += "</li>"
st += "</ul>"
return st
class CollinsDictionaryThesaurus(AudioDownloader) :
def __init__(self, word):
AudioDownloader.__init__(self)
self.data = []
self.word = word
if not self.load() :
self.url = 'http://www.collinsdictionary.com/dictionary/american-thesaurus/'
word_soup = self.get_soup_from_url(self.url + word)
syn = word_soup.findAll(attrs={'class' : 'syn'})
if len(syn) == 0 :
self.url = 'http://www.collinsdictionary.com/dictionary/english-thesaurus/'
word_soup = self.get_soup_from_url(self.url + word)
syn = word_soup.findAll(attrs={'class' : 'syn'})
something_to_dump = False
for syn_tag in syn:
self.data.append(syn_tag.text)
something_to_dump = True
if True :
self.dump()
def dump(self) :
fp = Storage(self.word).getPath() + self.word + '.cdt'
with open(fp, 'w') as f:
json.dump(self.data, f)
def load(self) :
fp = Storage(self.word).getPath() + self.word + '.cdt'
if os.path.exists(fp) :
with open(fp, 'r') as f:
self.data = json.load(f)
return True
else :
return False
def format(self) :
st = "<span>"
for e in self.data :
st = st + e + ", "
st = st + "</span>"
return st
class YourDictionaryParser(HTMLParser):
def __init__(self, word):
HTMLParser.__init__(self)
self.f1 = 0
self.f2 = 0
self.skip = 0
self.word = word
self.data = []
self.entity = Entity()
self.something_to_dump = False
if not self.load() :
# http://americanheritage.yourdictionary.com/
# self.feed(urllib.urlopen('http://www.yourdictionary.com/' + word).read())
connection = urllib.urlopen('http://www.yourdictionary.com/' + word)
encoding = connection.headers.getparam('charset')
page = connection.read().decode("utf-8")
self.feed(page)
self.something_to_dump = True
if self.something_to_dump :
self.dump()
def dump(self) :
fp = Storage(self.word).getPath() + self.word + '.ydp'
arr_data = []
for e in self.data :
st = e.dumps()
arr_data.append(st)
with open(fp, 'w') as f:
json.dump(arr_data, f)
def load(self) :
fp = Storage(self.word).getPath() + self.word + '.ydp'
if os.path.exists(fp) :
arr_data = []
with open(fp, 'r') as f:
arr_data = json.load(f)
for st in arr_data :
e = Entity()
e.loads(st)
self.data.append(e)
return True
else :
return False
def format(self) :
st = "<ul>"
for e in self.data :
st = st + "<li>" + str_cir(e.meaning).ireplace(self.word, " ___ ")
# st = st + "<ul>"
for ex in e.examples :
st = st + "<p style='margin-left: 20px'>" + str_cir(ex).ireplace(self.word, " ___ ") + "</p>"
st = st + "</li>"
st = st + "</ul>"
return st
def handle_starttag(self, tag, attrs):
if tag == 'span' :
for name, value in attrs:
if name == 'class' and value == 'custom_entry_pos' :
print " attr1:", name, value
self.skip = 1
return
if tag != 'div' :
return
for name, value in attrs:
if name == 'class' and value == 'custom_entry' :
print " attr1:", name, value
self.f1 = 1
elif name == 'class' and value == 'custom_entry_example':
print " attr2:", name, value
self.f2 = 1
def handle_endtag(self, tag):
if self.skip == 1 :
self.skip = 0
elif self.f2 == 1 and tag == 'div' :
print "End tag 2 :", tag
self.f2 = 0
elif self.f1 == 1 and tag == 'div' :
self.data.append(self.entity)
print "End tag 1 :", tag
self.f1 = 0
def handle_data(self, data):
if self.f2 == 1 :
print "Data2 :", data
if len(data.strip()) > 0 :
self.entity.setExample(data)
elif self.f1 == 1 and self.skip == 0:
print "Data1 :", data
if len(data.strip()) > 0 :
self.something_to_dump = True
self.entity = Entity()
self.entity.setMeaning(data.strip())
class WordNetParser() :
def __init__(self, word):
self.data = []
self.word = word.strip()
self.xml = ""
try_dump = False
if not self.load() :
self.xml = urllib.urlopen('http://www.stands4.com/services/v2/syno.php?uid=2686&tokenid=WAOzklnbIIZEFAjE&word=' + self.word).read()
try_dump = True
try :
root = ET.fromstring(self.xml)
except :
utils.showInfo(self.word)
utils.showInfo(self.xml)
raise
for child in root:
t = child.find('./term')
if t == None :
break
else :
if try_dump :
self.dump()
try_dump = False
term = t.text
definition = child.find('./definition').text
p = child.find('./partofspeech')
if p is None or p.text is None :
partofspeech = 'A'
else :
partofspeech = p.text
s = child.find('./synonyms')
if (s is None or s.text is None) :
synonyms = ''
else :
synonyms = s.text
if not partofspeech[0].isupper() :
entity = Entity()
entity.setMeaning(definition.strip())
synset = [x.strip() for x in (term + ", " + synonyms).split(',')]
synset = list(set(synset))
entity.setExample(", ".join(synset))
self.data.append(entity)
def dump(self) :
fp = Storage(self.word).getPath() + self.word + '.wnp'
with open(fp, 'w') as f:
f.write(self.xml)
def load(self) :
fp = Storage(self.word).getPath() + self.word + '.wnp'
if os.path.exists(fp) :
with codecs.open(fp, 'r') as f:
self.xml = f.read()
return True
else :
return False
def format(self) :
st = "<ul>"
for e in self.data :
st += "<li> "
st += str_cir(e.meaning.encode('ascii','replace')).ireplace(self.word, " ___ ")
for ex in e.examples :
st += "<p style='margin-left: 20px'>" + str_cir(ex.encode('ascii','replace')).ireplace(self.word, " ___ ") + "</p>"
st += "</li> "
st += "</ul>"
return st
class MerriamWebsterThesaurusParser() :
def __init__(self, word):
self.data = []
self.word = word
self.xml = ""
dump_me = False
if not self.load() :
self.xml = urllib.urlopen('http://www.dictionaryapi.com/api/v1/references/thesaurus/xml/' + word + "?key=ebaacac2-31ed-4e7a-96be-463a80ad5770").read()
dump_me = True
root = ET.fromstring(self.xml)
for child in root:
hw = child.find('./term/hw') #va
found1 = hw != None and child.find('./term/hw').text == word
if not found1 :
va = child.find('./vr/va')
found1 = va != None and child.find('./vr/va').text == word
if found1 :
if dump_me :
self.dump()
dump_me = False
fl = child.find('./fl').text
senss = child.findall('./sens')
data = []
for sens in senss :
entity = Entity()
mc = sens.find('./mc')
meaning = mc.text
subTemp = mc.findall('./it') #italic
for it in subTemp :
if it != None :
if type(it.text) == str : meaning += it.text
if type(it.tail) == str : meaning += it.tail
if type(mc.tail) == str : meaning += mc.tail
entity.meaning = meaning
syn = sens.find('./syn')
#'<b>Synonyms: </b>'
synonims = sens.find('./syn').text
subTemp = syn.findall('it') #italic
for it in subTemp :
if it != None :
if type(it.text) == str or type(it.text) == unicode : synonims += it.text.encode('ascii','replace')
if type(it.tail) == str or type(it.tail) == unicode : synonims += it.tail.encode('ascii','replace')
if type(syn.tail) == str : synonims += syn.tail
entity.examples.append(synonims)
relwords = sens.find('./rel')
if relwords != None :
rel = '<i>Related Words: </i>' + relwords.text
entity.examples.append(rel)
self.data.append(entity)
def dump(self) :
fp = Storage(self.word).getPath() + self.word + '.mwt'
with open(fp, 'w') as f:
f.write(self.xml)
def load(self) :
fp = Storage(self.word).getPath() + self.word + '.mwt'
if os.path.exists(fp) :
with codecs.open(fp, 'r') as f:
self.xml = f.read()
return True
else :
return False
def format(self) :
st = "<ul>"
for e in self.data :
st += "<li> "
st += str_cir(e.meaning.encode('ascii','replace')).ireplace(self.word, " ___ ")
for ex in e.examples :
st += "<p style='margin-left: 20px'>" + str_cir(ex.encode('ascii','replace')).ireplace(self.word, " ___ ") + "</p>"
st += "</li> "
st += "</ul>"
return st
class MerriamWebsterParser() :
def __init__(self, word):
self.data = []
self.word = word
self.xml = ''
dump_me = False
# 84ffb629-a7c3-4512-9c3c-a520c79ded19 (albert@gmail) 181c71fa-4b20-4ec3-83d8-5eb06fe8bdf0 (albertly@yandex)
if not self.load() :
self.xml = urllib.urlopen('http://www.dictionaryapi.com/api/v1/references/collegiate/xml/' + word + "?key=84ffb629-a7c3-4512-9c3c-a520c79ded19").read()
dump_me = True
root = ET.fromstring(self.xml)
for child in root:
ew = child.find('./ew')
if ew != None and child.find('./ew').text == word :
if dump_me :
self.dump()
dump_me = False
fl = ''
fle = child.find('./fl')
if fle != None :
fl = fle.text
else :
continue
dts = child.findall('.//dt')
data = []
for dt in dts :
entity = Entity()
meaning = dt.text
if type(dt.tail) == str : meaning = meaning + " " + dt.tail
entity.meaning = meaning
vis = dt.findall(".//vi")
for vi in vis :
example = ""
if type(vi.text) == str : example = vi.text
subTemp = vi.find('it') #italic
if subTemp != None :
if type(subTemp.text) == str : example = example + subTemp.text
if type(subTemp.tail) == str : example = example + " " + subTemp.tail
if type(vi.tail) == str : example = example + " " + vi.tail
entity.setExample(example)
fw = dt.find('fw')
if fw != None :
meaning = ""
if type(fw.text) == str : meaning = fw.text
if type(fw.tail) == str : meaning = meaning + " " + fw.tail
entity.meaning = entity.meaning + " " + meaning
sx = dt.find('sx')
if sx != None :
meaning = ""
if type(sx.text) == str : meaning = sx.text
if type(sx.tail) == str : meaning = meaning + " " + sx.tail
entity.meaning = entity.meaning + " " + meaning
data.append(entity)
group = GroupEntities(data, fl)
self.data.append(group)
def format(self) :
st = "<ul>"
for e1 in self.data :
st = st + "<li> " + e1.fl + "<ul>"
for e in e1.entities :
st = st + "<li>" + str_cir(e.meaning).ireplace(self.word, " ___ ") + "</li>"
st = st + "<ul>"
for ex in e.examples :
st = st + "<li>" + str_cir(ex).ireplace(self.word, " ___ ") + "</li>"
st = st + "</ul>"
st = st + "</ul></li>"
st = st + "</ul>"
return st
def dump(self) :
fp = Storage(self.word).getPath() + self.word + '.mwd'
with open(fp, 'w') as f:
f.write(self.xml)
def load(self) :
fp = Storage(self.word).getPath() + self.word + '.mwd'
if os.path.exists(fp) :
with codecs.open(fp, 'r') as f:
self.xml = f.read()
return True
else :
return False
class DictionaryParser() :
def __init__(self, word):
self.word = word
def format(self) :
collComm = CollinsDictionaryCommonness(self.word)
merriamWebsterThesaurus = MerriamWebsterThesaurusParser(self.word)
macmillanThesaurus = MacmillanThesaurusParser(self.word)
yourDictionary = YourDictionaryParser(self.word)
coll = CollinsDictionaryThesaurus(self.word)
wordnet = WordNetParser(self.word)
word = self.word
class Synonims :
def getSynonims(self) :
l = word[:1]
synonims = ''
data = merriamWebsterThesaurus.data
for e in data :
synonims += e.examples[0] + ", "
# synonims += ", "
data = wordnet.data
for e in data :
synonims += e.examples[0]
data = coll.data
for st in data :
synonims += ", " + st
synset = [x.strip() for x in (synonims).split(',')]
synset1 = []
for s in synset :
if s[:1] == l : synset1.append(s)
synset = sorted(set(synset1))
return str_cir(", ".join(synset).encode('ascii','replace')).ireplace(word, " ___ ")
html ="""
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="C:\\Users\\albert\\Documents\\Anki\\addons\\CSS\\jquery-ui-1.10.2.custom.min.css">
<script>%s</script>
<script>%s</script>
<style type="text/css">
.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; }
.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: %s; margin-top: -8px; }
ul { padding-left: 0px;}
li {
padding-left: 5px;
}
ul.sub { padding-left: 5px;}
li.sub {
padding-left: 10px;
}
</style>
</head>
<body>""" % (anki.js.jquery, anki.js.ui, '50%')
html += "<div class='accordion'><h3><a class='f' href='#'><img src='" + Storage.base + "coll.ico'> Collins Thesaurus </a>" + collComm.format() + "</h3>"
html += "<div>" + coll.format() + "</div></div>"
if len(yourDictionary.data) > 0 :
html += "<div class='accordion'><h3><a href='#'><img src='" + Storage.base + "yourDictionary.ico'> YourDictionary</a></h3>"
html += "<div>" + yourDictionary.format() + "</div></div>"
if len(merriamWebsterThesaurus.data) > 0 :
html += "<div class='accordion'><h3><a href='#'><img src='" + Storage.base + "merriam.ico'> Merriam-Webster Thesaurus</a></h3>"
html += "<div>" + merriamWebsterThesaurus.format() + "</div></div>"
# else :
# merriamWebster = MerriamWebsterParser(self.word)
# html += "<div class='accordion'><h3><a href='#'><img src='" + Storage.base + "merriam.ico'> Merriam-Webster</a></h3>"
# html += "<div>" + merriamWebster.format() + "</div></div>"
html += "<div class='accordion'><h3><a href='#'><img src='" + Storage.base + "macmillan.ico'> Macmillan Thesaurus</a>" + macmillanThesaurus.formatStars() + "</h3>"
html += "<div>" + macmillanThesaurus.format() + "</div></div>"
if len(wordnet.data) > 0 :
html += "<div class='accordion'><h3><a href='#'><img src='" + Storage.base + "wordnet.ico'> Word Net</a></h3>"
html += "<div>" + wordnet.format() + "</div></div>"
synonims = Synonims()
html += "<br><hr>"
html += "<div class='ui-widget'>" + synonims.getSynonims() + "</div>"
html += """
<script type="text/javascript">
$(".accordion").accordion({ collapsible: true, active: false, heightStyle: 'content' });
$( ".f" ).click();
</script>
</body>
"""
return html