def load_data_and_labels(positive_data_file, negative_data_file):
 positive_examples = list(open(positive_data_file, 'r').readlines())
 positive_examples = [s.strip() for s in positive_examples]
 negative_examples = list(open(negative_data_file, 'r').readlines())
 negative_examples = [s.strip() for s in negative_examples]
 x_text = (positive_examples + negative_examples)
 x_text = [clean_str(sent) for sent in x_text]
 positive_labels = [[0, 1] for _ in positive_examples]
 negative_labels = [[1, 0] for _ in negative_examples]
 y = np.concatenate([positive_labels, negative_labels], 0)
 return [x_text, y]

def load_data_and_labels ( positive_data_file , negative_data_file ) : positive_examples = list ( open ( positive_data_file , 'r' ) . readlines ( ) ) positive_examples = [ s . strip ( ) for s in positive_examples ] negative_examples = list ( open ( negative_data_file , 'r' ) . readlines ( ) ) negative_examples = [ s . strip ( ) for s in negative_examples ] x_text = ( positive_examples + negative_examples ) x_text = [ clean_str ( sent ) for sent in x_text ] positive_labels = [ [ 0 , 1 ] for _ in positive_examples ] negative_labels = [ [ 1 , 0 ] for _ in negative_examples ] y = np . concatenate ( [ positive_labels , negative_labels ] , 0 ) return [ x_text , y ]
loads mr polarity data from files .