begin_offset设置为-1 Google NATURAL LANGUAGE API(entity_extraction)

时间:2018-09-27 20:58:11

标签: python google-cloud-nl named-entity-extraction google-natural-language

Google Cloud CLOUD NATURAL LANGUAGE API(entity_extraction)对于begin_offset(在nodejs和python上)均返回-1。我是否想念任何参数

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

client = language.LanguageServiceClient()

text = u'Dr. James went to NYU yesterday'
document = types.Document(
    content=text,
    type=enums.Document.Type.PLAIN_TEXT)

results = client.analyze_entities(document=document).entities
print(results[0].mentions[0].text.begin_offset)