Skip to content

Commit a0cc392

Browse files
committed
Fix download command bug
1 parent 3f6ce93 commit a0cc392

File tree

11 files changed

+56
-32
lines changed

11 files changed

+56
-32
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ docs/_build
2323

2424
# Tagger and parser models
2525
*.model
26+
*.jar
27+
*.mco

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ can be easily modified or extended to develop new models.
2424
python -m perke download
2525
```
2626
Alternatively, you can use another model with same tag names and structure,
27-
and put it in
27+
and put it in the
2828
[`resources`](https://github.com/alirezah320/perke/tree/main/perke/resources)
2929
directory.
3030

docs/install.rst

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Installation
22
============
3-
Perke is a Python package, which means you need to download and install
4-
Python from `python.org <https://www.python.org/downloads>`_ if you haven't already. Once
5-
you have Python installed, follow bellow steps:
3+
Perke is a Python package, which means you need to download and install Python
4+
from `python.org <https://www.python.org/downloads>`_ if you haven't already.
5+
Once you have Python installed, follow bellow steps:
66

77
- The easiest way to install is from PyPI:
88

@@ -17,8 +17,15 @@ you have Python installed, follow bellow steps:
1717
1818
pip install git+https://github.com/tweepy/tweepy.git
1919
20-
- Perke also requires a POS tagger model that can be obtained from
21-
`here <https://github.com/sobhe/hazm/releases/download/v0.5/resources-0.5.zip>`_
22-
and must be put in
20+
- Perke also requires a trained POS tagger model. We use
21+
`hazm's <https://github.com/sobhe/hazm>`_ tagger model. You can download this
22+
model using the following command:
23+
24+
.. code:: bash
25+
26+
python -m perke download
27+
28+
Alternatively, you can use another model with same tag names and structure,
29+
and put it in the
2330
`resources <https://github.com/alirezah320/perke/tree/main/perke/resources>`_
2431
directory.

perke/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
import perke.commands
21
import perke.unsupervised

perke/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from perke.cli.base import setup_cli
2+
3+
if __name__ == '__main__':
4+
setup_cli()

perke/cli/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from perke.cli.base import app, setup_cli
2+
from perke.cli.clear import clear
3+
from perke.cli.download import download

perke/cli/base.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import typer
2+
from typer.main import get_command
3+
4+
app = typer.Typer(name='perke')
5+
6+
7+
def setup_cli() -> None:
8+
"""
9+
Setup command-line interface for perke.
10+
"""
11+
# Ensure that the help messages always display the correct prompt
12+
command = get_command(app)
13+
command(prog_name='python -m perke')
Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,25 @@
77
from github import Github
88
from github.GitReleaseAsset import GitReleaseAsset
99

10-
from perke.commands.base import app
10+
from perke.cli.base import app
11+
12+
13+
@app.command('download')
14+
def download_command() -> None:
15+
"""
16+
Downloads latest resources (tagger and parser models) that Perke
17+
needs.
18+
"""
19+
download()
20+
21+
22+
def download() -> None:
23+
"""
24+
Function version of `download_command` to be available in the package.
25+
"""
26+
asset = get_latest_resources_asset()
27+
extract_path = join(dirname(dirname(__file__)), 'resources')
28+
download_and_extract_asset(asset, extract_path)
1129

1230

1331
def get_latest_resources_asset() -> GitReleaseAsset:
@@ -54,14 +72,3 @@ def download_and_extract_asset(asset: GitReleaseAsset,
5472
with ZipFile(io_file) as zip_file:
5573
zip_file.extractall(path=extract_path)
5674
typer.echo('Download completed.')
57-
58-
59-
@app.command()
60-
def download() -> None:
61-
"""
62-
Download latest resources (tagger and parser models) that Perke
63-
needs.
64-
"""
65-
asset = get_latest_resources_asset()
66-
extract_to = join(dirname(dirname(__file__)), 'resources')
67-
download_and_extract_asset(asset, extract_to)

perke/commands/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

perke/commands/base.py

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)