-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsentiment.php
More file actions
24 lines (17 loc) · 765 Bytes
/
sentiment.php
File metadata and controls
24 lines (17 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# Imports the Google Cloud client library
use Google\Cloud\Language\LanguageClient;
# Instantiates a client
$language = new LanguageClient();
# The text to analyze
$text = "Les fauteuils de la salle 7 commencent a sérieusement être très usés et fatigué.
Au prix de la séance, la moindre des choses c'est d'avoir un fauteuil confortable.
Nettoyage entre deux séances complètement oublier aussi,c'est inadmissible.
";
# Detects the sentiment of the text
$annotation = $language->analyzeSentiment($text);
$sentiment = $annotation->sentiment();
echo 'Text: ' . $text . '
Sentiment: ' . $sentiment['score'] . ', ' . $sentiment['magnitude'];