Skip to content

Commit

Permalink
add back system UI
Browse files Browse the repository at this point in the history
  • Loading branch information
AyiStar committed Jun 30, 2018
1 parent f2b6c9c commit d29f608
Show file tree
Hide file tree
Showing 12 changed files with 369 additions and 57 deletions.
22 changes: 3 additions & 19 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,5 @@
# TODO List

## 识别

* KNN算法的利用

## 爬虫

* 时间的转换
* 检测微博是否更新

## GUI

* 录入微博功能
* 即时显示词云

## 陌生人

* 记录陌生人的照片
* 记录今天见过几次
* 一键展示
1. 词云形状
2. 微博的时间问题
3. 表格横向滚动轴
Empty file added fdr/__init__.py
Empty file.
3 changes: 1 addition & 2 deletions fdr/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import os
import sys
import time
import pickle
import multiprocessing as mp
import threading
Expand Down Expand Up @@ -587,5 +586,5 @@ def __init__(self, db_user, db_passwd, db_name, change_queue):

if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
main_GUI = MainWindow('ayistar', '', 'FDR', video=1)
main_GUI = MainWindow('ayistar', '', 'FDR', video=0)
sys.exit(app.exec_())
13 changes: 8 additions & 5 deletions fdr/gui_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,16 @@ def stranger_entry_process(db_user, db_passwd, db_name, person_name, image, q_ch




def weibo_entry_process(db_user, db_passwd, db_name, person_name, weibo_user_name):
cookie = {
"Cookie": '_T_WM=897a5cddc91313eb40a4d44efe82c041; SUB=_2A252B5M7DeRhGeRG6FsQ9SzPwjyIHXVVCz1zrDV6PUJbkdANLU7ykW1NUjSIDKEeHdnG6F3Owi33LiKgDU1zYT28; SUHB=0z1R34lEPLCsQs; SCF=Aurel-CXoF707U2FuZTejk20gZCmrDS1Ehi56ro6GtPtrzKDJCFJ88uDcB_NcEOZDfXZ7KHA6niumfXCilyuTXs.; SSOLoginState=1526981485; M_WEIBOCN_PARAMS=uicode%3D20000174%26featurecode%3D20000320%26fid%3Dhotword; MLOGIN=1',
"Cookie": '_T_WM=46ac77aa23a8c1ecba62cea35d74782a; SUB=_2A252M0H0DeRhGeBP6FcU8CbEwzyIHXVV3G-8rDV6PUJbkdANLW_9kW1NRU6EfTCytvr8Jijab7SH2IrbDcZ6rBBK; SUHB=0M2Vamy4SBy7uA; SCF=ArZJ2F9V-QuNENdMfe1ebva5AQUlf13tiq0ofE3CYdI9N-YhR3ydNMtVgWq23eD_wmj5kfNH_2EvoD_QMK9eCJg.; M_WEIBOCN_PARAMS=luicode%3D10000011%26lfid%3D102803_ctg1_8999_-_ctg1_8999_home; MLOGIN=1',
}
wb = WeiboClient(cookie=cookie, db_user=db_user, db_passwd=db_passwd, db_name=db_name)
wb = weibo_utils.WeiboClient(cookie=cookie, db_user=db_user, db_passwd=db_passwd, db_name=db_name)
uid = wb.get_uid(weibo_user_name)
if uid is not None:
#if wb.save_info(person_name, weibo_user_name, uid) == True:
wb.save_info(person_name, weibo_user_name, uid)
wb.get_weibo([uid])
ws = WeiboStat(db_user, db_passwd, db_name)
ws = stat_utils.WeiboStat(db_user, db_passwd, db_name)
ws.get_text(uid)
ws.word_stat()
ws.generate_word_cloud(pic_path='./data/wordcloud/', weibo_user_name=weibo_user_name)
Expand Down Expand Up @@ -284,7 +283,11 @@ def delete_person(db_user, db_passwd, db_name, person_id):

def alter_person(db_user, db_passwd, db_name, person_id, alter_name):
db_conn = MySQLdb.connect(user=db_user, passwd=db_passwd, db=db_name)
db_conn.set_character_set('utf8')
cursor = db_conn.cursor()
cursor.execute('SET NAMES utf8;')
cursor.execute('SET CHARACTER SET utf8;')
cursor.execute('SET character_set_connection=utf8;')

cursor.execute('SELECT name FROM Persons WHERE person_ID=%s', (person_id,))
origin_name = cursor.fetchone()[0]
Expand Down
Binary file added fdr/resources/icons/exit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fdr/resources/icons/refresh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fdr/resources/icons/search.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 10 additions & 1 deletion fdr/resources/stop_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,16 @@ sup
视频
微博
收藏
点赞
http
https
com
cn
cn
iPhone
浏览器
weibo
2018
2017
2016
2015
8 changes: 5 additions & 3 deletions fdr/stat_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ def word_stat(self):

def generate_word_cloud(self, pic_path=None, weibo_user_name=None):
mask_img = np.array(Image.open('./resources/icons/person.png'))
word_cloud = WordCloud(font_path='./resources/font.ttf', relative_scaling=.5, mask=mask_img,
background_color='white')
word_cloud = WordCloud(font_path='./resources/font.ttf', relative_scaling=.5,
width=640, height=480,
background_color='black')
word_cloud.generate_from_frequencies(self.word_stat)

if (pic_path is not None) and (weibo_user_name is not None):
plt.imshow(word_cloud, interpolation='bilinear')
plt.axes([0,0,1,1])
plt.imshow(word_cloud, interpolation='nearest')
plt.axis('off')
path = pic_path + '/' + weibo_user_name + '.jpg'
plt.savefig(path)
Expand Down
Loading

0 comments on commit d29f608

Please sign in to comment.