PHP Класс Google\Cloud\NaturalLanguage\Annotation
This class is created internally by
{@see \Google\Cloud\NaturalLanguage\NaturalLanguageClient} and is used to
represent various document analyzation results. It should not be instantiated
externally.
Annotations are returned by
{@see \Google\Cloud\NaturalLanguage\NaturalLanguageClient::analyzeEntities()},
{@see \Google\Cloud\NaturalLanguage\NaturalLanguageClient::analyzeSentiment()},
{@see \Google\Cloud\NaturalLanguage\NaturalLanguageClient::analyzeSyntax()} and
{@see \Google\Cloud\NaturalLanguage\NaturalLanguageClient::annotateText()}.
Показать файл
Открыть проект
Открытые методы
Приватные методы
Описание методов
__construct()
публичный Метод
entitiesByType()
публичный Метод
Example:
$entities = $annotation->entitiesByType('PERSON');
foreach ($entities as $entity) {
echo $entity['name'];
}
Example:
$info = $annotation->info();
sentiment()
публичный Метод
Example:
$sentiment = $annotation->sentiment();
if ($sentiment['score'] > 0) {
echo 'This is a positive message.';
}
tokensByLabel()
публичный Метод
Example:
$tokens = $annotation->tokensByLabel('P');
foreach ($tokens as $token) {
echo $token['lemma'];
}
tokensByTag()
публичный Метод
Example:
$tokens = $annotation->tokensByTag('NOUN');
foreach ($tokens as $token) {
echo $token['lemma'];
}