自然语言理解(NLU)没有回归的概念
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了自然语言理解(NLU)没有回归的概念相关的知识,希望对你有一定的参考价值。
我使用IBM Watson Natural Language Understanding(NLU)API提取Concepts。对于大多数文本,它能够提取至少1或2个概念,但在某些简单情况下,它不返回概念。
from watson_developer_cloud import NaturalLanguageUnderstandingV1
from watson_developer_cloud.natural_language_understanding_v1 import Features, CategoriesOptions, ConceptsOptions, RelationsOptions
natural_language_understanding = NaturalLanguageUnderstandingV1( version='2018-11-16', iam_apikey='API-KEY', url='https://gateway.watsonplatform.net/natural-language-understanding/api')
post ="No job Never had any romantic experiences I just have no ability / infrastructure to get through life It's killing me I don't want to be part of this world because I can't fit in, can't compete, can't enjoy Why does it have to be so uncomfortable? I feel so sad on the inside Another night I wonder how it will ever change, will it require my effort completely? I DON'T KNOW WHAT TO FUCKING DO"
response = natural_language_understanding.analyze(
text=post, features=Features(
concepts=ConceptsOptions(limit=10))).get_result()
响应变量中返回的结果是
{'concepts': [], 'language': 'en', 'usage': {'features': 1, 'text_characters': 393, 'text_units': 1}}
它是我不知道的API的已知限制,还是我调用API的方式有问题?
答案
对于相同的文本,我能够获得以下作为具有相同限制和相同版本日期的API的概念的输出。
"concepts": [
{
"text": "Existentialism",
"relevance": 0.988784,
"dbpedia_resource": "http://dbpedia.org/resource/Existentialism"
},
{
"text": "The Brothers Karamazov",
"relevance": 0.856152,
"dbpedia_resource": "http://dbpedia.org/resource/The_Brothers_Karamazov"
},
{
"text": "Fyodor Dostoyevsky",
"relevance": 0.83996,
"dbpedia_resource": "http://dbpedia.org/resource/Fyodor_Dostoyevsky"
},
{
"text": "Human condition",
"relevance": 0.716108,
"dbpedia_resource": "http://dbpedia.org/resource/Human_condition"
},
{
"text": "Psychology",
"relevance": 0.687781,
"dbpedia_resource": "http://dbpedia.org/resource/Psychology"
},
{
"text": "Philosophy of life",
"relevance": 0.675628,
"dbpedia_resource": "http://dbpedia.org/resource/Philosophy_of_life"
},
{
"text": "Meaning of life",
"relevance": 0.65926,
"dbpedia_resource": "http://dbpedia.org/resource/Meaning_of_life"
},
{
"text": "Human nature",
"relevance": 0.652501,
"dbpedia_resource": "http://dbpedia.org/resource/Human_nature"
}
]
你能为任何着名的地方传递一些维基百科文本,以验证你是否在输出中得到了返回的概念。另外,请确保在向API发送信息时不要设置任何默认语言。如果文本在大多数情况下超过100个字符,NLU会自动检测语言。例如,如果您将语言设置为西班牙语(es),它可能会调用西班牙语概念引擎,您可能会得到很少甚至没有结果。
以上是关于自然语言理解(NLU)没有回归的概念的主要内容,如果未能解决你的问题,请参考以下文章
自然语言处理NLP自然语言理解NLU自然语言生成NLG任务家族