title: String processing:How to look up a word if a certain word exists write a dictionary (regular expression)
body: <p>I have a .txt file looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/WtyjV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WtyjV.png" alt="this"></a></p>
  
  <p>As you can see its a several relationships between the verbs (don't care about the numbers) the file has 5,000 lines. </p>
  
  <p>Data is here: under Download &amp; Use VerbOcean : <a href="http://demo.patrickpantel.com/demos/verbocean/" rel="nofollow noreferrer">http://demo.patrickpantel.com/demos/verbocean/</a></p>
  
  <p>What I want is a dict for each relationship, so that we could say for example</p>
  
  <pre><code>similar-to['anger'] = 'energize' 
  happens-before['X'] = 'Y'
  stronger-than ['A'] = 'B'
  </code></pre>
  
  <p>and so on.</p>
  
  <p>So what I have so far is working perfectly for only [stronger-than] relationship. how should I extend it in a way that does all other relationships as well? </p>
  
  <pre><code>import csv
  
  file = open("C:\\Users\\shide\\Desktop\\Independent study\\data.txt")
  counter = 1
  stronger = {}
  strongerverb = []
  secondverb = []
  term1 = "[stronger-than]" #Look for stronger-than
       words = line.split()  #split sentence
      if term1 in words:  #if ['Stronger-than'] exists in the line then add the first word
       strongerverb.append(line.split(None, 1)[0]) # add only first verb
       secondverb.append(line.split()[2])  #add second verb
  
       if term1 in words:  # if ['Stronger-than'] exists in the line then add the first word
           strongerverb.append(line.split(None, 1)[0])  # add only first verb
           secondverb.append(line.split()[2])  # add second verb
  
  capacity = len(strongerverb)
  
  index = 0
  while index!=capacity:
      line = strongerverb[index]
      for word in line.split():
    #      print(word)
          index = index+1
  #print("First verb:",firstverb)
  #print("Second verb:",secondverb)
  for i in range(len(strongerverb)):
      stronger[strongerverb[i]] = secondverb[i]
  
  #Write a CSV file that fist column is containing verbs that is stronger than the second column.
  
  with open('output.csv', 'w') as output:
       writer = csv.writer(output, lineterminator='\n')
       for secondverb, strongerverb in stronger.items():
          writer.writerow([strongerverb, secondverb])
  </code></pre>
  
  <p>One way is to do same way for all other relationships but I guess that would not be a smart thing. Any ideas? 
  what I want is a dict for each relationship, so that we could say:</p>
  
  <pre><code>similar-to['anger'] = 'energize' 
  happens-before['X'] = 'Y'
  stronger-than ['A'] = 'B'
  </code></pre>
  
  <p>I am new to python and any help would be greatly appreciated. </p>