Skip to content

Commit

Permalink
Merge branch 'hotfix/0.5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
emfomy committed Jul 23, 2019
2 parents 8f90a72 + 0150e1e commit c3af3d0
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 18 deletions.
24 changes: 24 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# .readthedocs.yml

# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Build documentation with MkDocs
#mkdocs:
# configuration: mkdocs.yml

# Optionally build your docs in additional formats such as PDF and ePub
formats: all

# Optionally set the version of Python and requirements required to build your docs
python:
version: 3.6
install:
- requirements: requirements.txt
79 changes: 79 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ Author

* Mu Yang <[email protected]>

Documentation
-------------

http://ckipnlp.readthedocs.io/

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

Expand Down Expand Up @@ -121,6 +126,80 @@ Installation Options
| ``--rdb-dir=<rdb-dir>`` | "RDB" directory | ``<parser-share-dir>/RDB`` |
+-----------------------------------------------+---------------------------------------+-------------------------------+

Usage
=====

See http://ckipnlp.readthedocs.io/ for API details.

CKIPWS
------

.. code-block:: python
import ckipnlp.ws
print(ckipnlp.__name__, ckipnlp.__version__)
ws = ckipnlp.ws.CkipWs(logger=False)
print(ws('中文字喔'))
for l in ws.apply_list(['中文字喔', '啊哈哈哈']): print(l)
ws.apply_file(ifile='sample/sample.txt', ofile='output/sample.tag', uwfile='output/sample.uw')
with open('output/sample.tag') as fin:
print(fin.read())
with open('output/sample.uw') as fin:
print(fin.read())
CKIP-Parser
-----------

.. code-block:: python
import ckipnlp.parser
print(ckipnlp.__name__, ckipnlp.__version__)
ps = ckipnlp.parser.CkipParser(logger=False)
print(ps('中文字喔'))
for l in ps.apply_list(['中文字喔', '啊哈哈哈']): print(l)
ps = ckipnlp.parser.CkipParser(logger=False)
print(ps('中文字喔'))
for l in ps.apply_list(['中文字喔', '啊哈哈哈']): print(l)
ps.apply_file(ifile='sample/sample.txt', ofile='output/sample.tree')
with open('output/sample.tree') as fin:
print(fin.read())
Utilities
---------

.. code-block:: python
import ckipnlp
print(ckipnlp.__name__, ckipnlp.__version__)
from ckipnlp.util.ws import *
from ckipnlp.util.parser import *
# Format CkipWs output
ws_text = ['中文字(Na) 喔(T)', '啊哈(I) 哈哈(D)']
for text in ws_text: print(ckipnlp.util.ws.WsSentence.from_text(text))
for text in ws_text: print(repr(ckipnlp.util.ws.WsSentence.from_text(text)))
# Show CkipParser output as tree
tree_text = 'S(theme:NP(property:N‧的(head:Nhaa:我|Head:DE:的)|Head:Nad(DUMMY1:Nab:早餐|Head:Caa:和|DUMMY2:Naa:午餐))|quantity:Dab:都|Head:VC31:吃完|aspect:Di:了)'
tree = ParserTree.from_text(tree_text)
tree.show()
# Get dummies of node 5
for node in tree.get_dummies(5): print(node)
# Get heads of node 1
for node in tree.get_heads(1): print(node)
# Get relations
for r in tree.get_relations(0): print(r)
FAQ
===

Expand Down
2 changes: 1 addition & 1 deletion ckipnlp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__copyright__ = 'Copyright 2018-2019'

__title__ = 'CKIPNLP'
__version__ = '0.5.0'
__version__ = '0.5.1'
__description__ = 'CKIP CoreNLP Wrappers'
__license__ = "MIT"

Expand Down
28 changes: 11 additions & 17 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXBUILD = _SPHINX=1 sphinx-build
SPHINXBUILDOPTS =
SPHINXAPI = sphinx-apidoc
SPHINXAPIOPTS =
SPHINX = sphinx-build
SPHINXOPTS =

DOCDIR = .
BUILDDIR = _build
APIDIR = _api

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(DOCDIR)" "$(BUILDDIR)" $(SPHINXBUILDOPTS) $(O)
@$(SPHINX) -M help "$(DOCDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile api clean run

api:
@$(SPHINXAPI) -feTM -o "$(APIDIR)" "../ckipnlp" $(SPHINXAPIOPTS)
.PHONY: help Makefile api clean serve

clean: Makefile
@$(SPHINXBUILD) -M $@ "$(DOCDIR)" "$(BUILDDIR)" $(SPHINXBUILDOPTS)
@$(SPHINXBUILD) -M $@ "$(DOCDIR)" "$(APIDIR)" $(SPHINXBUILDOPTS)
@$(SPHINX) -M $@ "$(DOCDIR)" "$(BUILDDIR)" $(SPHINXOPTS)
@$(SPHINX) -M $@ "$(DOCDIR)" "$(APIDIR)" $(SPHINXOPTS)

run:
( cd _build/html/ && python3 -m http.server 8080 )
serve:
( cd $(BUILDDIR)/html/ && python3 -m http.server 8080 )

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXBUILDOPTS).
%: api Makefile
@$(SPHINXBUILD) -M $@ "$(DOCDIR)" "$(BUILDDIR)" $(SPHINXBUILDOPTS) $(O)
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINX) -M $@ "$(DOCDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
10 changes: 10 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
os.environ['_SPHINX'] = "1"
import ckipnlp as __about

def run_apidoc(_):
from sphinx.ext.apidoc import main
main(['-feTM', '-o', '_api', '../ckipnlp'])

def setup(app):
app.connect('builder-inited', run_apidoc)


# -- Project information -----------------------------------------------------

Expand All @@ -27,6 +35,8 @@
# The full version, including alpha/beta/rc tags
release = 'v'+__about.__version__

# Master documentation
master_doc = 'index'

# -- General configuration ---------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.

0 comments on commit c3af3d0

Please sign in to comment.