Skip to content

[Sample] Vietnamese text classification with Natural Language API #14679

Open

Description

@Dennis-nham

Sample Request: Vietnamese Text Classification

Reporter: NHAM QUOC HUAN · NLP Labs Vietnam


Background

We are building Vietnamese NLP applications at NLP Labs Vietnam using Google Cloud Natural Language API. The current sample collection lacks any Vietnamese language example, despite the API supporting it.

Gap

Looking at natural-language/ samples — all examples use English text. Vietnamese (vi) is a supported language per the API documentation, but no sample demonstrates this.

Proposed Addition

A minimal Vietnamese example in the existing natural-language/ samples:

# natural-language/samples/snippets/analyze_sentiment_vi.py

def analyze_sentiment_vietnamese(text_content: str):
    """Analyzes sentiment of Vietnamese financial text."""
    from google.cloud import language_v2

    client = language_v2.LanguageServiceClient()
    document = language_v2.Document(
        content=text_content,
        type_=language_v2.Document.Type.PLAIN_TEXT,
        language_code="vi",  # Vietnamese
    )
    sentiment = client.analyze_sentiment(
        request={"document": document}
    ).document_sentiment
    return sentiment

Scope: Small addition — 1 Python file + test + README note.

We are ready to submit a PR with this sample.

Organization: github.com/nlp-labs-vietnam

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    samplesIssues that are directly related to samples.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions