예제 #1
0
    def create_review(self,text_pos,text_neg):
        postag_pos = pos_tag(word_tokenize(text_pos))
        postag_neg = pos_tag(word_tokenize(text_neg))

        feats_pos = extract_features(postag_pos)
        feats_neg = extract_features(postag_neg)

        positive_data = {'feats':feats_pos, 'text':postag_pos}
        negative_data = {'feats':feats_neg, 'text':postag_neg}

        return Review(revid = -1, positive = positive_data , negative = negative_data )
예제 #2
0
    def read_review(self):
		dao = CorpusReader()
		objects = dao.get_objects()
		lista = []
		
		for postag_pos, postag_neg in zip(objects[0],objects[1]): 
			feats_pos = extract_features(postag_pos)
			feats_neg = extract_features(postag_neg)

			positive_data = {'feats':feats_pos, 'text':postag_pos}
			negative_data = {'feats':feats_neg, 'text':postag_neg}

    		lista.append(Review(revid = -1, positive = positive_data , negative = negative_data ))
    		#yield ({'pos':obj[0],'neg':obj[1]})
		return lista
예제 #3
0
    def create_list_reviews(self,tagged_pos, tagged_neg):
        review_list = []
        count = 0
        print 'creating reviews...' 
                
        for positive_tags, negative_tags in zip(tagged_pos, tagged_neg):
            rev_id = count
            count += 1
            positive_feats = extract_features(positive_tags)
            negative_feats = extract_features(negative_tags) 

            positive = {'feats': positive_feats, 'text': positive_tags}
            negative = {'feats': negative_feats, 'text': negative_tags}

            review_list.append(Review(rev_id, positive, negative))

        return review_list