Python library to retrieve wiktionary word definitions for different languages
Project description
PyWiktionary
The Python library for wiktionary words
Version 0.1.0
This is an alpha library to retrieve and parse Wiktionary word pages that will require enhancements and fixes
Install
Requirements
If you install this library from source code or you want help with development of the code, make sure to install requirements first:
$ pip install -r ./requirements.txt
Pywiktionary install
Install from the remote pip repository:
$ pip install pywiktionary
Install from the root of the source code:
$ pip install .
How to use
Initialize the parser factory (pywiktionary.wiktionary_parser_factory.WiktionaryParserFactory) with a supported language, then make the request with get_page() method passing the word you desire to get.
from pywiktionary.wiktionary_parser_factory import WiktionaryParserFactory
parser_factory = WiktionaryParserFactory(default_language='en')
pizza_parser = parser_factory.get_page('pizza')
Then to get data about the word use the parse() method of the parser object returned from WiktionaryParserFactory:
parsing_result = pizza_parser.parse()
The result variable is a dictionary containing the result of the wiktionary page parsing divided by type/subtype. Here the result for "pizza":
{
"meanings": {
"noun": [
{
"meaning": "(uncountable) A baked Italian dish of a thinly rolled bread dough crust typically topped before baking with tomato sauce, cheese, and other ingredients such as meat, vegetables or fruit",
"examples": []
},
{
"meaning": "(countable) A single instance of this dish",
"examples": []
}
]
}
}
Summary
This is the summary of above commented code:
from pywiktionary.wiktionary_parser_factory import WiktionaryParserFactory
parser_factory = WiktionaryParserFactory(default_language='en')
pizza_parser = parser_factory.get_page('pizza')
parsing_result = pizza_parser.parse()
Yeah, yeah... i know it is beautiful and easy as idea, but this library require many development to enhance this system!
Supported languages (Language - Code)
- English - en
- Italian - it
ToDo
- Surfable Software Documentation!
- Implement a good system to select wiktionary language parser
- Write a good human friend documentation! =)
- Write some examples for humans!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pywiktionary-0.1a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a71c2405f75f9c46fe2ef984f1128af081b89fbac2bb296f337c46f4a602e308 |
|
MD5 | a7ab54164a86867c869c6b99367eb6c8 |
|
BLAKE2b-256 | deb58042ac0e073e7362896cbf76d8da59e46879ae48b64d71adccb57df0c955 |