• 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
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

  • IBM Watson Studio : Drag and Drop Machine Learning Model Development

    IBM Watson Studio is a toolkit both for the newbie and data scientists with data science tools such as RStudio, Spark, Jupyter Notebooks, drag & drop tools.

  • Approaches of Deep Learning : Part 1

    From This Series on Approaches of Deep Learning We Will Learn Minimum Theories Around AI, Machine Learning, Natural Language Processing and Of Course, Deep Learning Itself.

  • Advantages & Disadvantages of Using IBM Big Data Analytics On Cloud

    This article namely Advantages & Disadvantages of Using IBM Big Data Analytics On Cloud is like a case study which deals with the big data analytics tools from one of the largest IT corporations in the world – IBM.

  • Facebook Analytics Cognitive Data Analysis : Jupyter Notebook & IBM Watson

    As Example, We Can Pull CSV Data From Facebook Analytics to Jupyter Notebook For Cognitive Data Analysis With IBM Watson & Jupyter Notebook.

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

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
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