Skip to content

Commit

Permalink
Introduce classify text feature (#717)
Browse files Browse the repository at this point in the history
* Introduce classify text feature

* correct annotation

* update v1 service definition, remove v1beta2

* update links
  • Loading branch information
dwsupplee authored Nov 7, 2017
1 parent 92c57bf commit 768b786
Show file tree
Hide file tree
Showing 11 changed files with 1,211 additions and 886 deletions.
34 changes: 25 additions & 9 deletions src/Language/Annotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* }
* ```
*
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta1/Sentence Sentence type documentation
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Sentence Sentence type documentation
*
* @return array|null
* }
Expand All @@ -67,7 +67,7 @@
* }
* ```
*
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta1/Token Token type documentation
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Token Token type documentation
*
* @return array|null
* }
Expand All @@ -81,7 +81,23 @@
* }
* ```
*
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta1/Entity Entity type documentation
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Entity Entity type documentation
*
* @return array|null
* }
* @method categories() {
* Returns an array of categories representing the input document.
*
* Example:
* ```
* foreach ($annotation->categories() as $category) {
* echo $category['name'];
* }
* ```
*
* @codingStandardsIgnoreStart
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta2/ClassificationCategory Classification category documentation
* @codingStandardsIgnoreEnd
*
* @return array|null
* }
Expand All @@ -93,7 +109,7 @@
* echo $annotation->language();
* ```
*
* @return string
* @return string|null
* }
*/
class Annotation
Expand Down Expand Up @@ -124,7 +140,7 @@ public function __construct(array $info = [])
* ```
*
* @codingStandardsIgnoreStart
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta1/documents/annotateText#response-body Annotate Text documentation
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/annotateText#response-body Annotate Text documentation
* @codingStandardsIgnoreEnd
*
* @return array
Expand All @@ -146,7 +162,7 @@ public function info()
* }
* ```
*
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta1/Sentiment Sentiment type documentation
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Sentiment Sentiment type documentation
*
* @return array|null
*/
Expand All @@ -168,7 +184,7 @@ public function sentiment()
* ```
*
* @codingStandardsIgnoreStart
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta1/Token#Tag Token tags documentation
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Token#Tag Token tags documentation
* @codingStandardsIgnoreEnd
*
* @return array|null
Expand All @@ -195,7 +211,7 @@ public function tokensByTag($tag)
* ```
*
* @codingStandardsIgnoreStart
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta1/Token#Label Token labels documentation
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Token#Label Token labels documentation
* @codingStandardsIgnoreEnd
*
* @return array|null
Expand All @@ -222,7 +238,7 @@ public function tokensByLabel($label)
* ```
*
* @codingStandardsIgnoreStart
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1beta1/Entity#Type Entity types documentation
* @see https://cloud.google.com/natural-language/docs/reference/rest/v1/Entity#Type Entity types documentation
* @codingStandardsIgnoreEnd
*
* @return array|null
Expand Down
6 changes: 6 additions & 0 deletions src/Language/Connection/ConnectionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@ public function analyzeSyntax(array $args = []);
* @return array
*/
public function annotateText(array $args = []);

/**
* @param array $args
* @return array
*/
public function classifyText(array $args = []);
}
9 changes: 9 additions & 0 deletions src/Language/Connection/Rest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,13 @@ public function annotateText(array $args = [])
{
return $this->send('documents', 'annotateText', $args);
}

/**
* @param array $args
* @return array
*/
public function classifyText(array $args = [])
{
return $this->send('documents', 'classifyText', $args);
}
}
Loading

0 comments on commit 768b786

Please sign in to comment.