Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/build_wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build

on: [push, pull_request]

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
# os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-20.04]

steps:
- uses: actions/checkout@v2

- name: Build wheels
uses: pypa/[email protected]
# to supply options, put them in 'env', like:
env:
CIBW_BEFORE_ALL_LINUX: yum install -y wget
# install something required for the build (you might want to use pyproject.toml instead)
CIBW_BEFORE_BUILD: pip install pybind11 && python setup.py install
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.8'

- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz
23 changes: 17 additions & 6 deletions mecab/mecab.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,25 @@ class MeCabError(Exception):
pass


class MeCab: # APIs are inspried by KoNLPy
def __init__(self, dicpath=''):
argument = ''
class MeCab: # APIs are inspired by KoNLPy
def __init__(self, dicpath=None, mecabrc_path=None):
arguments = []

if dicpath != '':
argument = '-d %s' % dicpath
if mecabrc_path:
arguments.append(f"-r {mecabrc_path}")

self.tagger = _mecab.Tagger(argument)
if dicpath:
arguments.append(f"-d {dicpath}")

arguments_str = " ".join(arguments)

try:
self.tagger = _mecab.Tagger(arguments_str)
except TypeError as e:
raise ValueError(
"Error loading tagger; try specifying the `dic_path' and/or `mecabrc_path`; "
f"({e})"
)

def parse(self, sentence):
lattice = _create_lattice(sentence)
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"pybind11>=2.0",
]
build-backend = "setuptools.build_meta"