Skip to content

Adding usage doc for Natural Language API.#2062

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

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

Conversation

@dhermes
Copy link
Copy Markdown
Contributor

@dhermes dhermes commented Aug 8, 2016

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

@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Aug 8, 2016
Comment thread docs/language-usage.rst
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

tseaver commented Aug 8, 2016

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?

Comment thread docs/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
Contributor Author

dhermes commented Aug 17, 2016

@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

tseaver commented Aug 18, 2016

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:

for entity in document.analyze_entities():
    build_entity_link(entity.name, entity.type, entity.url)

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

def by_sentiment(document):
    """Sort key:  rank from most negative to most positive."""
    sentiment = document.analyze_sentiment()
    return sentiment.polarity * sentiment.magnitude

ranked = 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)

assert only_syntax.entities is None
assert only_syntax.sentiment is None

tree = ParseTree()  # imagined class w/ 'add_token' method.

for index, token in enumerate(only_syntax.tokens):
    edge = token.dependency_edge
    tree.add_token(
        index, token.lemma, token.part_of_speech, edge.head_index, edge.label)

Comment thread docs/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

tseaver commented Aug 22, 2016

LGTM.

@dhermes
Copy link
Copy Markdown
Contributor Author

dhermes commented Aug 22, 2016

@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 force-pushed the language-usage-doc branch from cdb4adf to d36ad4d Compare August 23, 2016 00:29
@dhermes dhermes merged commit 9a6bf7f into googleapis:master Aug 23, 2016
@dhermes dhermes deleted the language-usage-doc branch August 23, 2016 01:32
Comment thread docs/language-usage.rst
.. 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.

@dhermes dhermes 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 free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants