|
| 1 | +# 自动文本摘要Demo |
| 2 | + |
| 3 | +## Demo目的 |
| 4 | + |
| 5 | +通过该例子,希望用户可以创建项目的同时,将所需依赖打包上传。 |
| 6 | + |
| 7 | +## 提前准备 |
| 8 | + |
| 9 | +* 需要电脑安装Node.js,NPM等必要基础软件 |
| 10 | + |
| 11 | +* 需要电脑安装Serverless Framework,[可以点击此处获取安装方法](https://github.com/serverless-tencent/serverless-tencent-scf/blob/master/docs/zh/%E5%BF%AB%E9%80%9F%E5%AE%89%E8%A3%85.md) |
| 12 | + |
| 13 | +* 配置账号信息,[可以点击此处获取配置方法](https://github.com/serverless-tencent/serverless-tencent-scf/blob/master/docs/zh/%E9%85%8D%E7%BD%AE%E8%B4%A6%E5%8F%B7.md) |
| 14 | + |
| 15 | +## 使用方法 |
| 16 | + |
| 17 | +* 下载本demo到本地 |
| 18 | + |
| 19 | +* 进入到Demo目录 |
| 20 | + |
| 21 | +* 执行指令`npm install`安装必要的依赖 |
| 22 | + |
| 23 | +* 执行命令`pip install -t . jieba snownlp`安装函数运行时所需的依赖 |
| 24 | + |
| 25 | +* 执行`serverless deploy`进行部署,部署成功可以看到以下信息: |
| 26 | + |
| 27 | +```text |
| 28 | +Serverless: Packaging service... |
| 29 | +Serverless: Excluding development dependencies... |
| 30 | +Serverless: Uploading service package to cos[sls-cloudfunction-ap-guangzhou]. textsummarization-dev-YbdGk3-2019-11-05-23-50-43.zip |
| 31 | +Serverless: Uploaded package successful /Users/dfounderliu/Desktop/SeerverlessPluginDemo/TextSummarization/.serverless/textsummarization.zip |
| 32 | +Serverless: Creating function textsummarization-dev-text_summarization |
| 33 | +Serverless: Created function textsummarization-dev-text_summarization |
| 34 | +Serverless: Setting tags for function textsummarization-dev-text_summarization |
| 35 | +Serverless: Creating trigger for function textsummarization-dev-text_summarization |
| 36 | +Serverless: Deployed function textsummarization-dev-text_summarization successful |
| 37 | +Serverless: Service Information |
| 38 | +service: textsummarization |
| 39 | +stage: dev |
| 40 | +region: ap-guangzhou |
| 41 | +stack: textsummarization-dev |
| 42 | +resources: 1 |
| 43 | +functions: text_summarization: textsummarization-dev-text_summarization |
| 44 | +
|
| 45 | +``` |
| 46 | + |
| 47 | +* 完成之后,可以通过invoke实现远程调试`serverless invoke -f text_summarization --path test.json`: |
| 48 | +```text |
| 49 | +Serverless: |
| 50 | +
|
| 51 | +{"keywords": ["\u51fd\u6570", "\u817e\u8baf", "\u8fd0\u884c", "\u81ea\u5b9a\u4e49", "COS"], "summary": ["\u60a8\u53ea\u9700\u7f16\u5199\u7b80\u5355\u7684\u3001\u76ee\u7684\u5355\u4e00\u7684\u4e91\u51fd\u6570\u5373\u53ef\u5c06\u5b83\u4e0e\u60a8\u7684\u817e\u8baf\u4e91\u57fa\u7840\u8bbe\u65bd\u53ca\u5176\u4ed6\u4e91\u670d\u52a1\u4ea7\u751f\u7684\u4e8b\u4ef6\u5173\u8054", "\u4e91\u51fd\u6570\u5728\u6267\u884c\u65f6\u5c06\u6839\u636e\u8bf7\u6c42\u8d1f\u8f7d\u6269\u7f29\u5bb9", "\u817e\u8baf\u4e91\u4e91\u51fd\u6570\u662f\u817e\u8baf\u4e91\u63d0\u4f9b\u7684 Serverless \u6267\u884c\u73af\u5883", "\u5728 COS Bucket \u4e0a\u4f20\u65f6\u3001\u5220\u9664\u6587\u4ef6\u65f6\u8fd0\u884c\u4e91\u51fd\u6570\u3001\u5e94\u7528\u7a0b\u5e8f\u901a\u8fc7 SDK \u8c03\u7528\u65f6\u8fd0\u884c\u4e91\u51fd\u6570", "\u53ea\u9700\u4e3a\u8fd0\u884c\u4e2d\u7684\u4e91\u51fd\u6570\u4ed8\u8d39"]} |
| 52 | +
|
| 53 | +---------- |
| 54 | +Log: |
| 55 | +START RequestId: 69ff3f4a-ffe4-11e9-a60a-525400cdceed |
| 56 | +Event RequestId: 69ff3f4a-ffe4-11e9-a60a-525400cdceed |
| 57 | +Building prefix dict from the default dictionary ... |
| 58 | +Building prefix dict from the default dictionary ... |
| 59 | +Dumping model to file cache /tmp/jieba.cache |
| 60 | +Dumping model to file cache /tmp/jieba.cache |
| 61 | +Loading model cost 1.092 seconds. |
| 62 | +Loading model cost 1.092 seconds. |
| 63 | +Prefix dict has been built succesfully. |
| 64 | +Prefix dict has been built succesfully. |
| 65 | +
|
| 66 | +END RequestId: 69ff3f4a-ffe4-11e9-a60a-525400cdceed |
| 67 | +Report RequestId: 69ff3f4a-ffe4-11e9-a60a-525400cdceed Duration:1237.17ms Memory:1024MB MaxMemoryUsed:658.383MB |
| 68 | +
|
| 69 | +``` |
0 commit comments