我正在尝试从AWS Lambda函数访问Google Cloud API,但我不知道如何进行身份验证.Google云端文档(https://cloud.google.com/docs/authentication)中的身份验证指南要求我下载凭据JSON文件并使用应用程序默认凭据,但是任何使用过托管函数的人都已经知道了是您不需要管理服务器或运行时环境,因此Lambda不允许我在运行代码的环境中存储任意文件.
我可以在本地使用Cloud SDK来获取访问令牌,但它会过期,所以我不能在我的函数中使用它作为永久解决方案.
我是否有办法获得一个访问令牌,我可以无限期地在我的代码中使用它来调用Google Cloud API?还有其他解决方案吗?
amazon-web-services google-cloud-platform gcloud aws-lambda google-cloud-nl
我正在使用Google Natural Language API为带有情绪分析的项目标记文本.我想将我的NL结果存储为JSON.如果向Google发出直接HTTP请求,则会返回JSON响应.
但是,当使用提供的Python库时,将返回一个对象,并且该对象不是直接JSON可序列化的.
以下是我的代码示例:
import os
import sys
import oauth2client.client
from google.cloud.gapic.language.v1beta2 import enums, language_service_client
from google.cloud.proto.language.v1beta2 import language_service_pb2
class LanguageReader:
# class that parses, stores and reports language data from text
def __init__(self, content=None):
try:
# attempts to autheticate credentials from env variable
oauth2client.client.GoogleCredentials.get_application_default()
except oauth2client.client.ApplicationDefaultCredentialsError:
print("=== ERROR: Google credentials could not be authenticated! ===")
print("Current enviroment variable for this process is: {}".format(os.environ['GOOGLE_APPLICATION_CREDENTIALS']))
print("Run:")
print(" $ export GOOGLE_APPLICATION_CREDENTIALS=/YOUR_PATH_HERE/YOUR_JSON_KEY_HERE.json")
print("to set the authentication credentials manually")
sys.exit()
self.language_client = …Run Code Online (Sandbox Code Playgroud) python serialization json google-cloud-platform google-cloud-nl
截至 11 月 20 日星期一,对于使用 PHP SDK 向注释 API 发出的请求,我们收到以下错误错误,现在允许的最小令牌数量似乎是 20。以前允许提交任意数量的单词。测试控制台仍将接受至少 1 个单词https://cloud.google.com/natural-language/
任何人都可以确认此更改是否是永久性的,如果是的话,现在的最少字数为 20 个字?这给我们带来了一个重大问题,我找不到有关此更改的正式公告。
提前致谢...
{
"error": {
"code": 400,
"message": "Invalid text content: too few tokens (words) to process.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "document",
"description": "Invalid text content: too few tokens (words) to process."
}
]
}
]
}
Run Code Online (Sandbox Code Playgroud) 我正在使用 Google Cloud NL API 来分析一些描述的情绪。对于某些行,错误InvalidArgument: 400 The language vi is not supported for document_sentiment analysis.不断弹出,我想围绕它建立一种方法,而不是拼命地试图找到发生这种情况的原因并删除负责任的行。不幸的是,我对 Python 比较陌生,不知道如何正确地做到这一点。
我的代码如下:
description_list = []
sentimentscore_list=[]
magnitude_list=[]
# Create a Language client
language_client = google.cloud.language.LanguageServiceClient()
for i in range(len(description)): # use the translated description if the original description is not in English
if description_trans[i] == '':
descr = description[i]
else:
descr = description_trans[i]
document = google.cloud.language.types.Document(
content=descr,
type=google.cloud.language.enums.Document.Type.PLAIN_TEXT)
# Use Language to detect the sentiment of the text.
response = language_client.analyze_sentiment(document=document) …Run Code Online (Sandbox Code Playgroud) 我希望Google NLP引擎能够识别自定义实体.我有一家名为Hint的公司,我希望它将其标记为一个组织."我喜欢提示"或"我喜欢提示"不会将提示标记为组织.它将提示标记为"其他"实体类型.
是否有一些关键词要提供给谷歌NLP,所以我可以与它交谈.例如,我可以预先处理我的文本,例如
我喜欢%CUSTOM_ENTITY%
我看到SyntaxNet与Parsey McParseface一起发布,然后在Google Cloud Natural Language API出来后不久,它有一些类似的功能,但我在Cloud Natural Language API文档中没有看到任何提及SyntaxNet的内容.
SyntaxNet和Google-Cloud-NL都进行语法分析.有区别吗?我可以使用Cloud-NL而不必设置自己的tensor-flow和SyntaxNet吗?
如何利用Google Cloud Natural Language API对Google表格中的文字进行情感分析?
是否有可用的集成或是否有适当的方法来集成他们的REST API?