Tags
Semantic tags are ranked entities, keywords or concepts relevant for the article.
See the Tag object reference page for more information.
Sample call
You can easily try it yourself:
- cURL
- Python SDK
- plain Python
curl -X POST https://api.geneea.com/v3/analysis \
-H 'Authorization: user_key <YOUR USER KEY>' \
-H 'Content-Type: application/json' \
-d '{
"id": "1",
"text": "The trip to London was great. Only the food was weird. Especially the pizza was terrible.",
"analyses": ["tags"],
"domain": "voc-hospitality"
}'
## On Windows, use \" instead of " and " instead of '
from geneeanlpclient import g3
requestBuilder = g3.Request.Builder(analyses=[g3.AnalysisType.TAGS])
with g3.Client.create(userKey=<YOUR USER KEY>) as analyzer:
result = analyzer.analyze(requestBuilder.build(
id=str(1),
text='The trip to London was great. Only the food was weird. Especially the pizza was terrible.'
))
for t in result.tags:
print(f'{t.stdForm}, gkbId: {t.gkbId}, type: {t.type} relevance: {t.relevance}')
import requests
def callGeneea(input):
url = 'https://api.geneea.com/v3/analysis'
headers = {
'content-type': 'application/json',
'Authorization': 'user_key <your user key>'
}
return requests.post(url, json=input, headers=headers).json()
responseObj = callGeneea({
'id': '1',
'text': 'The trip to London was great. Only the food was weird. Especially the pizza was terrible.',
'analyses': ['tags'],
'domain': 'voc-hospitality'
})
print(responseObj)
You should get the following response:
- cURL
- Python SDK
- plain Python
{
"version": "3.2.1",
"id": "1",
"language": {"detected": "en"},
"tags": [
{"id": "t0", "stdForm": "food & drink > quality", "type": "TOPIC", "relevance": 10.534},
{"id": "t1", "stdForm": "food & drink", "type": "TOPIC", "relevance": 10.422},
{"id": "t2", "gkbId": "HSP-10210", "stdForm": "food", "type": "ENTITIES", "relevance": 6.5},
{"id": "t3", "gkbId": "HSP-1091", "stdForm": "pizza", "type": "ENTITIES", "relevance": 6.5},
{"id": "t4", "stdForm": "food: weird", "type": "RELATIONS", "relevance": 3.0},
{"id": "t5", "stdForm": "pizza: terrible", "type": "RELATIONS", "relevance": 3.0},
{"id": "t6", "stdForm": "trip: great", "type": "RELATIONS", "relevance": 3.0}
],
"usedChars": 100
}
food & drink > quality, gkbId: None, type: TOPIC relevance: 10.534
food & drink, gkbId: None, type: TOPIC relevance: 10.422
food, gkbId: HSP-10210, type: ENTITIES relevance: 6.5
pizza, gkbId: HSP-1091, type: ENTITIES relevance: 6.5
food: weird, gkbId: None, type: RELATIONS relevance: 3.0
pizza: terrible, gkbId: None, type: RELATIONS relevance: 3.0
trip: great, gkbId: None, type: RELATIONS relevance: 3.0
{
"version": "3.2.1",
"id": "1",
"language": {"detected": "en"},
"tags": [
{"id": "t0", "stdForm": "food & drink > quality", "type": "TOPIC", "relevance": 10.534},
{"id": "t1", "stdForm": "food & drink", "type": "TOPIC", "relevance": 10.422},
{"id": "t2", "gkbId": "HSP-10210", "stdForm": "food", "type": "ENTITIES", "relevance": 6.5},
{"id": "t3", "gkbId": "HSP-1091", "stdForm": "pizza", "type": "ENTITIES", "relevance": 6.5},
{"id": "t4", "stdForm": "food: weird", "type": "RELATIONS", "relevance": 3.0},
{"id": "t5", "stdForm": "pizza: terrible", "type": "RELATIONS", "relevance": 3.0},
{"id": "t6", "stdForm": "trip: great", "type": "RELATIONS", "relevance": 3.0}
],
"usedChars": 100
}
You can use "returnMentions": "true"
to return the tag mentions.