Skip to content

Commit

Permalink
🎨 fix quickstart
Browse files Browse the repository at this point in the history
  • Loading branch information
AlongWY committed Oct 28, 2022
1 parent 89e42dd commit b7fb882
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/interface/docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@
分句
--------------------------

使用LTP分句只需要调用ltp.sent_split函数
使用LTP分句只需要使用 StnSplit

.. code-block:: python
from ltp import StnSplit
sents = StnSplit().sent_split(["他叫汤姆去拿外衣。", "汤姆生病了。他去了医院。"])
sents = StnSplit().split("汤姆生病了。他去了医院。")
# [
# "汤姆生病了。",
# "他去了医院。"
# ]
sents = StnSplit().batch_split(["他叫汤姆去拿外衣。", "汤姆生病了。他去了医院。"])
# [
# "他叫汤姆去拿外衣。",
Expand Down
19 changes: 19 additions & 0 deletions python/interface/examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
from ltp import LTP


def stn_split():
from ltp import StnSplit
sents = StnSplit().split("汤姆生病了。他去了医院。")
print(sents)
# [
# "汤姆生病了。",
# "他去了医院。"
# ]

sents = StnSplit().batch_split(["他叫汤姆去拿外衣。", "汤姆生病了。他去了医院。"])
print(sents)
# [
# "他叫汤姆去拿外衣。",
# "汤姆生病了。",
# "他去了医院。"
# ]


def legacy():
ltp = LTP("LTP/legacy")
ltp.add_word("汤姆去")
Expand Down Expand Up @@ -48,6 +66,7 @@ def neural():


def main():
stn_split()
legacy()
neural()

Expand Down

0 comments on commit b7fb882

Please sign in to comment.