Skip to content

Commit

Permalink
Merge branch 'hotfix/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
emfomy committed May 26, 2020
2 parents ea6cc1c + 2d486ab commit 1781139
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 37 deletions.
45 changes: 24 additions & 21 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
Introduction
============

A Linux Python wrapper for CKIP classic tools — `CKIP Word Segmentation <http://ckip.iis.sinica.edu.tw/project/wordsegment/>`__ and `CKIP Parser <http://ckip.iis.sinica.edu.tw/project/parser/>`__.

.. attention::
Please use `CKIPNLP <https://ckipnlp.readthedocs.io/>`__ for structured data types and pipeline drivers.

.. attention::
Please use `CKIPNLP <https://ckipnlp.readthedocs.io/>`_ for structured data types and pipeline drivers.
For Python 2 users, please use `PyCkip 0.4.2 <https://pypi.org/project/pyckip/0.4.2/>`__ instead.

Git
---
Expand Down Expand Up @@ -68,52 +73,50 @@ https://ckip-classic.readthedocs.io/
Contributers
------------

* `Mu Yang <https://muyang.pro>`_ at `CKIP <https://ckip.iis.sinica.edu.tw>`_ (Author & Maintainer)
* `Wei-Yun Ma <https://www.iis.sinica.edu.tw/pages/ma/>`_ at `CKIP <https://ckip.iis.sinica.edu.tw>`_ (Maintainer)
* `Mu Yang <https://muyang.pro>`__ at `CKIP <https://ckip.iis.sinica.edu.tw>`__ (Author & Maintainer)
* `Wei-Yun Ma <https://www.iis.sinica.edu.tw/pages/ma/>`__ at `CKIP <https://ckip.iis.sinica.edu.tw>`__ (Maintainer)

External Links
--------------

- `Online Demo <https://ckip.iis.sinica.edu.tw/service/corenlp>`_
- `Online Demo <https://ckip.iis.sinica.edu.tw/service/corenlp>`__

Requirements
------------

* `Python <https://www.python.org>`_ 3.5+
* `Cython <https://cython.org>`_ 0.29+

.. attention::
For Python 2 users, please use `PyCkip 0.4.2 <https://pypi.org/project/pyckip/0.4.2/>`_ instead.
* `Python <https://www.python.org>`__ 3.5+
* `Cython <https://cython.org>`__ 0.29+

CKIPWS (Optional)
^^^^^^^^^^^^^^^^^
Note that one should have CKIPWS/CKIPParser for this project:

* `CKIP Word Segmentation <http://ckip.iis.sinica.edu.tw/project/wordsegment/>`_ Linux version 20190524+

CKIPParser (Optional)
^^^^^^^^^^^^^^^^^^^^^

* `CKIP Parser <http://ckip.iis.sinica.edu.tw/project/parser/>`_ Linux version 20190506+ (20190725+ recommended)
* `CKIP Word Segmentation <https://ckip.iis.sinica.edu.tw/project/ws/>`__ Linux version 20190524+
- `Academic License <http://ckipsvr.iis.sinica.edu.tw/ckipws/reg.php>`__
- `Commercial License <https://iptt.sinica.edu.tw/shares/405>`__
* `CKIP Parser <https://ckip.iis.sinica.edu.tw/project/parser/>`__ Linux version 20190725+
- Academic License (not available)
- `Commercial License <https://iptt.sinica.edu.tw/shares/447>`__

Installation
============

Denote ``<ckipws-linux-root>`` as the root path of CKIPWS Linux Version, and ``<ckipparser-linux-root>`` as the root path of CKIPParser Linux Version.
Download CKIPWS and/or CKIPParser from above links. Denote ``<ckipws-linux-root>`` as the folder containing CKIPWS, and ``<ckipparser-linux-root>`` as the folder containing CKIPParser.

Install Using Pip
-----------------

.. code-block:: bash
pip install --upgrade ckip-classic
pip install --no-deps --force-reinstall --upgrade ckip-classic \
pip install --force-reinstall --upgrade ckip-classic \
--install-option='--ws' \
--install-option='--ws-dir=<ckipws-linux-root>' \
--install-option='--parser' \
--install-option='--parser-dir=<ckipparser-linux-root>'
Ignore ws/parser options if one doesn't have CKIPWS/CKIPParser.

.. attention::
Please use absolute paths.

Installation Options
--------------------

Expand Down Expand Up @@ -238,7 +241,7 @@ License

|CC BY-NC-SA 4.0|

Copyright (c) 2018-2020 `CKIP Lab <https://ckip.iis.sinica.edu.tw>`_ under the `CC BY-NC-SA 4.0 License <http://creativecommons.org/licenses/by-nc-sa/4.0/>`_.
Copyright (c) 2018-2020 `CKIP Lab <https://ckip.iis.sinica.edu.tw>`__ under the `CC BY-NC-SA 4.0 License <http://creativecommons.org/licenses/by-nc-sa/4.0/>`__.

