Using Document AI and Natural Language API for Form Sentiment Analysis

PMLE By islever Editorial Last updated

Short answer

C Train a Document AI custom extractor to parse the text in the comments section of each PDF file and use the Natural Language API analyzeSentiment feature to infer overall satisfaction scores.

Question

You work for a hotel and have a dataset that contains customers’ written comments scanned from paper-based customer feedback forms, which are stored as PDF files. Every form has the same layout. You need to quickly predict an overall satisfaction score from the customer comments on each form. How should you accomplish this task?
  1. Use the Vision API to parse the text from each PDF file. Use the Natural Language API analyzeSentiment feature to infer overall satisfaction scores.
  2. Use the Vision API to parse the text from each PDF file. Use the Natural Language API analyzeEntitySentiment feature to infer overall satisfaction scores.
  3. Uptrain a Document AI custom extractor to parse the text in the comments section of each PDF file. Use the Natural Language API analyzeSentiment feature to infer overall satisfaction scores. Correct Answer
  4. Uptrain a Document AI custom extractor to parse the text in the comments section of each PDF file. Use the Natural Language API analyzeEntitySentiment feature to infer overall satisfaction scores.

Key Takeaways

The main trap is confusing general OCR (Vision API) with structured extraction (Document AI Custom Extractor) and misunderstanding that 'overall' sentiment requires global analysis (analyzeSentiment) rather than entity-level breakdown (analyzeEntitySentiment).

This question explores selecting the right Google Cloud AI tools for extracting text from standardized forms and analyzing customer sentiment. The solution involves using Document AI Custom Extractors for precise field extraction and the Natural Language API's analyzeSentiment feature for overall scoring.

Common mistake: Option A is a common distractor because Vision API is faster to implement initially. However, it fails to account for the need to isolate specific text fields from a structured form layout efficiently, leading to noisy data for the sentiment analysis step.

Expert Analysis

The correct answer is C. This question tests the ability to select appropriate Google Cloud AI services for a specific document processing and analysis workflow, focusing on precision and efficiency.

Document Extraction: Vision API vs. Document AI Custom Extractor The scenario specifies that feedback forms are scanned PDFs with a "same layout" (consistent structure). While the Vision API can perform OCR, it extracts all text indiscriminately. To isolate just the "comments section" accurately without parsing irrelevant form fields (like dates or names), Document AI is the superior choice. Specifically, a Custom Extractor in Document AI is designed for high-volume documents with consistent layouts. By training it on a few labeled examples, you create a model that precisely targets the comments field, ensuring the downstream NLP service receives clean, relevant data. The comment highlighting this states: "Every form has the same layout, which is the signature case for a Document AI custom extractor... it ignores the rest of the form." Using Vision API (Options A and B) would require additional complex logic to filter noise, making it less robust for this specific constraint.

Sentiment Analysis: analyzeSentiment vs. analyzeEntitySentiment The goal is to predict an "overall satisfaction score." The Natural Language API's analyzeSentiment feature provides a global sentiment score (polarity and magnitude) for the entire input text, which directly correlates to overall satisfaction. In contrast, analyzeEntitySentiment breaks down sentiment by named entities (e.g., "the food was good," "the service was bad"). Since we need a single aggregate score from the whole comment, analyzeEntitySentiment is inappropriate as it yields multiple entity-specific scores rather than one holistic metric. As noted in the comments, "The analyzeSentiment function directly addresses the need for an overall satisfaction score."

Why Other Options Fail:

  • A & B: Use Vision API, which lacks the structured extraction capability needed to reliably isolate the comments section from a standardized form layout compared to Document AI Custom Extractors.
  • D: Uses analyzeEntitySentiment, which is incorrect for deriving a single overall satisfaction score from unstructured text blocks.

Exam Strategy

When a question mentions 'standardized layout', 'forms', or 'repeating structures', prioritize Document AI over generic Vision API for text extraction. Always match the output requirement: if the goal is an 'overall' or 'global' score, choose analyzeSentiment; if the goal is understanding sentiment toward specific products or features mentioned, consider analyzeEntitySentiment. Speed ('quickly') does not override accuracy needs when layout consistency allows for efficient custom model training.

Frequently Asked Questions

Why not use Vision API for OCR since it's simpler?

Vision API extracts all text. For standardized forms, Document AI Custom Extractors are more accurate at isolating specific fields like 'comments' without needing complex post-processing filters.

What is the difference between analyzeSentiment and analyzeEntitySentiment?

analyzeSentiment gives a single polarity/magnitude score for the whole text. analyzeEntitySentiment breaks sentiment down by named entities (e.g., 'room', 'staff'), which isn't suitable for a single overall satisfaction score.

More PMLE FAQ →

Community Votes

C
54%
A
46%

54% of anonymous learners picked answer C. Votes are pick records left by other test-takers — they are not the verified answer.

Discussion 17 contributions

Compiled from public community threads and reader submissions, lightly edited for clarity. Handles and vote tallies are shown as recorded, and comments reflect the views of individual contributors.

