Organizations can understand their customers’ views of their product or service using text analysis of their reviews, feedback, or transcribed call to customer service. Voice of Customer (VoC) allows businesses to look at the product from the user’s perspective. This makes it an indispensable tool for early defect detection, brand management, market analysis, etc. This article describes an architecture to deploy Voice of Customer Solution using Google’s Cloud Natural Language API. We discuss the strengths of these powerful APIs. We also mention some of the limitations of Google APIs and how they can be addressed using smart text processing by applying domain-specific taxonomy. We will also share the results obtained using Google APIs and NLP processing on two types of customer review data, Apparel and Technology product shopping.
Google’s Cloud Natural Language API
The Cloud Natural Language API allows developers to classify a document, analyze the sentiments, identify entities and associated sentiments. It also provides the capability to analyze the syntax. All these abilities are provided to a user using APIs based on Google’s pre-trained models. A notable feature of Google APIs is that it returns sentiments at three levels: document level, sentence level, and entity level. The Google Natural Language APIs are a suitable and state-of-the-art option for building VoC solutions. The developer does not need to be an NLP expert, and understanding of the underlying machine learning models is not required. On the other hand, access to the model details is not provided; hence it cannot be tuned to a specific task or dataset.
Google Cloud provides another capability called AutoML Natural Language which enables Data Scientists to build and deploy custom machine learning models that analyze and categorize documents, identify entities within them and assesses attitudes within them. This gives the flexibility to develop a tailored NLP model in contrast to the standardized out-of-the-box capabilities Cloud Natural Language API functions can provide.
Building Voice of Customer solution using Google Cloud NLP APIs
We built Voice of Customer as a natural language processing solution that aims to help a business to understand the opinion of the customers about the products and services they offer. Customers express their views and emotions by posting their reviews on various online platforms. VoC provides the ability to the decision-makers to understand customer views and emotions and reasoning behind it.
Earlier, we built VoC solutions using open source and another well-known analytics platform. We found that adapting Google Cloud to scale VoC solution for thousands of reviews or documents from various sources like e-commerce platforms, emails, social media is cost-effective and efficient. Resilient architecture represented below in Figure 1 ensures scaling up or down of the VoC solution as and when required.
Figure 1: Architecture diagram of VoC using Cloud Natural Language API on Google Cloud
For our VoC solution, we created the programs described below to collect the responses from Google API, which scales for thousands of reviews.
- Driver function: It estimates the volume of data to be processed and,based on decides the number of worker functions to be initiated so that requests to APIs and NLP processing for complete data takes only a few minutes. Every worker function processes only a small segment of data.
- Worker functions:
- The job of the worker functions is to invoke analyseSentiment and analyseEntitySentiment APIs. It also maps entities to the sentences of the document.
- Using the analyseSyntax method to collect tokens and retain only adjectives/adverbs/nouns in the document. It associates the filtered tokens with entities using customized rules.
- Lemmatization of both entities and tokens to eliminate redundancy and filtering out irrelevant entities.
- Use classifyText method to obtain the document category of the reviews and retain category having highest confidence value.
- All the processed results are collected, and a dashboard is used to communicate all the actionable insights.
Voice of Customer: Use Cases
We produced results for ~1,200 reviews for apparel and ~2,200 reviews for technology products using the architecture outlined above and custom natural processing. A quick summary of the results is provided below.
Dashboard snapshot for Technology product reviews
|Number of documents processed||1,190||2,266|
|Number of sentences processed||4,254||8,530|
|Document categories detected||12 out of which 90% are Shopping category of taxonomy generated by Google classifyText method||17 out of which 85% in Computers & Electronics category of taxonomy generated by Google classifyText method|
|Unique entities detected||8,435||4,722|
|Types of entities detected||7 types of entities out of 67% is “Other” category||7 types of entities out of 67% is the “Other” category, followed by Consumer Goods (17%)|
This section of the dashboard provides a summary of document categories and top positive and negative sentiment entities. The bar chart displays the monthly review count, and the line shows the average sentiment score.
Dashboard snapshot for reviews of apparels
This section of the dashboard provides a summary of entity sentiments for technology products. It displays entities with their total positive, negative, and neutral mentions and key themes used by the reviewer to express their sentimentsDeriving value out of responses collected from Google NLP API
Cloud natural language APIs are powerful in detecting a variety of entities and document categories. It determines the sentiments at three different levels: document level, sentence level and entity level with high accuracy. Numeric values generated by the APIs like sentiment score and magnitude are used to define the polarity of the sentiment. Salience is a score generated for entities to indicate the centrality of the entity and is used to drop the entities which does not have reasonable score. The classifyText method does excellent job of document classification and creates document category at three levels with hierarchical structure. It has the ability to classify documents into 27 content categories with three levels of hierarchy. Review example 1, below is correctly classified as /Computers & Electronics/Computer Hardware/Laptops & Notebooks with 99% confidence. All the important entities like laptop, game, keyboard and keys are detected. Sentiment scores generated for these entities are accurate.
|Example 1: “This ⟨laptop⟩1 is amazing. It runs ⟨everything⟩3 I need it to run, including intensive ⟨games⟩4 . I can now play my favorite ⟨game⟩6 in my ⟨laptop⟩1 . The ⟨one⟩8 ⟨downside⟩2 is that the ⟨keyboard⟩7 is terribly hard as half the time when I push the ⟨keys⟩5 , it does not type. “|
Customer has expressed his happiness about the laptop with concerns related to keyboard. APIs detected it correctly. Sentiment score for the laptop is positive while sentiment score for the keyboard or keys is negative. Entity level sentiment is provided in the table below for the example 1
While Google APIs provide multiple capabilities and scales for thousands of documents, it requires processing to translate the results into actionable insights to take business decisions. There are some limitations which have been addressed by introducing customized natural language processing using domain knowledge. Figure 2 represents a high-level functional step to enhance the API results used in our VoC solution.
Figure 2: Functional Steps in VoC Solution
APIs scale for thousands of documents and one does not need expertise in natural language processing. Responses from API calls are collected and processed using domain-specific taxonomy and custom rules to polish the information present. Responses for each review from all the five APIs are processed to create actionable insights. This includes data cleaning and augmenting the results with domain-specific taxonomy and linguistic rules.
As stated, earlier, analyzeEntitySentiment has generated an accurate sentiment score for keyboard in the example 1 but is not sufficient to take a specific action. Sentiment for keyboard is negative, and reviewer has used the adjective “terribly hard” to describe the issue. The product team would be interested in knowing the reasons for negative sentiments. To enrich the insight and make it actionable, themes of expression are captured using the analyzeSyntax method and associated with entities detected using distance in the sentence vector. So, if the negative sentiment of the keyboard is combined with terribly hard, the business understands the issue with the keyboard.
AnalyzeEntity API also returns large number of entities irrelevant to the business-like downside and everything in the example 1. In the same example, games and game are detected as two different entities and classified as Event and Work of Art, similarly, keyboard as Consumer Good but keys as Other. These limitations in the APIs are addressed in VoC by creating dictionary of entities not relevant to a domain and is used to eliminated impertinent entities. A rule-based approach specific to the domain is developed to refine entity classification and lemmatize identified entities (game and games) to ensure that the same entities are not identified as different entities. In example 1, since the document category is /Computers & Electronics/Computer Hardware/Laptops & Notebooks with 99% confidence, entities like keys, the game gets reclassified as consumer goods.
Google entity sentiment API does not always deal with negations for entity sentiments appropriately. For the below review (Example 2) for a dress overall document and sentence level sentiment score computed by API is negative but quality as an entity is assigned a positive score. This is addressed using custom rules by associating negation keywords with entities and changing the polarity of the scores.
|Example 2: “This ⟨dress⟩1 was beautiful, and I loved wearing it but the ⟨quality⟩3 couldn’t be more awful! The ⟨lace⟩2 stretched and balled up and after ⟨hand washing⟩4 it literally was falling apart after ⟨one⟩5 time wearing it.”|
We summarize below the text processing used in our VoC solution to refine the results collected using Google APIs to create actionable insights.
- Analysis of sentiment scores and their magnitude across the document-by-document category for a sample of reviews is used to understand the effectiveness of Google’s pre-trained model for a given domain.
- Analysis of entities: Entities detected are processed to eliminate redundancy and irrelevancy (e.g., game vs games, everything, etc. in the example 1) and entities (downside) not relevant to the business domain. This is implemented by creating a dictionary of entities irrelevant to a domain. Negations are handled using custom rules after analyzing the entities and its sentiment scores.
- Reclassification of entities using document category and domain knowledge.
- Sentiments collected at the sentence level and entity level are associated with themes (adjective/adverb) using the tokens collected using anayzeSyntax. This helps in understanding the kind of words customers have used to express their sentiments and if needed sentence to understand the context. These are used to understand the degree of negative or positive sentiments.
Comparison of Google’s Cloud Natural Language with open-source NLP packages
Polyglot, NLTK, TextBlob, fastText are some of the alternate open-source packages available for sentiment analysis. However, these packages have many limitations. These open-source packages do not support Entity Sentiment Analysis, they provide document-level sentiments. A rule-based approach is required to compute Entity sentiments which require significant effort and knowledge natural language processing is non-negotiable. Polyglot supports named-Entity Sentiment Analysis but is limited to Country, Organization, Places, etc.
Most of the open-source packages support only English whereas Google APIs support multiple languages (https://cloud.google.com/natural-language/docs/languages). Scaling VoC using Google APIs is very easy and can be done in no time whereas scaling with an open-source platform requires dedicated effort on architectural design. It can be easily integrated with Speech-to-Text API to generate insights from audio conversations like customer care recordings etc. Google Cloud Natural Language APIs are cost-effective. For detailed pricing refer to the price guide: https://cloud.google.com/natural-language/pricing.
Google Cloud Natural Language APIs are useful in computing sentiment score at entity level besides document and sentence level. Voice of Customer solution built using these APIs scales to process thousands of the review document. Results obtained using five APIs are enriched by bringing all the information together to create actionable insights in the form of a dashboard. We have addressed limitations found with these APIs by developing domain specific entity or taxonomy dictionaries and custom rules. Google APIs auto scale without any administration overhead and capabilities are much better than open-source packages.
- Natural Language Understanding by James Allen. Published by Pearson Education.
- The Handbook of Computational Linguistics and Natural Language Processing by Alexander Clark, Chris Fox, and Shalom Lappin. Published by Wiley-Blackwell.
- Natural Language Processing with Python: Analyzing Text with the Natural Language Toolkit. Steven Bird, Ewan Klein, and Edward Loper. Published by O’Reilly Media, Inc.
- Reducing Warranty Costs Through Proactive Customer Sentiment Monitoring
Lokendra Devangan, Senior Manager
Vishal Sharma, Associate Analyst
Want to learn more about Sentiment Analysis for your business? Talk to our experts about what you’d like to do.
Core Compete is a Google Cloud Partner.