Skip to content

Commit 850af7d

Browse files
committed
Removed unnecessary dependencies and simplified API response printing
1 parent b1c392c commit 850af7d

File tree

7 files changed

+67
-222
lines changed

7 files changed

+67
-222
lines changed

language/api/composer.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33
"google/cloud-language": "^0.4",
44
"symfony/console": "^3.0",
55
"google/cloud-storage": "^1.0",
6-
"symfony/yaml": "^3.2",
7-
"google/gax": "^0.21.2",
8-
"grpc/grpc": "^v1.1.0",
9-
"google/protobuf": "^v3.3.0",
106
"google/proto-client": "^0.22.0"
117
},
128
"require-dev": {

language/api/composer.lock

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

language/api/src/analyze_entities.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,6 @@ function analyze_entities($text, $projectId = null)
5858
if (array_key_exists('mid', $entity['metadata'])) {
5959
printf('Knowledge Graph MID: %s' . PHP_EOL, $entity['metadata']['mid']);
6060
}
61-
printf('Mentions:' . PHP_EOL);
62-
foreach ($entity['mentions'] as $mention) {
63-
printf(' Begin Offset: %s' . PHP_EOL, $mention['text']['beginOffset']);
64-
printf(' Content: %s' . PHP_EOL, $mention['text']['content']);
65-
printf(' Mention Type: %s' . PHP_EOL, $mention['type']);
66-
printf(PHP_EOL);
67-
}
6861
printf(PHP_EOL);
6962
}
7063
}

language/api/src/analyze_entities_from_file.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ function analyze_entities_from_file($bucketName, $objectName, $projectId = null)
6565
if (array_key_exists('mid', $entity['metadata'])) {
6666
printf('Knowledge Graph MID: %s' . PHP_EOL, $entity['metadata']['mid']);
6767
}
68-
printf('Mentions:' . PHP_EOL);
69-
foreach ($entity['mentions'] as $mention) {
70-
printf(' Begin Offset: %s' . PHP_EOL, $mention['text']['beginOffset']);
71-
printf(' Content: %s' . PHP_EOL, $mention['text']['content']);
72-
printf(' Mention Type: %s' . PHP_EOL, $mention['type']);
73-
printf(PHP_EOL);
74-
}
7568
printf(PHP_EOL);
7669
}
7770
}

language/api/src/analyze_entity_sentiment.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function analyze_entity_sentiment($text, $projectId = null)
5757

5858
$entity_types = array('UNKNOWN', 'PERSON', 'LOCATION', 'ORGANIZATION', 'EVENT',
5959
'WORK_OF_ART', 'CONSUMER_GOOD', 'OTHER');
60-
$mention_types = array('TYPE_UNKNOWN', 'PROPER', 'COMMON');
6160

6261
// Print out information about each entity
6362
foreach ($entities as $entity) {
@@ -66,15 +65,7 @@ function analyze_entity_sentiment($text, $projectId = null)
6665
printf('Entity Salience: %s' . PHP_EOL, $entity->getSalience());
6766
printf('Entity Magnitude: %s' . PHP_EOL, $entity->getSentiment()->getMagnitude());
6867
printf('Entity Score: %s' . PHP_EOL, $entity->getSentiment()->getScore());
69-
printf('Mentions: ' . PHP_EOL);
70-
foreach ($entity->getMentions() as $mention) {
71-
printf(' Begin Offset: %s' . PHP_EOL, $mention->getText()->getBeginOffset());
72-
printf(' Content: %s' . PHP_EOL, $mention->getText()->getContent());
73-
printf(' Mention Type: %s' . PHP_EOL, $mention_types[$mention->getType()]);
74-
printf(' Mention Magnitude: %s' . PHP_EOL, $mention->getSentiment()->getMagnitude());
75-
printf(' Mention Score: %s' . PHP_EOL, $mention->getSentiment()->getScore());
76-
printf(PHP_EOL);
77-
}
68+
printf(PHP_EOL);
7869
}
7970
}
8071
# [END analyze_entity_sentiment]

language/api/src/analyze_entity_sentiment_from_file.php

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ function analyze_entity_sentiment_from_file($cloud_storage_uri, $projectId = nul
5757

5858
$entity_types = array('UNKNOWN', 'PERSON', 'LOCATION', 'ORGANIZATION', 'EVENT',
5959
'WORK_OF_ART', 'CONSUMER_GOOD', 'OTHER');
60-
$mention_types = array('TYPE_UNKNOWN', 'PROPER', 'COMMON');
6160

6261
// Print out information about each entity
6362
foreach ($entities as $entity) {
@@ -66,15 +65,7 @@ function analyze_entity_sentiment_from_file($cloud_storage_uri, $projectId = nul
6665
printf('Entity Salience: %s' . PHP_EOL, $entity->getSalience());
6766
printf('Entity Magnitude: %s' . PHP_EOL, $entity->getSentiment()->getMagnitude());
6867
printf('Entity Score: %s' . PHP_EOL, $entity->getSentiment()->getScore());
69-
printf('Mentions: ' . PHP_EOL);
70-
foreach ($entity->getMentions() as $mention) {
71-
printf(' Begin Offset: %s' . PHP_EOL, $mention->getText()->getBeginOffset());
72-
printf(' Content: %s' . PHP_EOL, $mention->getText()->getContent());
73-
printf(' Mention Type: %s' . PHP_EOL, $mention_types[$mention->getType()]);
74-
printf(' Mention Magnitude: %s' . PHP_EOL, $mention->getSentiment()->getMagnitude());
75-
printf(' Mention Score: %s' . PHP_EOL, $mention->getSentiment()->getScore());
76-
printf(PHP_EOL);
77-
}
68+
printf(PHP_EOL);
7869
}
7970
}
8071
# [END analyze_entity_sentiment_from_file]

0 commit comments

Comments
 (0)