From public community threads 17

  1. fitri001 👍 6 Answered C
    Document AI custom extractor: Since the layout of the feedback forms is consistent, training a custom extractor in Document AI allows for efficient and accurate extraction of the specific comments section. This ensures the Natural Language API receives the relevant text for sentiment analysis. Natural Language API - analyzeSentiment: This functionality within the Natural Language API is specifically designed to analyze sentiment in a piece of text. It provides an overall sentiment score that can be mapped to a satisfaction score (e.g., high positive sentiment translates to high satisfaction).
  2. fitri001 👍 4
    A. Vision API - parseText: While the Vision API can extract text from PDFs, it wouldn't necessarily target the specific comments section without a custom parser. B. Natural Language API - analyzeEntitySentiment: This feature focuses on sentiment analysis for named entities within the text. It might not be ideal for overall satisfaction extraction from general customer comments.
  3. edoo 👍 3 Answered A
    I go with A, because "you need quickly predict", no time for fine-tunning.
  4. pikachu007 👍 2 Answered C
    Precision in text extraction: Document AI is specifically designed for extracting text from structured documents like forms, ensuring accurate extraction of comments, even with varying handwriting styles. Custom model for form layout: Training a custom extractor tailored to the hotel's feedback form layout further enhances accuracy and targets the relevant comments section effectively. Sentiment analysis: Natural Language API's analyzeSentiment feature analyzes overall sentiment in a text block, aligning with the goal of deriving overall satisfaction scores.
  5. lunalongo 👍 2 Answered A
    In summary, option A offers the optimal balance of speed, accuracy, and simplicity for this specific task. Using the pre-trained APIs is faster and requires less expertise than training a custom model. The analyzeSentiment function directly addresses the need for an overall satisfaction score. Why not D? If speed is the absolute priority and the layout is truly consistent, the Vision API's speed might outweigh the potential for slightly improved accuracy from a custom extractor.
Show 12 more comments
  1. guilhermebutzke 👍 2 Answered C
    My answer: Letter C Document AI is a suitable tool for cases where there are patterns of forms or documentation. Additionally, it is possible to directly read PDF files. In the Natural Language API, the analyzeSentiment function can determine the overall sentiment, as the text asks, "You need to quickly predict an overall satisfaction." The analyzeEntitySentiment function provides a score for each entity or word found. https://cloud.google.com/natural-language/docs/basics
  2. bobjr 👍 2 Answered A
    C & D are overkill We don't care about entities sentiment -> B is out Left with A and https://cloud.google.com/natural-language/docs/reference/rest/v1/documents/analyzeSentiment
  3. pinimichele01 👍 2 Answered A
    quickly predict an overall satisfaction -> a
  4. taylz876 👍 1 Answered C
    There are two steps, and each one needs the right tool. 1. Get the comments out of the scanned forms. Every form has the same layout, which is the signature case for a Document AI custom extractor. You train it on a few labeled examples to pick out exactly the comments section, and it ignores the rest of the form. Document AI is now part of the Agent Platform tools. 2. Score the overall satisfaction. analyzeSentiment returns one score for the whole text, from negative to positive, which is the overall satisfaction score you want. Why the others are wrong • A and B: The Vision API reads all the text on the page, including headings, field labels and printed boilerplate, so you would have to clean it up. Your notes say forms belong to Document AI, not Vision. • B and D: analyzeEntitySentiment gives a separate sentiment for each entity mentioned (like "room", "staff", "breakfast"). That is more detail than one overall score, so analyzeSentiment is the better fit.
  5. ddogg 👍 1 Answered C
    Document AI custom extractor: This allows you to tailor the text extraction specifically to the layout and format of your customer feedback forms, ensuring accurate capture of the comments section. Natural Language API analyzeSentiment: This feature analyzes the extracted text and provides an overall sentiment score, which can be used to gauge customer satisfaction.
  6. AzureDP900 👍 1
    C is right Document AI custom extractor: Allows you to train a custom model to extract relevant information (in this case, customer comments) from the PDF files. Natural Language API analyzeSentiment feature: Analyzes the sentiment of the extracted text to predict an overall satisfaction score.
  7. 8c200dd 👍 1 Answered A
    I worked in OCR project, Document AI is good but we need to train the model with labeling it will take lot of time. Vision is not like that they said quickly, also they are not asking to minimize the cost. so A is correct.
  8. Pau1234 👍 1 Answered C
    DocumentAI is perfect for the case. Since the question says: "overall satisfaction", then entity is not needed.
  9. Ankit267 👍 1 Answered A
    "quickly" is the differentiator between A & C
  10. Foxy2021 👍 1
    My vote is a. It is simple and do the job.
  11. Kalai_1 👍 1 Answered C
    Document AI best fit for this use case.
  12. pinimichele01 👍 1
    no sorrt, it's C, you need doc AI

Reader comments & corrections

No reader corrections yet — spotted an error or have a note? Share it below.

Log in to comment, report an error, or add a note about this question.

Practice All PMLE Questions

Access 65 questions with complete answers and detailed explanations.

View Full PMLE Practice Test →

← Back to PMLE Study Guide