def process_text(text, dic, r, grams):
 X = lil_matrix((len(text), len(dic)))
 for (i, l) in enumerate(text):
  tokens = tokenize(l, grams)
  indexes = []
  for t in tokens:
   try:
    indexes += [dic[t]]
   except KeyError:
    pass
  indexes = list(set(indexes))
  indexes.sort()
  for j in indexes:
   X[(i, j)] = r[j]
 return csr_matrix(X)

def process_text ( text , dic , r , grams ) : X = lil_matrix ( ( len ( text ) , len ( dic ) ) ) for ( i , l ) in enumerate ( text ) : tokens = tokenize ( l , grams ) indexes = [ ] for t in tokens : try : indexes += [ dic [ t ] ] except KeyError : pass indexes = list ( set ( indexes ) ) indexes . sort ( ) for j in indexes : X [ ( i , j ) ] = r [ j ] return csr_matrix ( X )
return sparse feature matrix .