#NEWLINE# def ImportFileOrFolder( self , tokenRegex = None , removeStopwords = True , stoplistFile = None , keepSequence = True ) : #NEWLINE# #INDENT# if ( not os . path . exists ( self . corpusPath ) ) : #NEWLINE# #INDENT# os . makedirs ( self . corpusPath ) #NEWLINE# #UNINDENT# if os . path . isdir ( self . inputPath ) : #NEWLINE# #INDENT# self . logger . info ( 'Importing a folder into MALLET: [%s] --> [%s]' , self . inputPath , self . corpusInMallet ) #NEWLINE# command = [ self . malletExecutable , 'import-dir' ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . logger . info ( 'Importing a file into MALLET: [%s] --> [%s]' , self . inputPath , self . corpusInMallet ) #NEWLINE# command = [ self . malletExecutable , 'import-file' ] #NEWLINE# #UNINDENT# command += [ '--input' , self . inputPath ] #NEWLINE# command += [ '--output' , self . corpusInMallet ] #NEWLINE# if removeStopwords : #NEWLINE# #INDENT# command += [ '--remove-stopwords' ] #NEWLINE# #UNINDENT# if ( stoplistFile is not None ) : #NEWLINE# #INDENT# command += [ '--stoplist-file' , stoplistFile ] #NEWLINE# #UNINDENT# if ( tokenRegex is not None ) : #NEWLINE# #INDENT# command += [ '--token-regex' , tokenRegex ] #NEWLINE# #UNINDENT# if keepSequence : #NEWLINE# #INDENT# command += [ '--keep-sequence' ] #NEWLINE# #UNINDENT# self . Shell ( command )