def encode_document(text, cats=None, id=None):
 text = unicode(text)
 cats = dict(((unicode(cat), bool(is_in_cat)) for (cat, is_in_cat) in (cats or {}).iteritems()))
 return (JSONValueProtocol.write(None, {'text': text, 'cats': cats, 'id': id}) + '\n')

def encode_document ( text , cats = None , id = None ) : text = unicode ( text ) cats = dict ( ( ( unicode ( cat ) , bool ( is_in_cat ) ) for ( cat , is_in_cat ) in ( cats or { } ) . iteritems ( ) ) ) return ( JSONValueProtocol . write ( None , { 'text' : text , 'cats' : cats , 'id' : id } ) + '\n' )
encode a document as a json so that mrtextclassifier can read it .