.. |CC BY-NC-SA 4.0| image:: https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png
:target: http://creativecommons.org/licenses/by-nc-sa/4.0/
2 changes: 1 addition & 1 deletion ckip_classic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

__pkgname__ = 'ckip-classic'
__title__ = 'CkipClassic'
__version__ = '1.0.2'
__version__ = '1.0.3'
__description__ = 'CKIP Classic NLP Tools'
__license__ = 'CC BY-NC-SA 4.0'

Expand Down
44 changes: 29 additions & 15 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,43 +186,54 @@ def finalize_options(self):

def run(self):

name2mod = {em.name: em for em in self.distribution.ext_modules}

# CKIPWS
if self.ws:
print('- Enable CKIPWS support')
if self.ws_lib_dir:
print('- Use CKIPWS library from (%s)' % self.ws_lib_dir)
i = next((i for i, em in enumerate(self.distribution.ext_modules) if em.name == 'ckip_classic._core.ws'), None)
self.distribution.ext_modules[i].library_dirs.append(self.ws_lib_dir)
self.distribution.ext_modules[i].runtime_library_dirs.append(self.ws_lib_dir)
print('- Use CKIPWS library from "%s"' % self.ws_lib_dir)
mod_ws = name2mod['ckip_classic._core.ws']
mod_ws.library_dirs.append(self.ws_lib_dir)
mod_ws.runtime_library_dirs.append(self.ws_lib_dir)
for lib in mod_ws.libraries:
libfile = os.path.join(self.ws_lib_dir, lib + '.so')
if not os.path.exists(libfile):
print(' - [WARNING] Shared library not exist: %s' % libfile)
else:
print('- Disable CKIPWS support')
i = next((i for i, em in enumerate(self.distribution.ext_modules) if em.name == 'ckip_classic._core.ws'), None)
if i is not None: del self.distribution.ext_modules[i]
del name2mod['ckip_classic._core.ws']

# CKIPParser
if self.parser:
print('- Enable CKIPParser support')
if self.parser_lib_dir:
print('- Use CKIPParser library from (%s)' % self.parser_lib_dir)
i = next((i for i, em in enumerate(self.distribution.ext_modules) if em.name == 'ckip_classic._core.parser'), None)
self.distribution.ext_modules[i].library_dirs.append(self.parser_lib_dir)
self.distribution.ext_modules[i].runtime_library_dirs.append(self.parser_lib_dir)
print('- Use CKIPParser library from "%s"' % self.parser_lib_dir)
mod_parser = name2mod['ckip_classic._core.parser']
mod_parser.library_dirs.append(self.parser_lib_dir)
mod_parser.runtime_library_dirs.append(self.parser_lib_dir)
for lib in mod_parser.libraries:
libfile = os.path.join(self.parser_lib_dir, lib + '.so')
if not os.path.exists(libfile):
print(' - [WARNING] Shared library not exist: %s' % libfile)
else:
print('- Disable CKIPParser support')
i = next((i for i, em in enumerate(self.distribution.ext_modules) if em.name == 'ckip_classic._core.parser'), None)
if i is not None: del self.distribution.ext_modules[i]
del name2mod['ckip_classic._core.parser']

# Re-register modules
self.distribution.ext_modules = list(name2mod.values())

# Data
if self.data2_dir:
print('- Use "Data2" from (%s)' % self.data2_dir)
print('- Use "Data2" from "%s"' % self.data2_dir)
self.data_files('share/ckip_classic/Data2/', self.data2_dir)

if self.rule_dir:
print('- Use "Rule" from (%s)' % self.rule_dir)
print('- Use "Rule" from "%s"' % self.rule_dir)
self.data_files('share/ckip_classic/Rule/', self.rule_dir)

if self.rdb_dir:
print('- Use "RDB" from (%s)' % self.rdb_dir)
print('- Use "RDB" from "%s"' % self.rdb_dir)
self.data_files('share/ckip_classic/RDB/', self.rdb_dir)

# Python packages
Expand All @@ -231,11 +242,14 @@ def run(self):
super(CommandMixin, self).run()

def data_files(self, prefix, dirtop):
count = 0
for dirpath, _, files in os.walk(dirtop):
count += len(files)
self.distribution.data_files.append((
os.path.join(prefix, os.path.relpath(dirpath, dirtop)),
[os.path.join(dirpath, file) for file in files],
))
print(' - Found %s files' % count)

class InstallCommand(CommandMixin, install):
user_options = install.user_options + CommandMixin.user_options
Expand Down

0 comments on commit 1781139

Please sign in to comment.