김예미

add sms keyword analysis part(menu2)

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