A Possible Framework for Document Analysis

Google Cloud Natural Language API

Alex Moltzau
3 min readAug 13, 2020

--

Google has an AutoML Natural Language Processing, and it could be an interesting part of a process. Using the Google framework to work with analysis is an interesting possibility to work with document analysis.

Image from Google’s explanation.

In a page describing basics Google describe specific code that can be used, and it:

  • Covers the types of requests you can make to the Natural Language API.
  • How to construct those requests.
  • How to handle their responses.

They recommend that all users of the Natural Language API read this guide.

They have several features.

  • “Sentiment analysis inspects the given text and identifies the prevailing emotional opinion within the text, especially to determine a writer’s attitude as positive, negative, or neutral. Sentiment analysis is performed through the analyzeSentiment method.
  • Entity analysis inspects the given text for known entities (Proper nouns such as public figures, landmarks, and so on. Common nouns such as restaurant, stadium, and so on.) and returns information about those entities. Entity analysis is performed with the analyzeEntities method.
  • Entity sentiment analysis inspects the given text for known entities (proper nouns and common nouns), returns information about those entities, and identifies the prevailing emotional opinion of the entity within the text, especially to determine a writer’s attitude toward the entity as positive, negative, or neutral. Entity analysis is performed with the analyzeEntitySentiment method.
  • Syntactic analysis extracts linguistic information, breaking up the given text into a series of sentences and tokens (generally, word boundaries), providing further analysis on those tokens. Syntactic Analysis is performed with the analyzeSyntax method.
  • Content classification analyzes text content and returns a content category for the content. Content classification is performed by using the classifyText method.”

The Natural Language API is a REST API, and consists of JSON requests and response.

“A RESTful API is an application program interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data.”

The following example is from the Google website.

A simple Natural Language JSON Entity Analysis request appears below:

{
"document":{
"type":"PLAIN_TEXT",
"language": "EN",
"content":"'Lawrence of Arabia' is a highly rated film biography about
British Lieutenant T. E. Lawrence. Peter O'Toole plays
Lawrence in the film."
},
"encodingType":"UTF8"
}

Several more examples can be found on Google’s website.

Using this could be part of a product, however it could also be used by independent analysts as part of a process.

This is #500daysofAI and you are reading article 436. I am writing one new article about or related to artificial intelligence every day for 500 days.

--

--

Alex Moltzau

AI Policy, Governance, Ethics and International Partnerships at www.nora.ai. All views are my own. twitter.com/AlexMoltzau