김예미

add sms keyword analysis part(menu2)

This diff could not be displayed because it is too large.
...@@ -2466,6 +2466,11 @@ ...@@ -2466,6 +2466,11 @@
2466 "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", 2466 "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz",
2467 "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" 2467 "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A=="
2468 }, 2468 },
2469 + "python-shell": {
2470 + "version": "2.0.1",
2471 + "resolved": "https://registry.npmjs.org/python-shell/-/python-shell-2.0.1.tgz",
2472 + "integrity": "sha512-Ys+SiCinY9JrldIJxGWd2AMQSQZLU7PFzrCWY7HTawZ73tIthFdlLLU1Y6Y40Hwdutc+TmfMe5TXNU73s07Xyg=="
2473 + },
2469 "qs": { 2474 "qs": {
2470 "version": "6.5.2", 2475 "version": "6.5.2",
2471 "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", 2476 "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
......
1 +import base64
2 +import sys
3 +import pymysql
4 +
5 +from konlpy.tag import Kkma
6 +
7 +conn=pymysql.connect(host='localhost',user='root',password='1234', db='dataextraction', charset='utf8')
8 +
9 +def select():
10 + curs=conn.cursor()
11 + #sql="select * from calllog"
12 + #sql="select * from contact"
13 + sql="select * from sms"
14 + curs.execute(sql)
15 +
16 + rows=curs.fetchall()
17 + print(rows[0])
18 + #for row in rows:
19 + #analysis_keyword(row[0])
20 +
21 +def analysis_keyword(text):
22 + kkma = Kkma()
23 + result = kkma.nouns(text)
24 + result = str(result)
25 + print(base64.b64encode(result.encode('utf-8')))
26 +
27 +select()
28 +
29 +conn.close()
...\ No newline at end of file ...\ No newline at end of file
1 +import base64
2 +import sys
3 +import pymysql
4 +
5 +from konlpy.tag import Twitter
6 +
7 +conn=pymysql.connect(host='localhost',user='root',password='1234', db='dataextraction', charset='utf8')
8 +
9 +def select():
10 + curs=conn.cursor()
11 + sql="select sms.type, sms.address, sms.date, sms.body, contact.name from sms left join contact on sms.address=contact.number;"
12 + curs.execute(sql)
13 +
14 + rows=curs.fetchall()
15 + for row in rows:
16 + return_data=" "
17 + if row[0]==1:
18 + return_data+="get|"
19 + else:
20 + return_data+="send|"
21 + if row[4] is None:
22 + return_data+=row[1]+" ( - )|"
23 + else:
24 + return_data+=row[1]+" ("+row[4]+")|"
25 + return_data+=row[2].strftime("%Y-%m-%d %H:%M:%S")+"|"
26 + return_data+=row[3]+"|"
27 + analysis_keyword(return_data, row[3])
28 +
29 +def analysis_keyword(return_data, text):
30 + twitter = Twitter()
31 + result = twitter.nouns(text)
32 + result=" ".join(str(x) for x in result)
33 + result=return_data+result
34 + print(base64.b64encode(result.encode('utf-8')))
35 +
36 +select()
37 +
38 +conn.close()
39 +
1 +import base64
2 +import sys
3 +import pymysql
4 +
5 +conn=pymysql.connect(host='localhost',user='root',password='1234', db='dataextraction', charset='utf8')
6 +
7 +def select():
8 + curs=conn.cursor()
9 + sql="drop table if exists sms_bank;"
10 + curs.execute(sql)
11 + sql="create table sms_bank(date datetime not null, bname text, price int, paymentplan text, sname text, primary key (date));"
12 + curs.execute(sql)
13 + sql="select body,date from sms where address in (15881600,16445330,15888900,15881688);"
14 + curs.execute(sql)
15 +
16 + rows=curs.fetchall()
17 + for row in rows:
18 + body=row[0].replace("<재난지원금 사용>\n","").replace("누적",":")
19 + body=" ".join(body.split("\n"))
20 + body_split=body.split(' ')
21 + _bname=body_split[1][:-2]
22 + _price=body_split[3][:-1].replace(",","")
23 + _paymentplan=body_split[4]
24 + _date=row[1].strftime("%Y-%m-%d %H:%M:%S")
25 + _sname=' '.join(body_split[7:])
26 + _sname=_sname.split(":")[0]
27 + curs2=conn.cursor()
28 + sql2="insert into sms_bank(bname, price, paymentplan, date, sname) values (%s, %s, %s, %s, %s);"
29 + curs2.execute(sql2, (_bname, _price, _paymentplan, _date, _sname))
30 + conn.commit()
31 + #print(base64.b64encode("Conplete".encode('utf-8')))
32 +
33 +select()
34 +
35 +conn.close()
36 +
1 +import base64
2 +import sys
3 +import pymysql
4 +
5 +from konlpy.tag import Twitter
6 +from collections import Counter
7 +
8 +conn=pymysql.connect(host='localhost',user='root',password='1234', db='dataextraction', charset='utf8')
9 +
10 +def select():
11 + curs=conn.cursor()
12 + sql="select sms.type, sms.address, sms.date, sms.body, contact.name from sms left join contact on sms.address=contact.number;"
13 + curs.execute(sql)
14 +
15 + rows=curs.fetchall()
16 + data=""
17 + for row in rows:
18 + data+=row[3]
19 +
20 + analysis_keyword(data)
21 +
22 +def analysis_keyword(text):
23 + twitter = Twitter()
24 + result = twitter.nouns(text)
25 + count=Counter(result)
26 + tag_count=[]
27 +
28 + for n, c in count.most_common(20):
29 + dics={'tag':n, 'count':c}
30 + tag_count.append(dics)
31 + for tag in tag_count:
32 + return_data=tag['tag']+"|"+str(tag['count'])
33 + print(base64.b64encode(return_data.encode('utf-8')))
34 +
35 +select()
36 +
37 +conn.close()
38 +
1 +import base64
2 +import sys
3 +import pymysql
4 +
5 +from konlpy.tag import Twitter
6 +from collections import Counter
7 +
8 +conn=pymysql.connect(host='localhost',user='root',password='1234', db='dataextraction', charset='utf8')
9 +
10 +def select():
11 + curs=conn.cursor()
12 + sql="select sms.type, sms.address, sms.date, sms.body, contact.name from sms left join contact on sms.address=contact.number where date between '"+sys.argv[1]+"' and '"+sys.argv[2]+"';"
13 + curs.execute(sql)
14 +
15 + rows=curs.fetchall()
16 + data=""
17 + for row in rows:
18 + data+=row[3]
19 +
20 + analysis_keyword(data)
21 +
22 +def analysis_keyword(text):
23 + twitter = Twitter()
24 + result = twitter.nouns(text)
25 + count=Counter(result)
26 + tag_count=[]
27 +
28 + for n, c in count.most_common(20):
29 + dics={'tag':n, 'count':c}
30 + tag_count.append(dics)
31 + for tag in tag_count:
32 + return_data=tag['tag']+"|"+str(tag['count'])
33 + print(base64.b64encode(return_data.encode('utf-8')))
34 +
35 +select()
36 +
37 +conn.close()
38 +
1 +import base64
2 +import sys
3 +import pymysql
4 +
5 +from konlpy.tag import Twitter
6 +from collections import Counter
7 +
8 +conn=pymysql.connect(host='localhost',user='root',password='1234', db='dataextraction', charset='utf8')
9 +
10 +def select():
11 + curs=conn.cursor()
12 + sql="select sms.type, sms.address, sms.date, sms.body, contact.name from sms left join contact on sms.address=contact.number where timestampdiff(month,now(),sms.date)>-1;"
13 + curs.execute(sql)
14 +
15 + rows=curs.fetchall()
16 + data=""
17 + for row in rows:
18 + data+=row[3]
19 +
20 + analysis_keyword(data)
21 +
22 +def analysis_keyword(text):
23 + twitter = Twitter()
24 + result = twitter.nouns(text)
25 + count=Counter(result)
26 + tag_count=[]
27 +
28 + for n, c in count.most_common(20):
29 + dics={'tag':n, 'count':c}
30 + tag_count.append(dics)
31 + for tag in tag_count:
32 + return_data=tag['tag']+"|"+str(tag['count'])
33 + print(base64.b64encode(return_data.encode('utf-8')))
34 +
35 +select()
36 +
37 +conn.close()
...\ No newline at end of file ...\ No newline at end of file
1 +import base64
2 +import sys
3 +import pymysql
4 +
5 +from konlpy.tag import Twitter
6 +from collections import Counter
7 +
8 +conn=pymysql.connect(host='localhost',user='root',password='1234', db='dataextraction', charset='utf8')
9 +
10 +def select():
11 + curs=conn.cursor()
12 + sql="select sms.type, sms.address, sms.date, sms.body, contact.name from sms left join contact on sms.address=contact.number where address in ("+sys.argv[1]+");"
13 + curs.execute(sql)
14 +
15 + rows=curs.fetchall()
16 + data=""
17 + for row in rows:
18 + data+=row[3]
19 +
20 + analysis_keyword(data)
21 +
22 +def analysis_keyword(text):
23 + twitter = Twitter()
24 + result = twitter.nouns(text)
25 + count=Counter(result)
26 + tag_count=[]
27 +
28 + for n, c in count.most_common(20):
29 + dics={'tag':n, 'count':c}
30 + tag_count.append(dics)
31 + for tag in tag_count:
32 + return_data=tag['tag']+"|"+str(tag['count'])
33 + print(base64.b64encode(return_data.encode('utf-8')))
34 +
35 +select()
36 +
37 +conn.close()
38 +
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.