我是Wit.ai的新手,并且已经开始在我的代码中实现它。我正在考虑一种比硬编码更简单的方法来从给定的wit.ai应用程序接口输出中提取所有的置信度。
例如(API输出):
{
"_text": "I believe I am a human",
"entities": {
"statement": [
{
"confidence": 0.97691847787856,
"value": "I",
"type": "value"
},
{
"confidence": 0.91728476663947,
"value": "I",
"type": "value"
}
],
"query": [
{
"confidence": 1,
"value": "am",
"type": "value"
}
]
},
"msg_id": "0YKCUvDvHC2gyydiU"
}提前谢谢你。
发布于 2018-08-17 13:31:10
您可以遍历entities以获得confidence。
类似于:
data = {
"_text": "I believe I am a human",
"entities": {
"statement": [
{
"confidence": 0.97691847787856,
"value": "I",
"type": "value"
},
{
"confidence": 0.91728476663947,
"value": "I",
"type": "value"
}
],
"query": [
{
"confidence": 1,
"value": "am",
"type": "value"
}
]
},
"msg_id": "0YKCUvDvHC2gyydiU"
}
confidence = list()
for k , v in data['entities'].iteritems():
for item in v:
confidence.append( (item['value'], item['confidence']))
print confidence这就给我们提供了:
[('I', 0.97691847787856), ('I', 0.91728476663947), ('am', 1)]希望这能有所帮助
https://stackoverflow.com/questions/51870095
复制相似问题