标签: google-natural-language

Google NLP api给出“无法找到TLS ALPN提供程序”;没有可用的netty-tcnative,Conscrypt或Jetty NPN / ALPN

我正在尝试使用Google自然语言处理API。我使用Maven添加库并添加GOOGLE_APPLICATION_CREDENTIALSas环境变量,该环境变量具有包含我的服务帐户密钥的JSON文件的路径。

这给了我一个错误; Could not find TLS ALPN provider; no working netty-tcnative, Conscrypt, or Jetty NPN/ALPN available

try (LanguageServiceClient language = LanguageServiceClient.create()) {

            // The text to analyze
            String text = "Hello, world!";
            Document doc = Document.newBuilder()
                    .setContent(text).setType(Type.PLAIN_TEXT).build();

            // Detects the sentiment of the text
            Sentiment sentiment = language.analyzeSentiment(doc).getDocumentSentiment();

            System.out.printf("Text: %s%n", text);
            System.out.printf("Sentiment: %s, %s%n", sentiment.getScore(), sentiment.getMagnitude());
        }catch(Exception e){
            System.out.println("Gevindu Error "+ e.getMessage());
        }
Run Code Online (Sandbox Code Playgroud)

java nlp maven google-natural-language

5
推荐指数
1
解决办法
655
查看次数

从一个例句中的句子列表中找出具有相似相对含义的句子

我希望能够找到具有相同含义的句子.我有一个查询语句,以及数百万个其他句子的长列表.句子是单词,或称为符号的特殊类型的单词,它只是一种象征着被讨论的对象的单词.

例如,我的查询语句是:

示例:将(x)添加到(y)给出(z)

可能存在我的数据库中已存在的句子列表,例如:1.(x)和(y)的总和是(z)2.(x)加(y)等于(z)3.(x)乘以by(y)不等于(z)4.(z)是(x)和(y)的总和

该示例应匹配我的数据库1,2,4中的句子,但不匹配3.此外,句子匹配应该有一些权重.

它不仅仅是数学句子,它可以根据单词的含义与任何其他句子进行比较.我需要一些方法来对句子和许多其他句子进行比较,以找到具有封闭相对含义的句子.即基于其含义的句子之间的映射.

谢谢!(标签是语言设计,因为我无法创建任何新标签)

nlp google-natural-language natural-language-processing

4
推荐指数
1
解决办法
4474
查看次数

导入错误:无法在 Google Cloud Language API 中导入名称语言

我正在尝试使用 Google Natural Language API 中的此示例代码来获取情绪分数。但是,每次运行代码时,都会收到“ImportError:无法导入名称语言”。第一行出错。

我已经 pip 安装了该库,尝试卸载并重新安装,在控制台上创建凭据(显示 API 已启用)并查看本教程并完成了答案中的这些步骤:Google 情绪分析 - 导入错误:无法导入名称语言。它没有帮助。还有什么我可以尝试的吗?

from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types

client = language.LanguageServiceClient()

text = u'Hello, world!'
document = types.Document(
    content=text,
    type=enums.Document.Type.PLAIN_TEXT)

sentiment = client.analyze_sentiment(document=document).document_sentiment

print('Text: {}'.format(text))
print('Sentiment: {}, {}'.format(sentiment.score, sentiment.magnitude))
Run Code Online (Sandbox Code Playgroud)

我还使用正确的路径将其粘贴到我的终端中。

export GOOGLE_APPLICATION_CREDENTIALS="/....(my path)/service_key.json"
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪:

Traceback (most recent call last):
  File "lang.py", line 3, in <module>
    from google.cloud import language
  File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/cloud/language.py", line 17, in <module>
    from google.cloud.language_v1 import LanguageServiceClient
  File …
Run Code Online (Sandbox Code Playgroud)

python google-api google-cloud-platform google-cloud-functions google-natural-language

4
推荐指数
2
解决办法
9401
查看次数

如何准备 CSV 文件以从 GCP 中提取 AutoML 实体?

我已经创建了 google 指定的 Jsonl 文件和格式。我将文件上传到云存储。

我准备了一个 CSV 文件,第一列有 Jsonl 文件的路径(gs://*example/file.jsonl),第二列有“TRAIN”或“VALIDATE”或“TEST”。

我收到一条错误消息“找不到引用的文件:请求中的 TRAIN”。

如何准备 CSV 文件?

google-cloud-storage google-cloud-platform google-natural-language google-cloud-automl

2
推荐指数
1
解决办法
3540
查看次数