Ejemplo n.º 1
0
	def singleprocess_datanum(self, test_dict):
		fu = file_util.FileUtil('../AmazonDataBackup/reviewsNew/reviewsNew.mP')
		fu.get_structure()
		for data_num in test_dict.keys():
			print data_num
			content_list = fu.get_content_list()[0:data_num]
			content_list_2_grams = summary_plot.get_2_grams_list(content_list)
			start = time.time()
			jd_list = summary_plot.get_jd_list(content_list_2_grams)
			summary_plot.get_reviews_similarity_relation(jd_list)
			finish_time = time.time() - start
			# print 'finish get relation with %s s' % finish_time
			test_dict[data_num] = finish_time
		# test_dict = collections.OrderedDict(sorted(test_dict.items()))
		return test_dict
Ejemplo n.º 2
0
 def singleprocess_datanum(self, test_dict):
     fu = file_util.FileUtil('../AmazonDataBackup/reviewsNew/reviewsNew.mP')
     fu.get_structure()
     for data_num in test_dict.keys():
         print data_num
         content_list = fu.get_content_list()[0:data_num]
         content_list_2_grams = summary_plot.get_2_grams_list(content_list)
         start = time.time()
         jd_list = summary_plot.get_jd_list(content_list_2_grams)
         summary_plot.get_reviews_similarity_relation(jd_list)
         finish_time = time.time() - start
         # print 'finish get relation with %s s' % finish_time
         test_dict[data_num] = finish_time
     # test_dict = collections.OrderedDict(sorted(test_dict.items()))
     return test_dict
Ejemplo n.º 3
0
def write_jd_dict_to_file(q, l, m, name):
    print 'starting process %s' % name
    while True:
        l.acquire()
        if q.empty():
            l.release()
            continue
        else:
            filename = q.get()
            if filename == 'STOP':
                print 'process', name, ' exit'
                l.release()
                break
            l.release()
            with open(filename) as fp:
                sub_list = ast.literal_eval(fp.read())
                rs_relation_dict = summary_plot.get_reviews_similarity_relation(
                    sub_list)
                l.acquire()
                print 'process ', name, str(rs_relation_dict)
                for feedback, num in rs_relation_dict.iteritems():
                    if feedback not in m.keys():
                        m[feedback] = 0
                    m[feedback] += num
                l.release()
Ejemplo n.º 4
0
def draw_graph(dirname, title, xlabel, ylabel):
    jd_list = []
    jd_dict = {}
    for (dirpath, dirnames, filenames) in walk(dirname):
        for filename in filenames:
            if not filename.startswith("."):
                print filename
                with open(dirname + "/" + filename) as fp:
                    sub_list = ast.literal_eval(fp.read())
                    rs_relation_dict = summary_plot.get_reviews_similarity_relation(sub_list)
                    for feedback, num in rs_relation_dict.iteritems():
                        if feedback not in jd_dict.keys():
                            jd_dict[feedback] = 0
                        jd_dict[feedback] += num
                        # jd_list += sub_list
                # print len(jd_list)
    print jd_dict
Ejemplo n.º 5
0
def draw_graph(dirname, title, xlabel, ylabel):
    jd_list = []
    jd_dict = {}
    for (dirpath, dirnames, filenames) in walk(dirname):
        for filename in filenames:
            if not filename.startswith('.'):
                print filename
                with open(dirname + '/' + filename) as fp:
                    sub_list = ast.literal_eval(fp.read())
                    rs_relation_dict = summary_plot.get_reviews_similarity_relation(
                        sub_list)
                    for feedback, num in rs_relation_dict.iteritems():
                        if feedback not in jd_dict.keys():
                            jd_dict[feedback] = 0
                        jd_dict[feedback] += num
                    # jd_list += sub_list
    # print len(jd_list)
    print jd_dict
Ejemplo n.º 6
0
def write_jd_dict_to_file(q, l, m, name):
    print "starting process %s" % name
    while True:
        l.acquire()
        if q.empty():
            l.release()
            continue
        else:
            filename = q.get()
            if filename == "STOP":
                print "process", name, " exit"
                l.release()
                break
            l.release()
            with open(filename) as fp:
                sub_list = ast.literal_eval(fp.read())
                rs_relation_dict = summary_plot.get_reviews_similarity_relation(sub_list)
                l.acquire()
                print "process ", name, str(rs_relation_dict)
                for feedback, num in rs_relation_dict.iteritems():
                    if feedback not in m.keys():
                        m[feedback] = 0
                    m[feedback] += num
                l.release()