PHP Class 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()}.
Datei anzeigen
Open project: GoogleCloudPlatform/gcloud-php
Public Methods
Private Methods
Method Details
__construct()
public method
entitiesByType()
public method
Example:
$entities = $annotation->entitiesByType('PERSON');
foreach ($entities as $entity) {
echo $entity['name'];
}
Example:
$info = $annotation->info();
sentiment()
public method
Example:
$sentiment = $annotation->sentiment();
if ($sentiment['score'] > 0) {
echo 'This is a positive message.';
}
tokensByLabel()
public method
Example:
$tokens = $annotation->tokensByLabel('P');
foreach ($tokens as $token) {
echo $token['lemma'];
}
tokensByTag()
public method
Example:
$tokens = $annotation->tokensByTag('NOUN');
foreach ($tokens as $token) {
echo $token['lemma'];
}