Text/Word counting in a file from python
<p>Chat.txt</p>

<pre><code>ID674 25/01/1986 Thank you for choosing Optimus prime. Please wait for an Optimus prime Representative to respond. You are currently number 0 in the queue. You should be connected to an agent in approximately 0 minutes.. You are now chatting with 'Tom' 0      &lt;br/&gt;
ID674 2gb Hi there! Welcome to Optus Web Chat 0/0/0 . How can I help you today?  1 
ID674 25-01-1986 I would like to change my bill plan from $0 with 0 expiry to something else $136. I find it very unuseful. Sam my phone no is 9838383821   2
</code></pre>

<p>In the text mentioned above is just an example of few lines in a file.My requirement is that  all the dates for example 25/01/1986 or 0/0/0 should be replaced with "DATE123"  .
<br/>Then :) should be replaced with "smileys123". 
Currencies i.e, $0 or $136 should be replaced with "Currency123" 
<br/>'TOM' (usually agents name in single quotes) should be replaced with AGENT123 
<br/>and many more.The output should be the number of occurrences of the string as shown</p>

<pre><code>DATE123=2  smileys123=2 Currency123=6 AGENT123=5
</code></pre>

<p>I have this approach as of now please let me know about this ,</p>

<pre><code>  class Replace:
     dateformat=DATE123
     smileys=smileys123
     currency=currency123

  count_dict={}

  function count_data(type,count):
     global count_dict
     if type in count_dict:
        count_dict[type]+=count
     else:
        count_dict = {type:count}


  f=open("chat.txt")
  while True:
     for line in f.readlines():
        print line,
        if ":)" in line:
           smileys = line.count(":)")
           count_data("smileys",smileys)
        elif "$number" in line :    #how to see whether it is currency or nor??
           currency=line.count("$number") //how can i do this
           count_data("currecny",currency)
        elif "1/2/3" in line :    #how to validate date format
           dateformat=line.count("dateformat") #how can i do this
           count_data("currency",currency)
        elif validate-agent-name in line:
           agent_name=line.count("agentname")  #How to do this get agentname in single quotes
           count_data("agent_name",agent_name)
     else:
        break
  f.close()

  for keys in count_dict:
     print keys,count_dict[keys]


  The following would be the ouput

  DATE123=2  smileys123=2 Currency123=6 AGENT123=5
</code></pre>
