Skip to content

Commit 18fc3a8

Browse files
committed
Merge branch 'hotfix/0.9.1' into master
2 parents fc0dceb + cd00efb commit 18fc3a8

18 files changed

+62
-62
lines changed

ckipnlp/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
__copyright__ = '2018-2020 CKIP Lab'
1111

1212
__title__ = 'CKIPNLP'
13-
__version__ = '0.9.0'
13+
__version__ = '0.9.1'
1414
__description__ = 'CKIP CoreNLP'
1515
__license__ = 'CC BY-NC-SA 4.0'
1616

ckipnlp/container/parse.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding:utf-8 -*-
33

44
"""
5-
This module provides containers for parse sentences.
5+
This module provides containers for parsed sentences.
66
"""
77

88
__author__ = 'Mu Yang <http://muyang.pro>'

ckipnlp/container/util/parse_tree.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# -*- coding:utf-8 -*-
33

44
"""
5-
This module provides tree containers for sentence parse.
5+
This module provides tree containers for parsed sentences.
66
"""
77

88
__author__ = 'Mu Yang <http://muyang.pro>'
@@ -23,7 +23,7 @@
2323
Node as _Node,
2424
)
2525

26-
from ckipnlp.data.constituency import (
26+
from ckipnlp.data.conparse import (
2727
SUBJECT_ROLES as _SUBJECT_ROLES,
2828
NEUTRAL_ROLES as _NEUTRAL_ROLES,
2929
)
File renamed without changes.

ckipnlp/driver/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
from .classic import (
1919
CkipClassicWordSegmenter,
20-
CkipClassicConstituencyParser,
20+
CkipClassicConParser,
2121
)
2222

2323
from .ss import (

ckipnlp/driver/classic.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def _call(self, *, _wspos):
130130

131131
################################################################################################################################
132132

133-
class CkipClassicConstituencyParser(_BaseDriver):
134-
"""The CKIP sentence parsing driver with CkipClassic backend.
133+
class CkipClassicConParser(_BaseDriver):
134+
"""The CKIP constituency parsing driver with CkipClassic backend.
135135
136136
Arguments
137137
---------
@@ -140,17 +140,17 @@ class CkipClassicConstituencyParser(_BaseDriver):
140140
141141
.. method:: __call__(*, ws, pos)
142142
143-
Apply sentence parsing.
143+
Apply constituency parsing.
144144
145145
Parameters
146146
- **ws** (:class:`~ckipnlp.container.text.TextParagraph`) — The word-segmented sentences.
147147
- **pos** (:class:`~ckipnlp.container.text.TextParagraph`) — The part-of-speech sentences.
148148
149149
Returns
150-
**constituency** (:class:`~ckipnlp.container.parse.ParseSentence`) — The constituency-parsing sentences.
150+
**conparse** (:class:`~ckipnlp.container.parse.ParseSentence`) — The constituency-parsing sentences.
151151
"""
152152

153-
driver_type = 'constituncy_parser'
153+
driver_type = 'con_parser'
154154
driver_family = 'classic'
155155
driver_inputs = ('ws', 'pos',)
156156

@@ -169,9 +169,9 @@ def _call(self, *, ws, pos):
169169
assert isinstance(pos, _SegParagraph)
170170

171171

172-
constituency_text = []
172+
conparse_text = []
173173
for ws_sent, pos_sent in zip(ws, pos):
174-
constituency_sent_text = []
174+
conparse_sent_text = []
175175
ws_clause = []
176176
pos_clause = []
177177
for ws_token, pos_token in _chain(zip(ws_sent, pos_sent), [(None, None),]):
@@ -181,16 +181,16 @@ def _call(self, *, ws, pos):
181181
continue
182182

183183
# Segment clauses by punctuations
184-
if pos_token is None or pos_token.endswith('CATEGORY'):
184+
if pos_token is None or (pos_token.endswith('CATEGORY') and pos_token != 'PAUSECATEGORY'):
185185
if ws_clause:
186186
wspos_clause_text = _WsPosSentence.to_text(ws_clause, pos_clause)
187-
for constituency_clause_text in self._core.apply_list([wspos_clause_text]):
188-
constituency_sent_text.append([self._normalize(constituency_clause_text), '',])
187+
for conparse_clause_text in self._core.apply_list([wspos_clause_text]):
188+
conparse_sent_text.append([self._normalize(conparse_clause_text), '',])
189189

190190
if ws_token:
191-
if not constituency_sent_text:
192-
constituency_sent_text.append([None, '',])
193-
constituency_sent_text[-1][1] += ws_token
191+
if not conparse_sent_text:
192+
conparse_sent_text.append([None, '',])
193+
conparse_sent_text[-1][1] += ws_token
194194

195195
ws_clause = []
196196
pos_clause = []
@@ -199,10 +199,10 @@ def _call(self, *, ws, pos):
199199
ws_clause.append(self._half2full(ws_token))
200200
pos_clause.append(pos_token)
201201

202-
constituency_text.append(constituency_sent_text)
203-
constituency = _ParseParagraph.from_list(constituency_text)
202+
conparse_text.append(conparse_sent_text)
203+
conparse = _ParseParagraph.from_list(conparse_text)
204204

205-
return constituency
205+
return conparse
206206

207207
@staticmethod
208208
def _half2full(text):

ckipnlp/driver/coref.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
CorefParagraph as _CorefParagraph,
2626
)
2727

28-
from ckipnlp.data.constituency import (
28+
from ckipnlp.data.conparse import (
2929
APPOSITION_ROLES as _APPOSITION_ROLES,
3030
)
3131

@@ -49,12 +49,12 @@ class CkipCorefChunker(_BaseDriver): # pylint: disable=too-few-public-methods
4949
lazy : bool
5050
Lazy initialize the driver.
5151
52-
.. method:: __call__(*, constituency)
52+
.. method:: __call__(*, conparse)
5353
5454
Apply coreference delectation.
5555
5656
Parameters
57-
**constituency** (:class:`~ckipnlp.container.parse.ParseParagraph`) — The constituency-parsing sentences.
57+
**conparse** (:class:`~ckipnlp.container.parse.ParseParagraph`) — The constituency-parsing sentences.
5858
5959
Returns
6060
**coref** (:class:`~ckipnlp.container.coref.CorefParagraph`) — The coreference results.
@@ -67,15 +67,15 @@ class CkipCorefChunker(_BaseDriver): # pylint: disable=too-few-public-methods
6767
def _init(self):
6868
pass
6969

70-
def _call(self, *, constituency):
71-
assert isinstance(constituency, _ParseParagraph)
70+
def _call(self, *, conparse):
71+
assert isinstance(conparse, _ParseParagraph)
7272

7373
# Convert to tree structure
7474
tree_list = [
7575
[
7676
(clause.to_tree(), clause.delim,)
7777
for clause in sent
78-
] for sent in constituency
78+
] for sent in conparse
7979
]
8080

8181
# Find coreference

ckipnlp/pipeline/coref.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ class CkipCorefDocument(_Mapping):
3232
The word-segmented sentences.
3333
pos : :class:`~ckipnlp.container.seg.SegParagraph`
3434
The part-of-speech sentences.
35-
constituency : :class:`~ckipnlp.container.constituency.ParseParagraph`
35+
conparse : :class:`~ckipnlp.container.parse.ParseParagraph`
3636
The constituency sentences.
3737
coref : :class:`~ckipnlp.container.coref.CorefParagraph`
3838
The coreference resolution results.
3939
"""
4040

41-
__keys = ('ws', 'pos', 'constituency', 'coref',)
41+
__keys = ('ws', 'pos', 'conparse', 'coref',)
4242

43-
def __init__(self, *, ws=None, pos=None, constituency=None, coref=None):
43+
def __init__(self, *, ws=None, pos=None, conparse=None, coref=None):
4444
self.ws = ws
4545
self.pos = pos
46-
self.constituency = constituency
46+
self.conparse = conparse
4747
self.coref = coref
4848

4949
def __len__(self):
@@ -74,8 +74,8 @@ class CkipCorefPipeline(_CkipPipeline):
7474
ner_chunker : str
7575
The type of named-entity recognition chunker.
7676
77-
sentence_parser : str
78-
The type of sentence parser.
77+
con_parser : str
78+
The type of constituency parser.
7979
8080
coref_chunker : str
8181
The type of coreference resolution chunker.
@@ -171,10 +171,10 @@ def get_coref(self, doc, corefdoc):
171171
)
172172

173173
# Do parsing
174-
if corefdoc.constituency is None:
175-
corefdoc.constituency = self.get_constituency(corefdoc)
174+
if corefdoc.conparse is None:
175+
corefdoc.conparse = self.get_conparse(corefdoc)
176176

177177
# Do coreference resolution
178-
corefdoc.coref = self._coref_chunker(constituency=corefdoc.constituency)
178+
corefdoc.coref = self._coref_chunker(conparse=corefdoc.conparse)
179179

180180
return corefdoc.coref

ckipnlp/pipeline/kernel.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ class CkipDocument(_Mapping):
3434
The part-of-speech sentences.
3535
ner : :class:`~ckipnlp.container.ner.NerParagraph`
3636
The named-entity recognition results.
37-
constituency : :class:`~ckipnlp.container.parse.ParseParagraph`
37+
conparse : :class:`~ckipnlp.container.parse.ParseParagraph`
3838
The constituency-parsing sentences.
3939
"""
4040

41-
__keys = ('raw', 'text', 'ws', 'pos', 'ner', 'constituency',)
41+
__keys = ('raw', 'text', 'ws', 'pos', 'ner', 'conparse',)
4242

43-
def __init__(self, *, raw=None, text=None, ws=None, pos=None, ner=None, constituency=None):
43+
def __init__(self, *, raw=None, text=None, ws=None, pos=None, ner=None, conparse=None):
4444
self.raw = raw
4545
self.text = text
4646
self.ws = ws
4747
self.pos = pos
4848
self.ner = ner
49-
self.constituency = constituency
49+
self.conparse = conparse
5050

5151
self._wspos = None
5252

@@ -78,8 +78,8 @@ class CkipPipeline:
7878
ner_chunker : str
7979
The type of named-entity recognition chunker.
8080
81-
sentence_parser : str
82-
The type of sentence parser.
81+
con_parser : str
82+
The type of constituency parser.
8383
8484
Other Parameters
8585
----------------
@@ -94,7 +94,7 @@ def __init__(self, *,
9494
sentence_segmenter='default',
9595
word_segmenter='tagger',
9696
pos_tagger='tagger',
97-
sentence_parser='classic',
97+
con_parser='classic',
9898
ner_chunker='tagger',
9999
lazy=True,
100100
opts={},
@@ -125,8 +125,8 @@ def __init__(self, *,
125125
self._pos_tagger = _DriverRegister.get('pos_tagger', pos_tagger)(
126126
lazy=lazy, **opts.get('pos_tagger', {}),
127127
)
128-
self._constituency_parser = _DriverRegister.get('constituncy_parser', sentence_parser)(
129-
lazy=lazy, **opts.get('sentence_parser', {}),
128+
self._con_parser = _DriverRegister.get('con_parser', con_parser)(
129+
lazy=lazy, **opts.get('con_parser', {}),
130130
)
131131
self._ner_chunker = _DriverRegister.get('ner_tagger', ner_chunker)(
132132
lazy=lazy, **opts.get('ner_chunker', {}),
@@ -151,8 +151,8 @@ def _get(self, key, doc):
151151
'pos': (
152152
self._pos_tagger, 'part-of-speech tagging',
153153
),
154-
'constituency': (
155-
self._constituency_parser, 'constituency parsing',
154+
'conparse': (
155+
self._con_parser, 'constituency parsing',
156156
),
157157
'ner': (
158158
self._ner_chunker, 'named-entity recognition',
@@ -261,7 +261,7 @@ def get_ner(self, doc):
261261

262262
########################################################################################################################
263263

264-
def get_constituency(self, doc):
264+
def get_conparse(self, doc):
265265
"""Apply constituency parsing.
266266
267267
Arguments
@@ -271,11 +271,11 @@ def get_constituency(self, doc):
271271
272272
Returns
273273
-------
274-
doc.constituency : :class:`~ckipnlp.container.parse.ParseParagraph`
274+
doc.conparse : :class:`~ckipnlp.container.parse.ParseParagraph`
275275
The constituency parsing sentences.
276276
277277
.. note::
278278
279279
This routine modify **doc** inplace.
280280
"""
281-
return self._get('constituency', doc)
281+
return self._get('conparse', doc)

docs/main/_defn.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
.. Driver
1313
1414
.. |CkipClassicWordSegmenter| replace:: :class:`~ckipnlp.driver.classic.CkipClassicWordSegmenter`
15-
.. |CkipClassicConstituencyParser| replace:: :class:`~ckipnlp.driver.classic.CkipClassicConstituencyParser`
15+
.. |CkipClassicConParser| replace:: :class:`~ckipnlp.driver.classic.CkipClassicConParser`
1616

1717
.. |CkipTaggerWordSegmenter| replace:: :class:`~ckipnlp.driver.tagger.CkipTaggerWordSegmenter`
1818
.. |CkipTaggerPosTagger| replace:: :class:`~ckipnlp.driver.tagger.CkipTaggerPosTagger`

docs/main/tag.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ Constituency Parsing Tags
1313
-------------------------
1414

1515
.. csv-table::
16-
:file: ./tag/constituency_pos.csv
16+
:file: ./tag/conparse_pos.csv
1717
:widths: 50 50
1818
:header-rows: 1
1919

2020
Constituency Parsing Roles
2121
--------------------------
2222

2323
.. csv-table::
24-
:file: ./tag/constituency_role.csv
24+
:file: ./tag/conparse_role.csv
2525
:widths: 50 50
2626
:header-rows: 1
File renamed without changes.
File renamed without changes.

docs/main/usage/driver.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Sentence Segmenter |CkipSentenceSegmenter|
4242
Word Segmenter |CkipTaggerWordSegmenter| |CkipClassicWordSegmenter|†
4343
Pos Tagger |CkipTaggerPosTagger| |CkipClassicWordSegmenter|†
4444
Ner Chunker |CkipTaggerNerChunker|
45-
Constituncy Parser |CkipClassicConstituencyParser|
45+
Constituency Parser |CkipClassicConParser|
4646
Coref Chunker |CkipCorefChunker|
4747
================================ ================================ ================================ ================================
4848

docs/main/usage/pipeline.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ The |CkipPipeline| will compute all necessary dependencies. For example, if one
3838
print(doc.ner)
3939
4040
# Constituency Parsing
41-
pipeline.get_constituency(doc)
42-
print(doc.constituency)
41+
pipeline.get_conparse(doc)
42+
print(doc.conparse)
4343
4444
################################################################
4545

test/script/pipeline/_base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
[ [ '中文字', 'LANGUAGE', (0, 3), ], ],
3737
[ [ '畢卡索', 'PERSON', (6, 9), ], ],
3838
]
39-
constituency = [
39+
conparse = [
4040
[
4141
[ 'S(Head:Nab:中文字|particle:Td:耶)', ',', ],
4242
[ '%(particle:I:啊|manner:Dh:哈|manner:D:哈哈)', '。', ],

test/script/pipeline/run_classic_constituency_parser.py test/script/pipeline/run_classic_con_parser.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from _base import *
99

10-
def test_classic_constituency_parser():
11-
obj = CkipPipeline(sentence_parser='classic')
10+
def test_classic_con_parser():
11+
obj = CkipPipeline(con_parser='classic')
1212
doc = CkipDocument(ws=SegParagraph.from_list(ws), pos=SegParagraph.from_list(pos))
13-
obj.get_constituency(doc)
14-
assert doc.constituency.to_list() == constituency
13+
obj.get_conparse(doc)
14+
assert doc.conparse.to_list() == conparse

test/tox.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,4 @@ commands_pre =
8282
commands =
8383
pytest {toxinidir}/script/pipeline/run_classic_word_segmenter.py {env:NO_COV:--cov=ckipnlp.pipeline --cov=ckipnlp.driver} {posargs}
8484
pytest {toxinidir}/script/pipeline/run_classic_word_segmenter_pos_tagger.py {env:NO_COV:--cov=ckipnlp.pipeline --cov=ckipnlp.driver} {posargs}
85-
pytest {toxinidir}/script/pipeline/run_classic_constituency_parser.py {env:NO_COV:--cov=ckipnlp.pipeline --cov=ckipnlp.driver} {posargs}
85+
pytest {toxinidir}/script/pipeline/run_classic_con_parser.py {env:NO_COV:--cov=ckipnlp.pipeline --cov=ckipnlp.driver} {posargs}

0 commit comments

Comments
 (0)