Skip to content

Commit

Permalink
fixes language styles (this is why we need the check :P)
Browse files Browse the repository at this point in the history
  • Loading branch information
bshaffer committed Dec 18, 2018
1 parent d71cbe1 commit 57d8ff5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 16 deletions.
6 changes: 2 additions & 4 deletions language/src/analyze_all.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ function analyze_all($text, $projectId = null)
printf('Name: %s' . PHP_EOL, $entity->getName());
printf('Type: %s' . PHP_EOL, $entity_types[$entity->getType()]);
printf('Salience: %s' . PHP_EOL, $entity->getSalience());
if($entity->getMetadata()->offsetExists('wikipedia_url')) {
if ($entity->getMetadata()->offsetExists('wikipedia_url')) {
printf('Wikipedia URL: %s' . PHP_EOL, $entity->getMetadata()->offsetGet('wikipedia_url'));
}
if($entity->getMetadata()->offsetExists('mid')) {
if ($entity->getMetadata()->offsetExists('mid')) {
printf('Knowledge Graph MID: %s' . PHP_EOL, $entity->getMetadata()->offsetGet('mid'));
}
printf('Mentions:' . PHP_EOL);
Expand Down Expand Up @@ -138,10 +138,8 @@ function analyze_all($text, $projectId = null)
printf('Token part of speech: %s' . PHP_EOL, $tag_types[$token->getPartOfSpeech()->getTag()]);
printf(PHP_EOL);
}

} finally {
$languageServiceClient->close();
}

}
# [END analyze_all]
5 changes: 2 additions & 3 deletions language/src/analyze_all_from_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ function analyze_all_from_file($gcsUri, $projectId = null)
printf('Name: %s' . PHP_EOL, $entity->getName());
printf('Type: %s' . PHP_EOL, $entity_types[$entity->getType()]);
printf('Salience: %s' . PHP_EOL, $entity->getSalience());
if($entity->getMetadata()->offsetExists('wikipedia_url')) {
if ($entity->getMetadata()->offsetExists('wikipedia_url')) {
printf('Wikipedia URL: %s' . PHP_EOL, $entity->getMetadata()->offsetGet('wikipedia_url'));
}
if($entity->getMetadata()->offsetExists('mid')) {
if ($entity->getMetadata()->offsetExists('mid')) {
printf('Knowledge Graph MID: %s' . PHP_EOL, $entity->getMetadata()->offsetGet('mid'));
}
printf('Mentions:' . PHP_EOL);
Expand Down Expand Up @@ -138,7 +138,6 @@ function analyze_all_from_file($gcsUri, $projectId = null)
printf('Token part of speech: %s' . PHP_EOL, $tag_types[$token->getPartOfSpeech()->getTag()]);
printf(PHP_EOL);
}

} finally {
$languageServiceClient->close();
}
Expand Down
9 changes: 4 additions & 5 deletions language/src/analyze_entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

use Google\Cloud\Language\V1beta2\Document;
use Google\Cloud\Language\V1beta2\LanguageServiceClient;

/**
* Find the entities in text.
* ```
Expand Down Expand Up @@ -62,18 +63,16 @@ function analyze_entities($text, $projectId = null)
printf('Name: %s' . PHP_EOL, $entity->getName());
printf('Type: %s' . PHP_EOL, $entity_types[$entity->getType()]);
printf('Salience: %s' . PHP_EOL, $entity->getSalience());
if($entity->getMetadata()->offsetExists('wikipedia_url')) {
if ($entity->getMetadata()->offsetExists('wikipedia_url')) {
printf('Wikipedia URL: %s' . PHP_EOL, $entity->getMetadata()->offsetGet('wikipedia_url'));
}
if($entity->getMetadata()->offsetExists('mid')) {
if ($entity->getMetadata()->offsetExists('mid')) {
printf('Knowledge Graph MID: %s' . PHP_EOL, $entity->getMetadata()->offsetGet('mid'));
}
printf(PHP_EOL);
}

} finally {
$languageServiceClient->close();
}

}
# [END language_entities_text]
# [END language_entities_text]
7 changes: 3 additions & 4 deletions language/src/analyze_entities_from_file.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,16 @@ function analyze_entities_from_file($gcsUri, $projectId = null)
printf('Name: %s' . PHP_EOL, $entity->getName());
printf('Type: %s' . PHP_EOL, $entity_types[$entity->getType()]);
printf('Salience: %s' . PHP_EOL, $entity->getSalience());
if($entity->getMetadata()->offsetExists('wikipedia_url')) {
if ($entity->getMetadata()->offsetExists('wikipedia_url')) {
printf('Wikipedia URL: %s' . PHP_EOL, $entity->getMetadata()->offsetGet('wikipedia_url'));
}
if($entity->getMetadata()->offsetExists('mid')) {
if ($entity->getMetadata()->offsetExists('mid')) {
printf('Knowledge Graph MID: %s' . PHP_EOL, $entity->getMetadata()->offsetGet('mid'));
}
printf(PHP_EOL);
}

} finally {
$languageServiceClient->close();
}
}
# [END language_entities_gcs]
# [END language_entities_gcs]

0 comments on commit 57d8ff5

Please sign in to comment.