gpt4 book ai didi

watson-conversation - 我的城市位置在 IBM Watson api NLU 中不可用

转载 作者:行者123 更新时间:2023-12-01 22:29:30 26 4
gpt4 key购买 nike

当我使用 Watson api NLU 向我位于印度城市发送文本时。我得到空实体。它应该带有数据实体位置。那么我如何在 watson NLU 中解决这个问题。

发送的句子是:

mba college in bhubaneswar

布巴内斯瓦尔是城市

最佳答案

因此,根据您的评论句子:

"mba college in bhubaneswar"

将其放入 NLU 中,实体检测失败,并显示:

Error: unsupported text language: unknown, Code: 400

第一个问题是,由于未指定语言,因此它会尝试猜测语言。但没有足够的地方可以猜测(即使这对你来说是显而易见的)。

第二个问题是,即使您指定了语言,它也无法完全识别。这是因为它不是一个真正的句子,而是一个片段。

NLU 不仅仅进行关键字查找,它还尝试理解词性 (POS),并据此确定该词的含义。

所以如果我给它一个真正的句子,它就会起作用。例如:

I go to an MBA college in Bhubaneswar

我使用了这个示例代码:

import json
from watson_developer_cloud import NaturalLanguageUnderstandingV1
from watson_developer_cloud.natural_language_understanding_v1 import Features, EntitiesOptions, RelationsOptions

ctx = {
"url": "https://gateway.watsonplatform.net/natural-language-understanding/api",
"username": "USERNAME",
"password": "PASSWORD"
}
version = '2017-02-27'

text = "I go to an MBA college in Bhubaneswar"
#text = "mba college in bhubaneswar"

nlu = NaturalLanguageUnderstandingV1(version=version, username=ctx.get('username'),password=ctx.get('password'))
entities = EntitiesOptions()
relations = RelationsOptions()

response = nlu.analyze(text=text, features=Features(entities=entities,relations=relations),language='en')

print(json.dumps(response, indent=2))

这给了我以下结果。

{
"usage": {
"text_units": 1,
"text_characters": 37,
"features": 2
},
"relations": [
{
"type": "basedIn",
"sentence": "I go to an MBA college in Bhubaneswar",
"score": 0.669215,
"arguments": [
{
"text": "college",
"location": [
15,
22
],
"entities": [
{
"type": "Organization",
"text": "college"
}
]
},
{
"text": "Bhubaneswar",
"location": [
26,
37
],
"entities": [
{
"type": "GeopoliticalEntity",
"text": "Bhubaneswar"
}
]
}
]
}
],
"language": "en",
"entities": [
{
"type": "Location",
"text": "Bhubaneswar",
"relevance": 0.33,
"disambiguation": {
"subtype": [
"IndianCity",
"City"
],
"name": "Bhubaneswar",
"dbpedia_resource": "http://dbpedia.org/resource/Bhubaneswar"
},
"count": 1
}
]
}

如果您只想扫描片段,那么 @ReeceMed solution将为您解决。

关于watson-conversation - 我的城市位置在 IBM Watson api NLU 中不可用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47787895/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com