def document_generator(dir_path_pattern, count=None):
 for (running_count, item) in enumerate(glob.iglob(dir_path_pattern)):
  if (count and (running_count >= count)):
   raise StopIteration()
  doc_id = os.path.basename(item)
  with codecs.open(item, encoding='utf-8') as f:
   try:
    text = f.read()
   except UnicodeDecodeError:
    continue
   (yield Document(text, doc_id, item))

def document_generator ( dir_path_pattern , count = None ) : for ( running_count , item ) in enumerate ( glob . iglob ( dir_path_pattern ) ) : if ( count and ( running_count >= count ) ) : raise StopIteration ( ) doc_id = os . path . basename ( item ) with codecs . open ( item , encoding = 'utf-8' ) as f : try : text = f . read ( ) except UnicodeDecodeError : continue ( yield Document ( text , doc_id , item ) )
generator for the input movie documents .