Beispiel #1
0
def load_blog(conn):
    cursor = conn.cursor()
    cursor.execute("select a.blogid, a.uid, a.subject, a.dateline, b.message from ihome_blog a left join ihome_blogfield b on a.blogid = b.blogid")
    rows = cursor.fetchall()
    for row in rows:
        parts = []
        if row[2]:
            parts = SegUtil.seg(row[2].encode("utf8"))
        if row[4]:
            parts.extend(SegUtil.seg(row[4].encode("utf8")))
        for p in parts:
            if p[1] == 'ns' or p[1] == 'nr' or p[1] == 'nt' or p[1] == 'n':
                if p[0] not in tags:
                    tags[p[0]] = [0, 0, 0]
                tags[p[0]][0] += 1
                tags[p[0]][1] += 1

    cursor.close()
Beispiel #2
0
def load_blog(conn):
    cursor = conn.cursor()
    cursor.execute("select a.blogid, a.uid, a.subject, a.dateline, b.message from ihome_blog a left join ihome_blogfield b on a.blogid = b.blogid where a.dateline > %d" % start_time)
    rows = cursor.fetchall()
    for row in rows:
        parts = []
        if row[2]:
            parts = SegUtil.seg(row[2].encode("utf8"))
        if row[4]:
            parts.extend(SegUtil.seg(row[4].encode("utf8")))
        for p in parts:
            if p[1] == 'ns' or p[1] == 'nr' or p[1] == 'nt' or p[1] == 'n':
                if len(p[0]) <= 0:
                    continue
                if p[0] not in tags:
                    tags[p[0]] = [0, 0, 0]
                tags[p[0]][0] += 1
                tags[p[0]][1] += 1

    cursor.close()
def load_complain(conn,date):
	cursor = conn.cursor()
	cursor.execute("select doid,uid,message,datatime from ihome_complain where datatime="+date)
	rows = cursor.fetchall()
	for row in rows:
		parts = []
		if row[2]:
			parts = SegUtil.seg(row[2].encode("utf8"))
		for p in parts:
			if p[1] == 'ns' or p[1] == 'nr' or p[1] == 'nt' or p[1] == 'n':
				if p[0] not in tags:
					tags[p[0]] = [0, 0, 0]
				tags[p[0]][0] += 1
				tags[p[0]][2] += 1
	cursor.close()
Beispiel #4
0
def load_complain(conn):
	cursor = conn.cursor()
	cursor.execute("select doid,uid,message,addtime from ihome_complain ")
	rows = cursor.fetchall()
	for row in rows:
		parts = []
		if row[2]:
			parts = SegUtil.seg(row[2].encode("utf8"))
		for p in parts:
			if p[1] == 'ns' or p[1] == 'nr' or p[1] == 'nt' or p[1] == 'n':
				if p[0] not in tags:
					tags[p[0]] = [0, 0, 0]
				tags[p[0]][0] += 1
				tags[p[0]][2] += 1


	cursor.close()
Beispiel #5
0
def load_doing(conn):
    cursor = conn.cursor()
    cursor.execute(
        "select a.doid, a.uid, a.message, a.dateline from ihome_doing a")
    rows = cursor.fetchall()
    for row in rows:
        parts = []
        if row[2]:
            parts = SegUtil.seg(row[2].encode("utf8"))
        for p in parts:
            if p[1] == 'ns' or p[1] == 'nr' or p[1] == 'nt' or p[1] == 'n':
                if p[0] not in tags:
                    tags[p[0]] = [0, 0, 0]
                tags[p[0]][0] += 1
                tags[p[0]][2] += 1

    cursor.close()
Beispiel #6
0
def load_doing(conn):
    cursor = conn.cursor()
    cursor.execute("select a.doid, a.uid, a.message, a.dateline from ihome_doing a")
    rows = cursor.fetchall()
    for row in rows:
        parts = []
        if row[2]:
            parts = SegUtil.seg(row[2].encode("utf8"))
        for p in parts:
            if p[1] == 'ns' or p[1] == 'nr' or p[1] == 'nt' or p[1] == 'n':
                if p[0] not in tags:
                    tags[p[0]] = [0, 0, 0]
                tags[p[0]][0] += 1
                tags[p[0]][2] += 1


    cursor.close()
Beispiel #7
0
			if p[1] == 'ns' or p[1] == 'nr' or p[1] == 'nt' or p[1] == 'n':
				if p[0] not in tags:
					tags[p[0]] = [0, 0, 0]
				tags[p[0]][0] += 1
				tags[p[0]][2] += 1


	cursor.close()





if __name__ == '__main__':
	conn = MySQLdb.connect(host="localhost", user='******', passwd='nameLR9969', db='ihome', port=3306, charset='utf8')
	SegUtil.init('.')
	load_complain(conn)

	h = []

	for k,v in tags.iteritems():
		if len(h) < 100:
			heapq.heappush(h, (v, k))
		else:
			heapq.heappushpop(h, (v, k))

	cursor = conn.cursor()
	lastid = -1
	results = []
	while len(h) > 0:
		num, word = heapq.heappop(h)