def mark_negation(document, double_neg_flip=False, shallow=False):
 if (not shallow):
  document = deepcopy(document)
 labeled = (document and isinstance(document[0], (tuple, list)))
 if labeled:
  doc = document[0]
 else:
  doc = document
 neg_scope = False
 for (i, word) in enumerate(doc):
  if NEGATION_RE.search(word):
   if ((not neg_scope) or (neg_scope and double_neg_flip)):
    neg_scope = (not neg_scope)
    continue
   else:
    doc[i] += '_NEG'
  elif (neg_scope and CLAUSE_PUNCT_RE.search(word)):
   neg_scope = (not neg_scope)
  elif (neg_scope and (not CLAUSE_PUNCT_RE.search(word))):
   doc[i] += '_NEG'
 return document

def mark_negation ( document , double_neg_flip = False , shallow = False ) : if ( not shallow ) : document = deepcopy ( document ) labeled = ( document and isinstance ( document [ 0 ] , ( tuple , list ) ) ) if labeled : doc = document [ 0 ] else : doc = document neg_scope = False for ( i , word ) in enumerate ( doc ) : if NEGATION_RE . search ( word ) : if ( ( not neg_scope ) or ( neg_scope and double_neg_flip ) ) : neg_scope = ( not neg_scope ) continue else : doc [ i ] += '_NEG' elif ( neg_scope and CLAUSE_PUNCT_RE . search ( word ) ) : neg_scope = ( not neg_scope ) elif ( neg_scope and ( not CLAUSE_PUNCT_RE . search ( word ) ) ) : doc [ i ] += '_NEG' return document
append _neg suffix to words that appear in the scope between a negation and a punctuation mark .