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

database

A module pip install sqlalchemy is required.

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 Tasks and Wikipedia Resources

This command is also independent of task 2, 3.

It can check tasks and Wikipedia resources.

wscraper list

output

Available task:
  - my_task

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

14. Database Migration

Tables of configurated database are created.

wscraper database migrate

15. Inserting Records for Database

Records of articles are inserted for tables.

wscraper database seed

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.3.tar.gz (19.9 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: wscraper-0.0.3.tar.gz
  • Upload date:
  • Size: 19.9 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.3.tar.gz
Algorithm Hash digest
SHA256 62da482d02424dfb7dd1249d757e5bdc3304bd4cf2e4bddce51846a48e2f8047
MD5 761e0fab5961d962a333ab06835b7cc8
BLAKE2b-256 f3980ab215c4197763277fd56e4a9ba0f9dd25414adb1d204963acd8a4b2740a

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