Skip to main content

Build fcitx5/RIME dictionaries from MediaWiki sites

Project description

mw2fcitx

Build fcitx5/RIME dictionaries from MediaWiki sites.

PyPI Tests codecov: Coverage

pip install mw2fcitx
# or if you want to just install for current user
pip install mw2fcitx --user
# or if you want to just run it (needs Pipx)
pipx run mw2fcitx

For the pre-built moegirl dictionary info, see the wiki.

CLI Usage

mw2fcitx -c config_script.py

Configuration Script Format

# By default we assume the configuration is located at a variable
#     called "exports".
# You can change this with `-n any_name` in the CLI.

exports = {
    # Source configurations.
    "source": {
        # MediaWiki api.php path, if to fetch titles from online.
        "api_path": "https://zh.moegirl.org.cn/api.php",
        # Title file path, if to fetch titles from local file. (optional)
        # Can be a path or a list of paths.
        "file_path": ["titles.txt"],
        "kwargs": {
            # Title number limit for fetching. (optional)
            "title_limit": 120,
            # Title number limit for fetching via API. (optional)
            # Overrides title_limit.
            "api_title_limit": 120,
            # Title number limit for each fetch via file. (optional)
            # Overrides title_limit.
            "file_title_limit": 60,
            # Partial session file on exception (optional)
            "partial": "partial.json",
            # Title list export path. (optional)
            "output": "titles.txt",
            # Delay between MediaWiki API requests in seconds. (optional)
            "request_delay": 2,
            # Results per API request; same as `aplimit` in MediaWiki docs. (optional)
            "aplimit": "max"
        }
    },
    # Tweaks configurations as an list.
    # Every tweak function accepts a list of titles and return
    #     a list of title.
    "tweaks":
        tweaks,
    # Converter configurations.
    "converter": {
        # opencc is a built-in converter.
        # For custom converter functions, just give the function itself.
        "use": "opencc",
        "kwargs": {}
    },
    # Generator configurations.
    "generator": [{
        # rime is a built-in generator.
        # For custom generator functions, just give the function itself.
        "use": "rime",
        "kwargs": {
            # Destination dictionary filename. (optional)
            "output": "moegirl.dict.yml"
        }
    }, {
        # pinyin is a built-in generator.
        # This generator depends on `libime`.
        "use": "pinyin",
        "kwargs": {
            # Destination dictionary filename. (mandatory)
            "output": "moegirl.dict"
        }
    }]
}

A sample config file is here: sample_config.py

License

The Unlicense

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

mw2fcitx-0.16.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

mw2fcitx-0.16.0-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file mw2fcitx-0.16.0.tar.gz.

File metadata

  • Download URL: mw2fcitx-0.16.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for mw2fcitx-0.16.0.tar.gz
Algorithm Hash digest
SHA256 278d60371b9f1cfa61406666bcadea8e926e6b9d2f6ef62c714678e3048205f4
MD5 0f2a0196025fd63c40d0ad0712271af3
BLAKE2b-256 3647c58f44634537ef617adc0bc238a79a333f2a66c796ced6fd6de166d00672

See more details on using hashes here.

File details

Details for the file mw2fcitx-0.16.0-py3-none-any.whl.

File metadata

  • Download URL: mw2fcitx-0.16.0-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for mw2fcitx-0.16.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d1e895d7d6d5fc7eb03f257a904df505153659f40dfab49938a3fdb1a42d1d9
MD5 6e049adfd00f299ff6b6f6a1707ddf2a
BLAKE2b-256 4d9991720e7be329c576f1fe62c011dc77aea28db1e79fba7addcd3058f77b2f

See more details on using hashes here.

Supported by

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