diff --git a/merriam_webster.py b/merriam_webster.py index a6a950e6..aae87e7e 100644 --- a/merriam_webster.py +++ b/merriam_webster.py @@ -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()