• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here: Home » Example of Using IBM Watson For Text Analysis with Google Docs

By Abhishek Ghosh April 20, 2018 2:24 am Updated on April 25, 2018

Example of Using IBM Watson For Text Analysis with Google Docs

Advertisement

In previously published articles on this website, we discussed around developing cognitive applications using IBM Data Science Experience tool. As IBM has lot of examples on Github and their official websites intended for the developers; the reader factually need not to be machine learning expert to build scripts, programs, plugins which that can recognize objects in photographs or analyze emotion of text written by human. One such example usage is in WordPress Plugin to Analyze Emotion of posts. This Example of Using IBM Watson For Text Analysis with Google Docs Demands Not Much Knowledge of Coding and This Can Be Used to Analyze Common Text Articles.

For this guide, you’ll need :

  1. IBM Cloud/Bluemix trial or paid account
  2. Google Apps account to add scripts

 

Below are some resources, official working demo from IBM around the topic :

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
...
https://console.bluemix.net/docs/services/visual-recognition/getting-started.html
https://github.com/IBM-Cloud/watson-spreadsheet
https://developer.ibm.com/code/patterns/
https://github.com/IBM/powerai-vision-object-detection
https://www.ibm.com/in-en/marketplace/deep-learning-platform
https://visual-recognition-demo.ng.bluemix.net/train
# hardware for data center and/or server room
https://www.ibm.com/it-infrastructure/power
...

NOTE : We do not recommend to upload sensitive document on Google Cloud for avoiding breech of privacy. Google’s various services are blacklisted by Richard Stallman & Free Software community. IBM Watson definitely a proprietary service but IBM, at least till the time of publication of this article, not known to be associated with mass surveillance.

 

Using IBM Watson For Text Analysis : Needed Minimum Theory

 

IBM Watson For Text Analysis is example of Natural Language Processing (NLP) service by IBM. With the service, we are using machine learning to extract data and understand overall emotion of text. In one recent article, we discussed difference of AI and machine learning to the newbies.

Natural Language Processing (NLP) is the ability of a computer program to understand natural human language. Natural Language Processing (NLP) is a component of artificial intelligence (AI) like machine learning (ML) is.

Example-of-Using-IBM-Watson-For-Text-Analysis-with-Google-Docs

 

Example of Using IBM Watson For Text Analysis with Google Docs

 

Obviously, you need to know how to add script in Google Docs. That documentation, how to is here :

Vim
1
2
3
4
https://developers.google.com/apps-script/
https://developers.google.com/apps-script/guides/docs
https://developers.google.com/apps-script/quickstart/docs
https://developers.google.com/apps-script/guides/dashboard

Next, you need to know about IBM’s that API :

Vim
1
https://www.ibm.com/watson/developercloud/natural-language-understanding/api/v1/#introduction

Here is similar type of guides on creating scripts for Google Apps :

Vim
1
https://www.ibm.com/blogs/bluemix/2016/08/watson-services-and-google-docs/

I got a ready to use script from this post :

Vim
1
https://www.labnol.org/internet/ibm-watson-google-docs-nlp/31481/

I ported that script with GNU GPL 3.0 License (you can also change credit, pop-up etc) for education :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 
IBM Watson Demo for Google Docs
-------------------------------
 
Contributed by Abhishek Ghosh
Email: admin@thecustomizewindows.com
Web: https://thecustomizewindows.com/
Twitter: @AbhishekCTRL
 
*/
 
function analyzeText_() {
  
  var text = getSelectedText_();
  
  if (!text.length) {
    showMessage_("Please select some text in the document.");
    return;
  }
  
  var credentials =  {
    "username": "b5e4783c-2646-4b24-86fb-d737f4b7b6d0",
    "password": "AcSJCy5squjb"
  };
  
  var payload = {
    "text": text.join("\n"),
    "features": {
      "entities": {
        "emotion": false,
        "sentiment": false,
        "limit": 10
      }
    }
  };
  
  var url = "https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2017-02-27";
  
  var response = UrlFetchApp.fetch(url, {
    "method": "POST",
    "contentType": "application/json",
    "payload": JSON.stringify(payload),
    "headers": {
      "Authorization" : "Basic " + Utilities.base64Encode(credentials.username + ":" + credentials.password)
    }
  });
  
  var entities = JSON.parse(response).entities;
  
  var answers = entities.filter(function(entity) {
    return entity.relevance > .3
  }).map(function(entity) {
    return [entity.text, entity.type].join(" - ");
  });
  
  if (answers.length) {
    showMessage_(answers.join("\n"));
  } else {
    showMessage_("Sorry, no entities were found");
  }
  
}
 
