parameters: (self,idx=None)
return_statement: return (examples, labels)
docstring: Read from file and split data into examples and labels
docstring_summary: Read from file and split data into examples and labels
docstring_tokens: Read from file and split data into examples and labels
function: def readlines(self,idx=None):
          """Read from file and split data into examples and labels"""
          fp = open(self.filename,'r')
          (dataname,issparse,alist,data) = arff.arffread(fp)
          fp.close()
          self.dataname = dataname
  
          #if (alist[0][0]!='label'):
          #    sys.stderr.write('First column of ARFF file needs to be the label\n')
          #    sys.exit(-1)
  
          if idx is None:
              idx = range(len(data))
  
          labels = [data[ix][0] for ix in idx]
          labels = array(labels)
          if self.extype == 'vec':
              examples = [data[ix][1:] for ix in idx]
              examples = array(examples).T
              print '%d features, %d examples' % examples.shape
          elif self.extype == 'seq':
              examples = [data[ix][1] for ix in idx]
              print 'sequence length = %d, %d examples' % (len(examples[0]),len(examples))
          elif self.extype == 'mseq':
              examples = [data[ix][1:] for ix in idx]
              printstr = 'sequence lengths = '
              for seq in examples[0]:
                  printstr += '%d, ' % len(seq)
              printstr += '%d examples' % len(examples)
              print printstr
  
          return (examples, labels)
function_tokens: def readlines ( self , idx = None ) : fp = open ( self . filename , 'r' ) ( dataname , issparse , alist , data ) = arff . arffread ( fp ) fp . close ( ) self . dataname = dataname #if (alist[0][0]!='label'): #    sys.stderr.write('First column of ARFF file needs to be the label\n') #    sys.exit(-1) if idx is None : idx = range ( len ( data ) ) labels = [ data [ ix ] [ 0 ] for ix in idx ] labels = array ( labels ) if self . extype == 'vec' : examples = [ data [ ix ] [ 1 : ] for ix in idx ] examples = array ( examples ) . T print '%d features, %d examples' % examples . shape elif self . extype == 'seq' : examples = [ data [ ix ] [ 1 ] for ix in idx ] print 'sequence length = %d, %d examples' % ( len ( examples [ 0 ] ) , len ( examples ) ) elif self . extype == 'mseq' : examples = [ data [ ix ] [ 1 : ] for ix in idx ] printstr = 'sequence lengths = ' for seq in examples [ 0 ] : printstr += '%d, ' % len ( seq ) printstr += '%d examples' % len ( examples ) print printstr return ( examples , labels )