Skip to content

Adding usage doc for Natural Language API. - #2062

Merged
dhermes merged 1 commit into
googleapis:masterfrom
dhermes:language-usage-doc
Aug 23, 2016
Merged

Adding usage doc for Natural Language API.#2062
dhermes merged 1 commit into
googleapis:masterfrom
dhermes:language-usage-doc

Conversation

@dhermes

Copy link
Copy Markdown
Contributor

/cc @omaray are you in the org yet (I can't assign you to this PR)

@googlebotgooglebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 8, 2016
and each method uses a `Document`_ for representing text. To
create a :class:`~gcloud.language.document.Document`,

.. code-block:: python

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@tseaver

Copy link
Copy Markdown
Contributor

A couple of more general questions:

  • Shouldn't this PR (and subsequent implementation PRs) target a natural-language-feature branch?
  • Should we be packaging up the JSON results for the three APIs into objects?

@dhermesdhermes mentioned this pull request Aug 8, 2016
Comment threaddocs/language-usage.rst Outdated
app. You can analyze text uploaded in your request or integrate
with your document storage on Google Cloud Storage.

This is a Beta release of Google Cloud Natural Language API. This

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@dhermes

Copy link
Copy Markdown
ContributorAuthor

@tseaver Can you weigh in here on which response values you think we should wrap?

@elibixby

Copy link
Copy Markdown

@jerjou Can you take a look to make sure we have someone who has used the API a bit to comment on usability.

@tseaver

Copy link
Copy Markdown
Contributor

Can you weigh in here on which response values you think we should wrap?

For analyze_entities, we could return instances of a (putative) Entity class:

forentityindocument.analyze_entities():
build_entity_link(entity.name, entity.type, entity.url)

For analyze_sentiment, we could return a (putative) Sentiment instance:

defby_sentiment(document):
"""Sort key: rank from most negative to most positive."""sentiment=document.analyze_sentiment()
returnsentiment.polarity*sentiment.magnituderanked=sorted(documents, key=by_sentiment)

For annotate_text, (assuming we have flags to disable unwanted features):

only_syntax=document.annotate_text(
include_entities=False, include_sentiment=False)
assertonly_syntax.entitiesisNoneassertonly_syntax.sentimentisNonetree=ParseTree() # imagined class w/ 'add_token' method.forindex, tokeninenumerate(only_syntax.tokens):
edge=token.dependency_edgetree.add_token(
index, token.lemma, token.part_of_speech, edge.head_index, edge.label)

Comment threaddocs/language-usage.rst Outdated
>>> document = client.document(text_content)

By default, the document's language and type are English and
plain text:

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@tseaver

Copy link
Copy Markdown
Contributor

LGTM.

@dhermes

Copy link
Copy Markdown
ContributorAuthor

@jgeewax In the interest of keeping this PR from reaching 15 days of age, I'll merge with @tseaver's LGTM and we can address after the fact as the API develops (it's a small surface area so it won't be overwhelming).

@dhermes
dhermes merged commit 9a6bf7f into googleapis:masterAug 23, 2016
@dhermes
dhermes deleted the language-usage-doc branch August 23, 2016 01:32
.. code-block:: python

>>> client = language.Client(language='es',
... encoding=encoding=language.Encoding.UTF16)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

@dhermesdhermes mentioned this pull request Sep 19, 2016
parthea pushed a commit that referenced this pull request Nov 24, 2025
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Apr 1, 2026
* feat: support pandas.Index as key for DataFrame.__setitem__()
* fix format
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yesThis human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@dhermes@tseaver@elibixby@jgeewax@daspecster@jerjou@googlebot