Skip to main content

Scraping documents from a dump XML file of Wikipedia.

Project description

wikipedia-scraper

Parsing, tokenizing and creating language model using a Wikipedia dump XML file.

Author

Installation

pip install wscraper

Support

language

  • japanese
    • Japanese Wikipedia
  • english
    • English Wikipedia

tokenizer

  • mecab
    • Modules pip install mecab-python unidic-lite are required.
    • Some apt packages libmecab-dev libmecab2 swig are required for Ubuntu.
    • Japanese tokenizer
  • janome
    • A module pip install janome is required.
    • Japanese tokenizer
  • nltk
    • A module pip install nltk is required.
    • English tokenizer

model

  • word2vec
    • A module pip install gensim is required.
  • doc2vec
    • A module pip install gemsim is required.
  • word_frequency
    • word frequency and word document frequency

How to Work

0. Checking Console Commands

Please run this command.

wscraper help

Available commands to be listed.

1. Initialization

wscraper initialize

2. Creating New Task

This example make task named my_task.

wscraper new my_task

3. Using Created Task

wscraper switch my_task

Current task is switched to my_task.

4. Importing A Wikipedia XML File

This operation is independent of each task 2, 3.

A file wikipedia.xml assumes like (lang)wiki-(date)-pages-articles-multistream.xml

wscraper import /path/to/wikipedia.xml --name my_wp

5. Checking Wikipedia Resources

This command is also independent of task 2, 3.

It can check wikipedia resources.

wscraper wikipedia

output

Available Wikipedia:
  - my_wp

6. Setting Parameters for Current Task

Required parameters should be set for current task my_task.

This example uses 2 threads, Japanese Wikipedia.

wscraper set --wikipedia my_wp --worker 2 --language japanese

7. Unsetting Parameters

If you mistake at work 6, you can delete parameters by running following command.

(Example of the parameter worker.)

wscraper unset --worker

7. Checking Status of Current Task

wscraper status

Current task name and each parameter is printed.

8. Setting Tokenizer for Current Task

This example uses tokenizer MeCab. Tokenizer name is mecab

wscraper tokenizer mecab

9. Creating Model for Current Task

This example is going to create a model.

Its algorithm is word2vec and name is my_model.

wscraper model new my_model word2vec

10. Deleting Model

If you mistake at work 9, you can delete model by indicating name.

wscraper model delete my_model

11. Building Model

wscraper model build my_model

12. Editing Tokenizer Arguments

This is not supported yet.

Please run python code to reset tokenizer.

>>> from wscraper.base import Config
>>> config = Config("my_task")
>>> config.set_tokenizer(method = "tokenizer_method", arguments = { "key1": value1, "key2": value2, ... })

13. Editing Model Arguments

This is not supported yet for console.

Please run python code.

>>> from wscraper.base import Config
>>> config = Config("my_task")
>>> config.update_model_arguments("my_model", { "key1": value1, "key2": value2, ... })
>>> config.delete_model_arguments("my_model", [ "key1", "key2", ...]) # if you want to delete parameters

License

The source code is licensed MIT.

Please check the file LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wscraper-0.0.2.tar.gz (16.8 kB view details)

Uploaded Source

File details

Details for the file wscraper-0.0.2.tar.gz.

File metadata

  • Download URL: wscraper-0.0.2.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.9

File hashes

Hashes for wscraper-0.0.2.tar.gz
Algorithm Hash digest
SHA256 656d1fd3abbe7596232d854b93d114b47d113b2b148ec45f180be9245b0bed07
MD5 07c2f159c795616bc4b35dc98e5f5265
BLAKE2b-256 f3ed9f5378ee355093d8a0dfcd421be88ee94fdd7fb2c0e07fe097e880b76aa3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page