Installation
pip3 install --verbose x2cdict
Usage
Environment setting
DICT_DB_HOSTis127.0.0.1by defaultDICT_DB_USERisdictby defaultDICT_DB_PASSisturingmachineby defaultDEEPL_AUTH_KEYhas to be set by yourself
The dictionary db IS NOT BUILT in this project, you HAVE TO install the DB by yourself, refer to BaJiu Dictionary Installation.
Binary Usage
- Search vocabs with PoS assgined
x2cdict_vocab --fromlang en --tolang cn --pos ADJ --word happy --external False
x2cdict_vocab --help
- Search vocabs without PoS
x2cdict_vocab_without_pos --fromlang en --tolang cn --word happy --external False
x2cdict_vocab_without_pos --help
- Search phrase
x2cdict_phrase --fromlang en --tolang cn --phrase "overcome the problem"
x2cdict_phrase --help
Issues
-
PATH issue:
- The folder where the exectuable is installed may not be in your
PATH. For Linux, check the$HOME/.local/binto see whether the executablex2cdict_*is installed. - Add
export PATH="$HOME/.local/bin:$PATH"in$HOME/.bashrc
- The folder where the exectuable is installed may not be in your
-
hpack issue:
pip3 uninstall hpack pip3 install hpack==3.0.0
Package Usage
from x2cdict import VocabDict, PhraseDict
def search_vocab(word, pos, fromlang, tolang, external):
vd = VocabDict(fromlang, tolang)
r = vd.search(word, pos, external)
print(r)
def search_vocab_without_pos(word, fromlang, tolang, external):
vd = VocabDict(fromlang, tolang)
r = vd.search_without_pos(word, external)
print(r)
def search_phrase(phrase, fromlang, tolang):
vd = PhraseDict(fromlang, tolang)
r = vd.search(phrase)
print(r)
From above, external is a boolean variable to switch whether using external translation, default is True.
Development
Clone the project
git clone https://github.com/qishe-nlp/x2cdict.git
Install poetry
Install dependencies
poetry update
Test
poetry run pytest -rP
which run tests under tests/*
Execute
poetry run x2cdict_vocab --help
poetry run x2cdict_vocab_without_pos --help
poetry run xc2dict_phrase --help
Build
- Change
versioninpyproject.tomlx2cdict/__init__.pytests/test_x2cdict.py
- Build python package by
poetry build
Publish from local dev env
- Set pypi test environment variables in poetry, refer to poetry doc
- Publish to pypi test by
poetry publish -r test
Publish through CI
- Github action build and publish package to test pypi repo
git tag [x.x.x]
git push origin master
- Manually publish to pypi repo through github action
Release files for x2cdict 0.1.48
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| x2cdict-0.1.48.tar.gz | 6.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| x2cdict-0.1.48-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.7 kB
Release files / x2cdict-0.1.48.tar.gz
| Download URL | x2cdict-0.1.48.tar.gz |
|---|---|
| Size | 6.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe090a097359f9d57c67bc556de0c6e184a0720183597c5d5d02aa2fe1caf991
|
|
BLAKE2b-256 checksum How to use checksums |
8194fcb6ff2ba65e271ceaf041048ffb4fd2514846bbba3323a77976b458d45a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1019-azure
|
Release files / x2cdict-0.1.48-py3-none-any.whl
| Download URL | x2cdict-0.1.48-py3-none-any.whl |
|---|---|
| Size | 9.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2048e8c3f1e8c43751ffc4fb7c38c8cffe930e1d132ba8e8718041a3a6f4a3a3
|
|
BLAKE2b-256 checksum How to use checksums |
6494ba56a9683b745ec940fc1a61305903bd62ff7b9d25338ddae409dc5538e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.11.0 Linux/6.2.0-1019-azure
|