title: How to assign a number to a word from an API response
body: <p>I've created a custom machine learning model using Watson Knowledge studio and deployed to an NLU service. I've also managed to access my model in python. My custom model has been designed to identify specific entity types such as (Advice, Cancellation, Awareness, and so on). What I want to do is to extract these entity types from the API JSON response and assign a number to them (e.g Advice = 1, Cancellation = 2, Awareness = 3, etc.) and then write them along with the sample text (e.g "I want to cancel my subscription with Gameloft.") to a CSV file with column headings (ID, Sentence, Entity Type). I have already managed to extract the entity types and the sample text and written them to a .txt file, however I need to write them to a CSV file. </p>
  
  <pre><code>import json
  from watson_developer_cloud import NaturalLanguageUnderstandingV1
  from watson_developer_cloud.natural_language_understanding_v1 \
    import Features, EntitiesOptions, KeywordsOptions
  
  natural_language_understanding = NaturalLanguageUnderstandingV1(
    username='**************',
    password='*********',
    version='2018-03-16')
  
  text="I want to cancel my subscription with Gameloft."
  response = natural_language_understanding.analyze(
  text =text,  
    features=Features(
      entities=EntitiesOptions(
        emotion=True,
        sentiment=True,
        limit=2,
        model="**************"),
      keywords=KeywordsOptions(
        emotion=True,
        sentiment=True,
        limit=2)))
  
  
  
  print(json.dumps(response, indent=2)) 
  
  response['keywords'][0]['text']
  response ['entities'][0]['type']
  
  if response['entities'][0]['type'] == "Cancellation":
      print ('1')
  with open('C:\\Users\\Results.txt', "w") as f:
      for x in response['entities']:
          f.write(x['type'] + ' ')
  </code></pre>
  
  <p>Please help me with the following:</p>
  
  <p>How can I assign numbers to my entity types?</p>
  
  <p>Is there a way to create a loop that loads multiple sentences/text to be analyzed by the NLU API?</p>
  
  <p>How can I write everything(entity types, text and the numbers assigned to the entity types) to a CSV file?</p>