是的,它确实。
不确定您使用的是什么语言,但下面是使用客户端库的 python 示例:
from google.cloud import language
client = language.Client()
# document of type PLAIN_TEXT
text = "hello"
document_text = client.document_from_text(text)
syntax_text = document_text.analyze_syntax()
print("\n\ndocument of type PLAIN_TEXE:")
for token in syntax_text.tokens:
print(token.__dict__)
# document of type HTML
html = "<p>hello</p>"
document_html = client.document_from_html(html)
syntax_html = document_html.analyze_syntax()
print("\n\ndocument of type HTML:")
for token in syntax_html.tokens:
print(token.__dict__)
# document of type PLAIN_TEXT but should be HTML
document_mismatch = client.document_from_text(html)
syntax_mismatch = document_mismatch.analyze_syntax()
print("\n\ndocument of type PLAIN_TEXT but with HTML content:")
for token in syntax_mismatch.tokens:
print(token.__dict__)
这对我有用,因为 html 标签<p>
并</p>
没有作为自然语言处理。
如果您完成此页面上的设置步骤,您可以快速尝试使用gcloud
命令行工具:
gcloud beta ml language analyze-syntax --content="<p>hello</p>" --content-type="HTML"