-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prepare to publish to pypi * Resolve comments * More updates to rules * Refactor for the cli tool * Restructure for package release * 加入 㩒 * Add 'label' output type * Update README * Add tests * Add github action for publishing * Publish to pypi * v1.0.1 * Bump version
- Loading branch information
1 parent
cd9d8b7
commit 2c56043
Showing
9 changed files
with
282 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Publish Python Package to PyPI | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
build-and-publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.12" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Run tests | ||
run: | | ||
python -m unittest tests/test_judge.py | ||
- name: Build and publish | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .judge import judge | ||
from .version import __version__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import argparse | ||
import sys | ||
from .judge import judge | ||
|
||
def main(): | ||
''' | ||
When used as a command line tool, specify input text file with `--input <INPUT.txt>`, and output type with `--type <TYPE>`. | ||
''' | ||
argparser = argparse.ArgumentParser( | ||
description='Specify input text file with `--input <INPUT.txt>`, where each line is a sentence. ') | ||
|
||
argparser.add_argument('--input', type=str, default='input.txt', help='Specify input text file, where each line is a sentence. Default is `input.txt`.') | ||
argparser.add_argument('--type', type=str, default='all', help='Specify the type of output. `all` for all sentences with a class label prepended, `cantonese` for Cantonese sentences, `mandarin` for Mandarin sentences, `mixed` for mixed Mandarin-Cantonese sentences, `neutral` for neutral sentences. Default is `all`.') | ||
|
||
args = argparser.parse_args() | ||
|
||
with open(args.input, encoding='utf-8') as f: | ||
for line in f: | ||
l = line.strip() | ||
judgement: str = judge(l) | ||
if args.type == 'all': | ||
sys.stdout.write(f'{judgement}\t{l}\n') | ||
elif args.type == 'label': | ||
sys.stdout.write(f'{judgement}\n') | ||
elif args.type == judgement: | ||
sys.stdout.write(f'{l}\n') | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "1.0.1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from setuptools import setup, find_packages | ||
from cantofilter import __version__ | ||
|
||
# Read the contents of your README file | ||
with open("README.md", "r", encoding="utf-8") as fh: | ||
long_description = fh.read() | ||
|
||
setup( | ||
name="canto-filter", | ||
version=__version__, | ||
author="CanCLID (Cantonese Computational Linguistics Infrastructure Development Workgroup)", | ||
author_email="[email protected]", | ||
description="粵文分類篩選器 Cantonese text filter", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
packages=find_packages(), | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.6", | ||
"Programming Language :: Python :: 3.7", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3.12", | ||
"License :: OSI Approved :: MIT License", | ||
"Intended Audience :: Developers", | ||
"Topic :: Text Processing :: Linguistic", | ||
"Natural Language :: Cantonese", | ||
"Operating System :: OS Independent", | ||
], | ||
python_requires=">=3.6", | ||
entry_points={ | ||
"console_scripts": [ | ||
"cantofilter=cantofilter.cli:main", # 'command=package.module:function' | ||
], | ||
}, | ||
) |
Empty file.
Oops, something went wrong.