{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "sys.path.append(os.path.join(os.getcwd(),'..'))\n",
    "import ibm_watson\n",
    "from ibm_watson.natural_language_understanding_v1 import Features, EntitiesOptions, KeywordsOptions\n",
    "from ibm_cloud_sdk_core.authenticators import IAMAuthenticator"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "authenticator = IAMAuthenticator('YOUR API KEY')\n",
    "nlu = ibm_watson.NaturalLanguageUnderstandingV1(version='2018-03-16', authenticator=authenticator)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{u'entities': [{u'count': 2,\n",
       "   u'relevance': 0.919052,\n",
       "   u'text': u'Bruce Banner',\n",
       "   u'type': u'Person'},\n",
       "  {u'count': 2,\n",
       "   u'relevance': 0.861216,\n",
       "   u'text': u'Bruce Wayne',\n",
       "   u'type': u'Person'}],\n",
       " u'keywords': [{u'count': 1,\n",
       "   u'relevance': 0.997922,\n",
       "   u'text': u'Bruce Banner iis'},\n",
       "  {u'count': 1, u'relevance': 0.968563, u'text': u'Bruce Wayne'},\n",
       "  {u'count': 1, u'relevance': 0.939485, u'text': u'Superman fears'},\n",
       "  {u'count': 1, u'relevance': 0.633474, u'text': u'Hulk'},\n",
       "  {u'count': 1, u'relevance': 0.620977, u'text': u'Banner'},\n",
       "  {u'count': 1, u'relevance': 0.550403, u'text': u'BATMAN'},\n",
       "  {u'count': 1, u'relevance': 0.530623, u'text': u'Wayne'},\n",
       "  {u'count': 1, u'relevance': 0.374627, u'text': u'experimental text'}],\n",
       " u'language': u'en',\n",
       " u'usage': {u'features': 2, u'text_characters': 121, u'text_units': 1}}"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "nlu.analyze(text='this is my experimental text.  Bruce Banner iis the Hulk and Bruce Wayne is BATMAN! Superman fears not Banner, but Wayne.',\n",
    "            features=Features(entities=EntitiesOptions(), keywords=KeywordsOptions())).get_result()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
