-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
12,717 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
blank_issues_enabled: false | ||
contact_links: | ||
- name: ⁉️ Need help with HanLP? | ||
- name: ⁉️ 提问求助请上论坛 | ||
url: https://bbs.hankcs.com/ | ||
about: Join our multilingual forum and have a free discussion. | ||
about: 欢迎前往蝴蝶效应论坛求助 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
160 changes: 160 additions & 0 deletions
160
plugins/hanlp_demo/hanlp_demo/zh/abstractive_summarization_restful.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "WfGpInivS0fG" | ||
}, | ||
"source": [ | ||
"<h2 align=\"center\">点击下列图标在线运行HanLP</h2>\n", | ||
"<div align=\"center\">\n", | ||
"\t<a href=\"https://colab.research.google.com/github/hankcs/HanLP/blob/doc-zh/plugins/hanlp_demo/hanlp_demo/zh/absum_restful.ipynb\" target=\"_blank\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>\n", | ||
"\t<a href=\"https://mybinder.org/v2/gh/hankcs/HanLP/doc-zh?filepath=plugins%2Fhanlp_demo%2Fhanlp_demo%2Fzh%2Fabsum_restful.ipynb\" target=\"_blank\"><img src=\"https://mybinder.org/badge_logo.svg\" alt=\"Open In Binder\"/></a>\n", | ||
"</div>\n", | ||
"\n", | ||
"## 安装" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "IYwV-UkNNzFp" | ||
}, | ||
"source": [ | ||
"无论是Windows、Linux还是macOS,HanLP的安装只需一句话搞定:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"id": "1Uf_u7ddMhUt" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"!pip install hanlp_restful -U" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "pp-1KqEOOJ4t" | ||
}, | ||
"source": [ | ||
"## 创建客户端" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "4M7ka0K5OMWU", | ||
"outputId": "d74f0749-0587-454a-d7c9-7418d45ce534" | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"from hanlp_restful import HanLPClient\n", | ||
"HanLP = HanLPClient('https://www.hanlp.com/api', auth=None, language='zh') # auth不填则匿名,zh中文,mul多语种" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "BMW528wGNulM" | ||
}, | ||
"source": [ | ||
"#### 申请秘钥\n", | ||
"由于服务器算力有限,匿名用户每分钟限2次调用。如果你需要更多调用次数,[建议申请免费公益API秘钥auth](https://bbs.hanlp.com/t/hanlp2-1-restful-api/53)。" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "elA_UyssOut_" | ||
}, | ||
"source": [ | ||
"## 生成式自动摘要\n", | ||
"生成式自动摘要(Abstractive Summarization)任务的目标是为文章生成一段简短的概括性摘要。 生成的摘要有可能出现原文中不存在的新短语或新句子,并且整体流畅性较高。\n", | ||
"### 中文\n", | ||
"生成式自动摘要任务的输入为一段文本:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": { | ||
"colab": { | ||
"base_uri": "https://localhost:8080/" | ||
}, | ||
"id": "BqEmDMGGOtk3", | ||
"outputId": "936d439a-e1ff-4308-d2aa-775955558594" | ||
}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"'长江证券:看好大金属品种中的铜铝钢'" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"HanLP.abstractive_summarization('''\n", | ||
"每经AI快讯,2月4日,长江证券研究所金属行业首席分析师王鹤涛表示,2023年海外经济衰退,美债现处于历史高位,\n", | ||
"黄金的趋势是值得关注的;在国内需求修复的过程中,看好大金属品种中的铜铝钢。\n", | ||
"此外,在细分的小品种里,建议关注两条主线,一是新能源,比如锂、钴、镍、稀土,二是专精特新主线。(央视财经)\n", | ||
"''')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": { | ||
"id": "jj1Jk-2sPHYx" | ||
}, | ||
"source": [ | ||
"返回值为一段摘要。" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"### 英文\n", | ||
"按照HanLP一贯的多语种设计,任何语言都支持。由于服务器GPU资源限制,目前英文接口暂未上线。如果你有相应需求,欢迎前往论坛发起请愿。" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"accelerator": "GPU", | ||
"colab": { | ||
"collapsed_sections": [], | ||
"name": "absum_restful.ipynb", | ||
"provenance": [] | ||
}, | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 1 | ||
} |
Oops, something went wrong.