Skip to content

Commit 25ef70a

Browse files
committed
fixes CS, updates composer, prints tokens
1 parent 5220f21 commit 25ef70a

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

language/api/composer.lock

Lines changed: 17 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

language/api/src/functions/print_annotation.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function print_annotation(Annotation $annotation)
2323
{
2424
$info = $annotation->info();
2525
if (isset($info['language'])) {
26-
print "language: " . $info['language'] . "\n";
26+
printf('language: %s' . PHP_EOL, $info['language']);
2727
}
2828

2929
if (isset($info['documentSentiment'])) {
@@ -32,25 +32,35 @@ function print_annotation(Annotation $annotation)
3232
if ($polarity < 0) {
3333
$magnitude = -$magnitude;
3434
}
35-
print "sentiment: " . $magnitude . "\n";
35+
printf('sentiment: %s' . PHP_EOL, $magnitude);
3636
}
3737

3838
if (isset($info['sentences'])) {
39-
print "sentences:\n";
39+
print 'sentences:' . PHP_EOL;
4040
foreach ($info['sentences'] as $sentence) {
41-
print " " . $sentence['text']['beginOffset'] . ": " .
42-
$sentence['text']['content'] . "\n";
41+
printf(' %s: %s' . PHP_EOL,
42+
$sentence['text']['beginOffset'],
43+
$sentence['text']['content']);
44+
}
45+
}
46+
47+
if (isset($info['tokens'])) {
48+
print 'tokens:' . PHP_EOL;
49+
foreach ($info['tokens'] as $token) {
50+
printf(' %s: %s' . PHP_EOL,
51+
$token['lemma'],
52+
$token['partOfSpeech']['tag']);
4353
}
4454
}
4555

4656
if (isset($info['entities'])) {
47-
print "entities:\n";
57+
print 'entities:' . PHP_EOL;
4858
foreach ($info['entities'] as $entity) {
49-
print " " . $entity['name'];
59+
printf(' %s', $entity['name']);
5060
if (isset($entity['metadata']['wikipedia_url'])) {
51-
print ": " . $entity['metadata']['wikipedia_url'];
61+
printf(': %s', $entity['metadata']['wikipedia_url']);
5262
}
53-
print "\n";
63+
print PHP_EOL;
5464
}
5565
}
5666
}

0 commit comments

Comments
 (0)