1

I am trying to parse the definitions of target English word from "en.Wiktionary.org"

I had considered already existing module(https://github.com/Suyash458/WiktionaryParser/blob/master/readme.md) ,however, it parses redundancies to my purpose - such as etymology, related words, pronounciation and examples.

How could I only parse the definitions according to the Part of Speech?

Any recommendation or advice would be grateful.

Daschin
  • 119
  • 1
  • 4
  • What have you tried? Paste code and error. – Sharun Aug 14 '17 at 14:10
  • actually I am looking into the WikiParse.py (which is available at given link) and trying to slightly change it to only return the definitions without etymologies, related, pronounciations and examples. However keep returns errors for me since I have no prior background for Beautiful Soap and Jsons. – Daschin Aug 14 '17 at 14:17

1 Answers1

2

Is this what you mean?

>>> from wiktionaryparser import WiktionaryParser
>>> parser = WiktionaryParser()
>>> word = parser.fetch('satiate', 'english')
>>> for item in word[0]['definitions']:
...     item['partOfSpeech'], item['text']
... 
('verb', 'satiate (third-person singular simple present satiates, present participle satiating, simple past and past participle satiated)\n(transitive) To fill to satisfaction; to satisfy.Nothing seemed to satiate her desire for knowledge.\n(transitive) To satisfy to excess. To fill to satiety.\n')
('adjective', "satiate (comparative more satiate, superlative most satiate)\nFilled to satisfaction or to excess.Alexander PopeOur generals now, retir'd to their estates,Hang their old trophies o'er the garden gates;In life's cool evening satiate of applause […]\nAlexander PopeOur generals now, retir'd to their estates,Hang their old trophies o'er the garden gates;In life's cool evening satiate of applause […]\n")

>>> word = parser.fetch('arrondissement', 'french')
>>> for item in word[0]['definitions']:
...     item['partOfSpeech'], item['text']
... 
('noun', 'arrondissement\xa0m (plural arrondissements)\nArrondissement\n(Canada) Arrondissement, a borough (submunicipal administrative division)\n')

When you ask for a word this library returns a somewhat complicated structure of lists and dictionaries. You might just need for practice in manipulating them.

Bill Bell
  • 21,021
  • 5
  • 43
  • 58