Home | Trees | Indices | Help |
|
---|
|
1 # Natural Language Toolkit - File 2 # Understands operations on files and the various input files extensions 3 # 4 # Author: Sumukh Ghodke <sumukh dot ghodke at gmail dot com> 5 # 6 # URL: <http://nltk.sf.net> 7 # This software is distributed under GPL, for license information see LICENSE.TXT 8 9 from nltk_lite.contrib.classifier.exceptions import filenotfounderror as fnf, invaliddataerror as inv 10 import os, os.path 11 12 DOT = '.' 131752 5819 self.__check_for_existence() 20 fil = open(self.path, 'r') 21 returned = [] 22 for line in fil: 23 filtered = filter_comments(line) 24 if len(filtered) == 0: 25 continue 26 returned.append(method(filtered)) 27 fil.close() 28 return returned29 3335 if not overwrite and os.path.exists(self.path): 36 raise inv.InvalidDataError('File or Directory exists at ' + self.path + ' and overwrite is set to false.') 37 if os.path.exists(self.path): 38 if os.path.isfile(self.path): 39 os.remove(self.path) 40 else: 41 raise inv.InvalidDataError('Cannot overwrite directory ' + self.path + '.') 42 fil = open(self.path, 'w') 43 fil.close()4460 dot_index = file_name.rfind(DOT) 61 if dot_index == -1: 62 return [file_name, ''] 63 return [file_name[:dot_index], file_name[dot_index+1:]]64
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0beta1 on Wed May 16 22:47:54 2007 | http://epydoc.sourceforge.net |