Skip to content

Commit

Permalink
🎨 更新 example
Browse files Browse the repository at this point in the history
  • Loading branch information
AlongWY committed Aug 22, 2022
1 parent 4df6159 commit 2ebe92c
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions python/interface/examples/simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

def legacy():
ltp = LTP("LTP/legacy")
result = ltp.pipeline(
"他叫汤姆去拿外衣。",
result = ltp(
["他叫汤姆去拿外衣。", "树上停着一些小鸟。先飞走了19只,又飞走了15只。两次共飞走了多少只小鸟?"],
tasks=["cws", "pos", "ner"],
)
print(result.cws)
Expand All @@ -17,7 +17,10 @@ def neural():

# 已经分词的文本
result = ltp.pipeline(
[["他", "叫", "汤姆", "去", "拿", "外衣", "。"], ["가을동", "叫", "1993", "年", "的", "Ameri", "·"]],
[
["他", "叫", "汤姆", "去", "拿", "外衣", "。"],
["가을동", "叫", "1993", "年", "的", "Ameri", "·"]
],
# 注意这里移除了 "cws" 任务
tasks=["pos", "ner", "srl", "dep", "sdp"],
)
Expand All @@ -29,7 +32,11 @@ def neural():

# 未分词的文本
result = ltp.pipeline(
"他叫汤姆去拿外衣。",
[
"他叫汤姆去拿外衣。",
"韓語:한국의 단오",
"树上停着一些小鸟。先飞走了19只,又飞走了15只。两次共飞走了多少只小鸟?"
],
tasks=["cws", "pos", "ner", "srl", "dep", "sdp"],
)
print(result.cws)
Expand All @@ -40,8 +47,11 @@ def neural():
print(result.sdp)

# Batched 未分词的文本
result = ltp.pipeline(
["他叫汤姆去拿外衣。", "韓語:한국의 단오"],
result = ltp(
[
"他叫汤姆去拿外衣。",
"韓語:한국의 단오", "树上停着一些小鸟。先飞走了19只,又飞走了15只。两次共飞走了多少只小鸟?"
],
tasks=["cws", "pos", "ner", "srl", "dep", "sdp"],
)
print(result.cws)
Expand Down

0 comments on commit 2ebe92c

Please sign in to comment.