Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 12th, 2012  |  syntax: None  |  size: 0.46 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Extracting specific information from text
  2. import nltk
  3. from nltk.text import *
  4. from nltk.corpus import PlaintextCorpusReader
  5.  
  6. def readfiles():    
  7.     corpus_root = 'C:prototypeemails'
  8.     w = PlaintextCorpusReader(corpus_root, '.*')
  9.     t = Text(w.words())
  10.     print "--- to ----"
  11.     print t.concordance("to")
  12.  
  13.     print "--- from ----"
  14.     print t.concordance("from")
  15.        
  16. cityState = dataAfterTo.split(",")
  17. city = cityState[0]
  18. state = cityState[1].split()[0]