# NLP文本摘要网页demo
#### **介绍**
本作业来自在国科大进行教授自然语言处理的清华教授刘洋老师所布置,由成员蒋茂苇、姜文康共同完成。 :two_men_holding_hands:
#### **软件架构**
文本摘要模型初步来自huggingface的transformers,通过API调用sshleifer/distilbart-cnn-12-6模型,[本模型开源地址(http://huggingface.co/sshleifer/distilbart-cnn-12-6),本项目模型推理代码使用Python独立完成。除了在本地IDE环境运行Python文件完成模型推理外,还可以通过模型部署(网页端实现在线模型推理),模型部署实现方式,使用html5+js+css/bootstrap框架完成搭建前端界面,使用Python-Flask框架完成后端服务,通过Python-Flask进行调用推理代码,与加载渲染前端界面,使得模型推理与用户网页衔接起来。
- ![项目框架](https://images.gitee.com/uploads/images/2021/1024/092855_a22a4582_5230895.png "屏幕截图.png")
- 文件介绍:Flask 的模板文件默认放在 “templates” 文件夹下, 静态资源文件放在 “static” 目录下。
- ![Templates文件夹](https://images.gitee.com/uploads/images/2021/1024/093525_94ef6afd_5230895.png "屏幕截图.png")
- templates文件夹放置Html文件
- ![Static文件夹](https://images.gitee.com/uploads/images/2021/1024/094556_3d5d20b2_5230895.png "屏幕截图.png")
- static文件夹(配置静态资源文件夹,里面一般配置网页所需的js/css文件)
- **核心部分:** nlpfc.py是我们实现模型推理的核心函数,如下图所示。
- ![nlpfc.py](https://images.gitee.com/uploads/images/2021/1024/094818_e632b9b9_5230895.png "屏幕截图.png")
- **举个例子**
- **【本项目文本摘要的Input】**
```
The tower is 324 metres (1,063 ft) tall, about the same height
as an 81-storey building, and the tallest structure in Paris
Its base is square, measuring 125 metres (410 ft) on each side.
During its construction, the Eiffel Tower surpassed the Washington
Monument to become the tallest man-made structure in the world,
a title it held for 41 years until the Chrysler Building in New York City
was finished in 1930. It was the first structure to reach a height of 300 metres.
Due to the addition of a broadcasting aerial at the top of the tower in 1957, it is
now taller than the Chrysler Building by 5.2 metres (17 ft). Excluding transmitters,
the Eiffel Tower is the second tallest free-standing structure in France after the Millau
Viaduct.",
})
```
- **【本项目生产式与抽取式文本摘要的Output】**
```
Generative Output:The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building .
It was the first structure to reach a height of 300 metres . Excluding transmitters,
it is the second tallest free-standing structure in France after the Millau Viaduct .
```
```
Abstractive Output:The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris Its base is square, measuring 125 metres (410 ft) on each side.
```
- flask_sever.py文件是服务端文件,可通过直接在windows系统下的[cmd]终端或者Linux\Macos系统下的[Terminal]终端运行,运行指令[ python flask_sever.py ]
-![flask_sever.py运行结果](https://images.gitee.com/uploads/images/2021/1024/100431_9a8dc6e3_5230895.png "屏幕截图.png")
- 通过flask自动生成的链接【http://127.0.0.1:5000/】,在游览器输入栏复制粘贴该链接,进入用户界面。
- ![输入图片说明](web_page.jpg)
- 通过在文本输入栏里面输入相关英文(中文摘要的版本在近期进行开源),然后点击提交按钮。结果如下:
- ![输入图片说明](output.jpg)![输入图片说明](output.jpg)
#### 安装教程
1. 本项目编写在window10与macos上编写,通过vscodeIDE进行编写,实际运行无效考虑IDE环境,有Python运行环境即可所以本项目也可以部署在服务器。
2. pip install flask,
pip install summa,
然后根据运行提升缺什么包,安装什么包就可以了。
3. 一些参考资料放入 文本摘要.txt 文件中,供给参考
- ![参考资料](https://images.gitee.com/uploads/images/2021/1024/103552_f0324509_5230895.png "屏幕截图.png")
#### 放松时刻
**1GB是一级棒的意思,工资用k来算(1k=1024),1000能多出24块钱**
没有合适的资源?快使用搜索试试~ 我知道了~
NLP文本摘要网页demo
共14个文件
py:3个
md:2个
js:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 200 浏览量
2023-08-30
16:51:09
上传
评论
收藏 276KB ZIP 举报
温馨提示
NLP文本摘要网页demo 安装教程 本项目编写在window10与macos上编写,通过vscodeIDE进行编写,实际运行无效考虑IDE环境,有Python运行环境即可所以本项目也可以部署在服务器。 pip install flask, pip install summa, 然后根据运行提升缺什么包,安装什么包就可以了。 一些参考资料放入 文本摘要.txt 文件中,供给参考
资源推荐
资源详情
资源评论
收起资源包目录
nlp-master.zip (14个子文件)
nlp-master
nlpfc.py 2KB
summarization.py 1KB
web_page.jpg 101KB
LICENSE 9KB
文本摘要.txt 935B
templates
index.html 2KB
output.jpg 193KB
flask_server.py 1KB
README.en.md 931B
static
css
style.css 156B
.keep 0B
snowflakes.min.1.0.0.js 14KB
script.js 184B
README.md 4KB
共 14 条
- 1
资源评论
云哲-吉吉2021
- 粉丝: 3435
- 资源: 1129
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功