Google Cloud Natural Language情感分析教程

news/2024/11/25 15:49:15/

安装 Google Cloud SDK

支持的 Python 版本 Python 3(3.5 到 3.9)。

运行 PowerShell 命令:

(New-Object Net.WebClient).DownloadFile("https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe", "$env:Temp\GoogleCloudSDKInstaller.exe")& $env:Temp\GoogleCloudSDKInstaller.exe

安装时,取消选择”Bundled Python”选项

打开Google Cloud SDK Shell

(按照以下步骤输入) port和address改为自己实际代理情况

Welcome to the Google Cloud SDK! Run "gcloud -h" to get the list of available commands.

---

D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/type socks5

Updated property [proxy/type].

D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/address 127.0.0.1

Updated property [proxy/address].

D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud config set proxy/port 1080

Updated property [proxy/port].

D:\Programming\Tools\cloud\google_cloud\cloud_sdk>gcloud init

Welcome! This command will take you through the configuration of gcloud.

Settings from your current configuration [proxyconfig0] are:

core:

  disable_usage_reporting: 'False'

proxy:

  address: 127.0.0.1

  port: '1080'

  type: socks5

Pick configuration to use:

 [1] Re-initialize this configuration [proxyconfig0] with new settings

 [2] Create a new configuration

 [3] Switch to and re-initialize existing configuration: [default]

Please enter your numeric choice:  1

Your current configuration has been set to: [proxyconfig0]

You can skip diagnostics next time by using the following flag:

  gcloud init --skip-diagnostics

Network diagnostic detects and fixes local network connection issues.

Checking network connection...done.

Reachability Check passed.

Network diagnostic passed (1/1 checks passed).

You must log in to continue. Would you like to log in (Y/n)?  y

Your browser has been opened to visit:

    https://accounts.google.com/o/oauth2/auth?redirect_uri=http%3A%2F%2Flocalhost%3A8085%2F&prompt=select_account&response_type=code&client_id=32555940559.apps.googleusercontent.com&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcloud-platform+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcompute+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Faccounts.reauth&access_type=offline

You are logged in as: [dreammax1997@gmail.com].

Pick cloud project to use:

 [1] tonal-run-227315

 [2] Create a new project

Please enter numeric choice or text value (must exactly match list

item):  1

Your current project has been set to: [tonal-run-227315].

Do you want to configure a default Compute Region and Zone? (Y/n)?  y

Which Google Compute Engine zone would you like to use as project

default?

If you do not specify a zone via a command line flag while working

with Compute Engine resources, the default is assumed.

 [1] us-east1-b

 [2] us-east1-c

 [3] us-east1-d

 [4] us-east4-c

Too many options [56]. Enter "list" at prompt to print choices fully.

Please enter numeric choice or text value (must exactly match list

item):  1 (根据实际情况选)

Your project default Compute Engine zone has been set to [us-east1-b].

You can change it by running [gcloud config set compute/zone NAME].

Your project default Compute Engine region has been set to [us-east1].

You can change it by running [gcloud config set compute/region NAME].

Created a default .boto configuration file at [C:\Users\DreamMax\.boto]. See this file and

[https://cloud.google.com/storage/docs/gsutil/commands/config] for more

information about configuring Google Cloud Storage.

Your Google Cloud SDK is configured and ready to use!

* Commands that require authentication will use dreammax1997@gmail.com by default

* Commands will reference project `tonal-run-227315` by default

* Compute Engine commands will use region `us-east1` by default

* Compute Engine commands will use zone `us-east1-b` by default

要谷歌账号绑定信用卡,免费试用12个月,300$赠金。

详细见:Google Cloud_google cloud 永久免费_dufufd的博客-CSDN博客

设置应用默认凭据本地开发环境

在Google Cloud SDK shell里运行

创建凭据文件:gcloud auth application-default login

创建服务帐号密钥并将其提供给 ADC

对于 PowerShell:

$env:GOOGLE_APPLICATION_CREDENTIALS="KEY_PATH"

将 KEY_PATH 替换为包含您的服务帐号密钥的 JSON 文件的路径。

例如:$env:GOOGLE_APPLICATION_CREDENTIALS="C:\Users\username\Downloads\service-account-file.json"

来源:https://cloud.google.com/docs/authentication/provide-credentials-adc?hl=zh-cn#local-dev

配置完应用默认凭据后可以使用情感分析,详细举例流程见:https://cloud.google.com/natural-language/docs/sentiment-tutorial?hl=zh-cn


http://www.ppmy.cn/news/82502.html

相关文章

苹果笔不用原装可以吗?apple pencil二代平替笔推荐

随着网络技术的飞速发展,移动电话、平板电脑、笔记本等移动设备正在逐渐走进人们的生活。就好比如我们现在用的是电容笔。我认为,如果我们可以运用它来学习记笔记,做笔记,或其他一些很简单的事情,我们将不必为一支原装…

理解 Delphi 的类(二) - 初识类的方法

说到"类", 就会提到: 属性、方法、事件 (这是类包含的内容);封装、继承、多态 (这是类的主要用途). 下面定义并调用了了一个过程 MyProc、一个函数 MyFun. unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dial…

Unity3D :运行时 UI 的性能注意事项

推荐:将 NSDT场景编辑器 加入你的3D工具链 3D工具集: NSDT简石数字孪生 运行时 UI 的性能注意事项 本页介绍如何提高运行时的性能用户界面 . 优化数据存储 您可以使用 usageHints 来设置元素在运行时的使用方式,以便相应地优化数据存储。例…

小松鼠踩一踩游戏

文章目录 一、 介绍和知识点九、UnityFacade 门面设计模式二、 声音全局管理器测试音频代码UI全局管理器父类抽象类 BaseManager子类 UIManager 四、 UI按钮的引用父类 BasePanel子类主面板 MainPanel子类 游戏中 GamePanel子类 游戏结果 ResultPanel 角色动画器、控制角色移动…

JAVA常用API - 正则表达式

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 目录 文章目录 前言 一,正则表达式是什么? 二,正则表达式符号 三,常用正则表达式组合 四,正则表达…

由浅入深Netty代码调优

目录 1. 优化1.1 扩展序列化算法 2 参数调优2.1 CONNECT_TIMEOUT_MILLIS2.2 SO_BACKLOG2.3 ulimit -n2.4 TCP_NODELAY2.5 SO_SNDBUF & SO_RCVBUF2.6 ALLOCATOR2.7 RCVBUF_ALLOCATOR 1. 优化 1.1 扩展序列化算法 序列化,反序列化主要用在消息正文的转换上 序列…

Flink有状态计算的状态容错

状态容错 State Fault Tolerance 首先来说一说状态容错。Flink 支持有状态的计算,可以把数据流的结果一直维持在内存(或 disk)中,比如累加一个点击数,如果某一时刻计算程序挂掉了,如何保证下次重启的时候&…

CMake常用命令总结与练习

CMake常用命令总结 前言cmake_minimum_required (VERSION XX):CMake最低版本project (demo):CMake工程名add_executable(main main.c):生成可执行文件aux_source_directory(dir var):指定源文件放入变量set(val src):指定源文件放入变量include_director…