function about_() {
  showMessage_("This demo was contributed by Abhishek Ghosh\nEmail: admin@thecustomizewindows.com\nWebsite: https://thecustomizewindows.com/");
}
 
 
function onOpen(e) {
  DocumentApp.getUi()
  .createMenu("★ IBM Watson")
  .addItem('Analyze Text', 'analyzeText_')
  .addItem('About', 'about_')
  .addToUi();
}
 
function getSelectedText_() {
  var text = [];
  var selection = DocumentApp.getActiveDocument().getSelection();
  if (selection) {
    var elements = selection.getSelectedElements();
    for (var i = 0; i < elements.length; ++i) {
      if (elements[i].isPartial()) {
        var element = elements[i].getElement().asText();
        var startIndex = elements[i].getStartOffset();
        var endIndex = elements[i].getEndOffsetInclusive();        
        text.push(element.getText().substring(startIndex, endIndex + 1));
      } else {
        var element = elements[i].getElement();
        if (element.editAsText) {
          var elementText = element.asText().getText();
          if (elementText) {
            text.push(elementText);
          }
        }
      }
    }
  }
  return text;
}
 
function showMessage_(e) {
  DocumentApp.getUi().alert(e);
}
 
/**
* @OnlyCurrentDoc  
*/

That :

Vim
1
2
3
  var credentials =  {
    "username": "b5e4783c-2646-4b24-86fb-d737f4b7b6d0",
    "password": "AcSJCy5squjb"

should be changed to yours one till he blocks or change it! That above credential is of original poet who written the script (if he changes credential, you can click open his link, go to Tools menu, then click Script Editor option menu to find the script and get the new credential). I also kept the thing as GitHub repo.

How to use it?

  1. On Google Docs of Google Apps open any text document.
  2. Go to Tools menu, then click Script Editor option menu.
  3. A new window from https://script.google.com/a/ will open.
  4. Copy-paste the above snippet and save it.
  5. Reload the Google Docs of Google Apps window with your text document.
  6. You’ll notice that a new button named ★ IBM Watson appeared beside Help menu of Google docs.
  7. Now select text, click that ★ IBM Watson option to bring down option menu, click select Analyze Text.
  8. IBM Watson will ask for permission, allow it.
  9. Then you’ll get the result as pop-up window.
  10. That’s it

 

Now, modify that script to add more creativity.

Tagged With complexyqi , example of text for watson analysis , IBM textAnalysis error , ibm watson text analysis entities , parsing error in ibm watson language using uipath , takeggp , tornoei , upuv6

This Article Has Been Shared 322 Times!

Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Example of Using IBM Watson For Text Analysis with Google Docs

  • Building Big Data Analytics Solutions In The Cloud With Tools From IBM

    We Can Plan Building Big Data Analytics Solutions In The Cloud With Tools From IBM For Cost Reduction, Simplicity & Using Advanced Features.

  • What is Fog Computing, Fog Networking, Fogging

    Fog computing is a System-Wide Architecture Which is Useful For Deploying Seamlessly Resources and Services For Computing, Data Storage.

  • Theoretical Foundations of Big Data : Part 3

    Theoretical Foundations of Big Data is third and final part of our series of articles. We have talked about Data Mining, OLAP & softwares.

  • How To Install and Run iPython/Jupyter Notebook on IBM Bluemix

    This is Old Way of Using Tools Around Big Data and Data Science. Here are Steps on How To Install, Run iPython/Jupyter Notebook on Bluemix.

  • Machine Learning in Medical Diagnosis : GitHub Projects

    Here Are Some GitHub Projects Around Machine Learning in Medical Diagnosis. Few current applications of AI in medical diagnostics are already in use.

Additionally, performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Zebronics Pixaplay 16 : Entry Level Movie Projector Review February 2, 2023
  • What is Voice User Interface (VUI) January 31, 2023
  • Proxy Server: Design Pattern in Programming January 30, 2023
  • Cyberpunk Aesthetics: What’s in it Special January 27, 2023
  • How to Do Electrical Layout Plan for Adding Smart Switches January 26, 2023

About This Article

Cite this article as: Abhishek Ghosh, "Example of Using IBM Watson For Text Analysis with Google Docs," in The Customize Windows, April 20, 2018, February 3, 2023, https://thecustomizewindows.com/2018/04/example-of-using-ibm-watson-for-text-analysis-with-google-docs/.

Source:The Customize Windows, JiMA.in

PC users can consult Corrine Chorney for Security.

Want to know more about us? Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy

We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT