fix MW word history
This commit is contained in:
parent
f65a677cb4
commit
5c5397437c
@ -1,4 +1,5 @@
|
||||
from dict_dl import Queue, WordParser, cw, ot, rb, uq, uqall
|
||||
import itertools
|
||||
|
||||
|
||||
class MerriamWebsterParser(WordParser):
|
||||
@ -63,8 +64,8 @@ class MerriamWebsterParser(WordParser):
|
||||
@property
|
||||
def first_known_use(self):
|
||||
uses = {}
|
||||
for e in self.root.findall(".//div[@id='first-known-anchor']"):
|
||||
for y in e.findall(".//p[@class='ety-sl']"):
|
||||
for e in self.root.findall(".//div[@class='first-known-content-section']"):
|
||||
for y in e.findall(".//p[@class='ety-sl pb-3']"):
|
||||
uses[ot(y)] = ""
|
||||
for t, y in zip(
|
||||
e.findall(".//p[@class='function-label']"),
|
||||
@ -83,7 +84,7 @@ class MerriamWebsterParser(WordParser):
|
||||
@property
|
||||
def history_and_etymology(self):
|
||||
hande = {}
|
||||
for e in self.root.findall(".//div[@id='etymology-anchor']"):
|
||||
for e in self.root.findall(".//div[@class='etymology-content-section']"):
|
||||
for y in e.findall(".//p[@class='et']"):
|
||||
hande[ot(y)] = ""
|
||||
for t, y in zip(
|
||||
@ -91,6 +92,7 @@ class MerriamWebsterParser(WordParser):
|
||||
e.findall(".//p[@class='et']"),
|
||||
):
|
||||
hande[ot(y)] = rb(ot(t), "(", ")")
|
||||
print(hande)
|
||||
return cw(hande)
|
||||
|
||||
@property
|
||||
@ -131,14 +133,14 @@ class MerriamWebsterParser(WordParser):
|
||||
)
|
||||
|
||||
|
||||
# testword = "optimize"
|
||||
# d = MerriamWebsterParser(testword)
|
||||
# # print(d.definitions)
|
||||
# print(d.neighbours)
|
||||
# word_dict = d.todict()
|
||||
# for k, v in word_dict[testword].items():
|
||||
# print(f"### {k} ###\n", v)
|
||||
# exit()
|
||||
testword = "domicile"
|
||||
d = MerriamWebsterParser(testword)
|
||||
# print(d.definitions)
|
||||
print(d.neighbours)
|
||||
word_dict = d.todict()
|
||||
for k, v in word_dict[testword].items():
|
||||
print(f"### {k} ###\n", v)
|
||||
exit()
|
||||
|
||||
q = Queue(MerriamWebsterParser, "en_MerriamWebster/", "_MW.json")
|
||||
q.loadDB()
|
||||
|
Loading…
Reference in New Issue
Block a user