From 0d03575616a71191e78e49222dd48a7e070fe498 Mon Sep 17 00:00:00 2001 From: daspecster Date: Tue, 28 Mar 2017 12:29:36 -0400 Subject: [PATCH 1/2] Fix broken language examples. --- docs/language-usage.rst | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/docs/language-usage.rst b/docs/language-usage.rst index da8de49054e4..a37587b55c4c 100644 --- a/docs/language-usage.rst +++ b/docs/language-usage.rst @@ -41,8 +41,9 @@ UTF-8. To over-ride these values: .. code-block:: python - >>> client = language.Client(language='es', - ... encoding=language.Encoding.UTF16) + >>> document = client.document_from_text( + ... text_content, language='es', encoding=language.Encoding.UTF16) + The encoding can be one of :attr:`Encoding.UTF8 `, @@ -99,8 +100,8 @@ over-ridden: ... ... ... """ - >>> document = client.document_from_html(html_content, - ... language='es') + >>> document = language.document_from_html(html_content, + ... language='es') The ``language`` argument can be either ISO-639-1 or BCP-47 language codes; at the time, only English, Spanish, and Japanese `are supported`_. @@ -153,7 +154,7 @@ metadata and other properties. >>> text_content = ("Michelangelo Caravaggio, Italian painter, is " ... "known for 'The Calling of Saint Matthew'.") - >>> document = client.document(text_content) + >>> document = language.document.Document(client, content=text_content) >>> entity_response = document.analyze_entities() >>> for entity in entity_response.entities: ... print('=' * 20) @@ -188,7 +189,7 @@ only supports English text. .. code-block:: python >>> text_content = "Jogging isn't very fun." - >>> document = client.document(text_content) + >>> document = language.document.Document(client, content=text_content) >>> sentiment_response = document.analyze_sentiment() >>> sentiment = sentiment_response.sentiment >>> print(sentiment.score) @@ -229,7 +230,7 @@ the response is :data:`None`. .. code-block:: python >>> text_content = 'The cow jumped over the Moon.' - >>> document = client.document(text_content) + >>> document = language.document.Document(client, content=text_content) >>> annotations = document.annotate_text() >>> # Sentences present if include_syntax=True >>> print(annotations.sentences) From be39b21738f87d3fe62d9ca236529a9ffad1aee0 Mon Sep 17 00:00:00 2001 From: daspecster Date: Tue, 28 Mar 2017 12:57:11 -0400 Subject: [PATCH 2/2] Use client helpers. --- docs/language-usage.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/language-usage.rst b/docs/language-usage.rst index a37587b55c4c..bb443f89054c 100644 --- a/docs/language-usage.rst +++ b/docs/language-usage.rst @@ -100,8 +100,8 @@ over-ridden: ... ... ... """ - >>> document = language.document_from_html(html_content, - ... language='es') + >>> document = client.document_from_html(html_content, + ... language='es') The ``language`` argument can be either ISO-639-1 or BCP-47 language codes; at the time, only English, Spanish, and Japanese `are supported`_. @@ -154,7 +154,7 @@ metadata and other properties. >>> text_content = ("Michelangelo Caravaggio, Italian painter, is " ... "known for 'The Calling of Saint Matthew'.") - >>> document = language.document.Document(client, content=text_content) + >>> document = client.document_from_text(text_content) >>> entity_response = document.analyze_entities() >>> for entity in entity_response.entities: ... print('=' * 20) @@ -189,7 +189,7 @@ only supports English text. .. code-block:: python >>> text_content = "Jogging isn't very fun." - >>> document = language.document.Document(client, content=text_content) + >>> document = client.document_from_text(text_content) >>> sentiment_response = document.analyze_sentiment() >>> sentiment = sentiment_response.sentiment >>> print(sentiment.score) @@ -230,7 +230,7 @@ the response is :data:`None`. .. code-block:: python >>> text_content = 'The cow jumped over the Moon.' - >>> document = language.document.Document(client, content=text_content) + >>> document = client.document_from_text(text_content) >>> annotations = document.annotate_text() >>> # Sentences present if include_syntax=True >>> print(annotations.sentences)