# Installation
```
pip3 install --verbose x2cdict
```
# Usage
### Environment setting
* `DICT_DB_HOST` is `127.0.0.1` by default
* `DICT_DB_USER` is `dict` by default
* `DICT_DB_PASS` is `turingmachine` by default
* `DEEPL_AUTH_KEY` has 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](https://github.com/bajiu-dict/deploy_dict_mongo).
### 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/bin` to see whether the executable `x2cdict_*` is installed.
* Add `export PATH="$HOME/.local/bin:$PATH"` in `$HOME/.bashrc`
* 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](https://python-poetry.org/docs/)
### 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 `version` in
* `pyproject.toml`
* `x2cdict/__init__.py`
* `tests/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](https://python-poetry.org/docs/repositories/)
* Publish to pypi test by `poetry publish -r test`
### Publish through CI
* Github action build and publish package to [test pypi repo](https://test.pypi.org/)
```
git tag [x.x.x]
git push origin master
```
* Manually publish to [pypi repo](https://pypi.org/) through [github action](https://github.com/qishe-nlp/x2cdict/actions/workflows/pypi.yml)
Raw data
{
"_id": null,
"home_page": "https://github.com/qishe-nlp/x2cdict",
"name": "x2cdict",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "language,dictionary,Chinese",
"author": "Phoenix Grey",
"author_email": "phoenix.grey0108@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/81/94/fcb6ff2ba65e271ceaf041048ffb4fd2514846bbba3323a77976b458d45a/x2cdict-0.1.48.tar.gz",
"platform": null,
"description": "# Installation\n\n```\npip3 install --verbose x2cdict \n```\n\n# Usage\n### Environment setting\n\n* `DICT_DB_HOST` is `127.0.0.1` by default\n* `DICT_DB_USER` is `dict` by default\n* `DICT_DB_PASS` is `turingmachine` by default\n* `DEEPL_AUTH_KEY` has to be set by yourself\n\n\nThe dictionary db IS NOT BUILT in this project, you HAVE TO install the DB by yourself, refer to [BaJiu Dictionary Installation](https://github.com/bajiu-dict/deploy_dict_mongo).\n\n### Binary Usage\n\n* Search vocabs with PoS assgined\n```\nx2cdict_vocab --fromlang en --tolang cn --pos ADJ --word happy --external False\nx2cdict_vocab --help\n```\n\n* Search vocabs without PoS\n```\nx2cdict_vocab_without_pos --fromlang en --tolang cn --word happy --external False\nx2cdict_vocab_without_pos --help\n```\n\n* Search phrase\n```\nx2cdict_phrase --fromlang en --tolang cn --phrase \"overcome the problem\"\nx2cdict_phrase --help\n```\n\n### Issues\n\n* PATH issue:\n * The folder where the exectuable is installed may not be in your `PATH`. For Linux, check the `$HOME/.local/bin` to see whether the executable `x2cdict_*` is installed.\n * Add `export PATH=\"$HOME/.local/bin:$PATH\"` in `$HOME/.bashrc`\n\n* hpack issue:\n ```\n pip3 uninstall hpack\n pip3 install hpack==3.0.0\n ```\n\n### Package Usage\n```\nfrom x2cdict import VocabDict, PhraseDict\ndef search_vocab(word, pos, fromlang, tolang, external):\n vd = VocabDict(fromlang, tolang)\n r = vd.search(word, pos, external)\n print(r)\n\ndef search_vocab_without_pos(word, fromlang, tolang, external):\n vd = VocabDict(fromlang, tolang)\n r = vd.search_without_pos(word, external)\n print(r)\n\ndef search_phrase(phrase, fromlang, tolang):\n vd = PhraseDict(fromlang, tolang)\n r = vd.search(phrase)\n print(r)\n```\n\nFrom above, `external` is a boolean variable to switch whether using external translation, default is `True`.\n\n# Development\n\n### Clone the project\n```\ngit clone https://github.com/qishe-nlp/x2cdict.git\n```\n\n### Install [poetry](https://python-poetry.org/docs/)\n\n### Install dependencies\n```\npoetry update\n```\n\n### Test\n```\npoetry run pytest -rP\n```\nwhich run tests under `tests/*`\n\n### Execute\n```\npoetry run x2cdict_vocab --help\npoetry run x2cdict_vocab_without_pos --help\npoetry run xc2dict_phrase --help\n```\n\n### Build\n* Change `version` in\n * `pyproject.toml`\n * `x2cdict/__init__.py`\n * `tests/test_x2cdict.py`\n* Build python package by `poetry build`\n\n### Publish from local dev env\n* Set pypi test environment variables in poetry, refer to [poetry doc](https://python-poetry.org/docs/repositories/)\n* Publish to pypi test by `poetry publish -r test`\n\n### Publish through CI \n\n* Github action build and publish package to [test pypi repo](https://test.pypi.org/)\n\n```\ngit tag [x.x.x]\ngit push origin master\n```\n\n* Manually publish to [pypi repo](https://pypi.org/) through [github action](https://github.com/qishe-nlp/x2cdict/actions/workflows/pypi.yml)\n",
"bugtrack_url": null,
"license": "",
"summary": "translate X language into Chinese",
"version": "0.1.48",
"project_urls": {
"Homepage": "https://github.com/qishe-nlp/x2cdict",
"Repository": "https://github.com/qishe-nlp/x2cdict"
},
"split_keywords": [
"language",
"dictionary",
"chinese"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6494ba56a9683b745ec940fc1a61305903bd62ff7b9d25338ddae409dc5538e9",
"md5": "231edba29648807914f0ba250800a677",
"sha256": "2048e8c3f1e8c43751ffc4fb7c38c8cffe930e1d132ba8e8718041a3a6f4a3a3"
},
"downloads": -1,
"filename": "x2cdict-0.1.48-py3-none-any.whl",
"has_sig": false,
"md5_digest": "231edba29648807914f0ba250800a677",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 9527,
"upload_time": "2024-02-23T04:49:53",
"upload_time_iso_8601": "2024-02-23T04:49:53.715692Z",
"url": "https://files.pythonhosted.org/packages/64/94/ba56a9683b745ec940fc1a61305903bd62ff7b9d25338ddae409dc5538e9/x2cdict-0.1.48-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8194fcb6ff2ba65e271ceaf041048ffb4fd2514846bbba3323a77976b458d45a",
"md5": "e4cae573f7d4ed0a8060e8eaa714290f",
"sha256": "fe090a097359f9d57c67bc556de0c6e184a0720183597c5d5d02aa2fe1caf991"
},
"downloads": -1,
"filename": "x2cdict-0.1.48.tar.gz",
"has_sig": false,
"md5_digest": "e4cae573f7d4ed0a8060e8eaa714290f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 6191,
"upload_time": "2024-02-23T04:49:55",
"upload_time_iso_8601": "2024-02-23T04:49:55.139585Z",
"url": "https://files.pythonhosted.org/packages/81/94/fcb6ff2ba65e271ceaf041048ffb4fd2514846bbba3323a77976b458d45a/x2cdict-0.1.48.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-23 04:49:55",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "qishe-nlp",
"github_project": "x2cdict",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "x2cdict"
}