File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff line change 14
14
$ application ->add (new AnalyzeSentimentCommand ());
15
15
$ application ->add (new AnalyzeSyntaxCommand ());
16
16
$ application ->run ();
17
-
Original file line number Diff line number Diff line change 19
19
20
20
use Google \Cloud \NaturalLanguage \Annotation ;
21
21
22
- function print_annotation (Annotation $ annotation ) {
22
+ function print_annotation (Annotation $ annotation )
23
+ {
23
24
$ info = $ annotation ->info ();
24
25
if (isset ($ info ['language ' ])) {
25
26
print "language: " . $ info ['language ' ] . "\n" ;
26
27
}
27
28
28
- if (isset ($ info ['documentSentiment ' ]))
29
- {
29
+ if (isset ($ info ['documentSentiment ' ])) {
30
30
$ magnitude = $ info ['documentSentiment ' ]['magnitude ' ];
31
31
$ polarity = $ info ['documentSentiment ' ]['polarity ' ];
32
- if ($ polarity < 0 )
32
+ if ($ polarity < 0 ) {
33
33
$ magnitude = -$ magnitude ;
34
+ }
34
35
print "sentiment: " . $ magnitude . "\n" ;
35
36
}
36
37
37
- if (isset ($ info ['sentences ' ]))
38
- {
38
+ if (isset ($ info ['sentences ' ])) {
39
39
print "sentences: \n" ;
40
40
foreach ($ info ['sentences ' ] as $ sentence ) {
41
41
print " " . $ sentence ['text ' ]['beginOffset ' ] . ": " .
42
42
$ sentence ['text ' ]['content ' ] . "\n" ;
43
43
}
44
44
}
45
45
46
- if (isset ($ info ['entities ' ]))
47
- {
46
+ if (isset ($ info ['entities ' ])) {
48
47
print "entities: \n" ;
49
48
foreach ($ info ['entities ' ] as $ entity ) {
50
49
print " " . $ entity ['name ' ];
51
- if (isset ($ entity ['metadata ' ]['wikipedia_url ' ]))
50
+ if (isset ($ entity ['metadata ' ]['wikipedia_url ' ])) {
52
51
print ": " . $ entity ['metadata ' ]['wikipedia_url ' ];
52
+ }
53
53
print "\n" ;
54
54
}
55
55
}
56
- }
56
+ }
You can’t perform that action at this time.
0 commit comments