Exemplo n.º 1
0
def plotMonthlyTrend(keywords, title, monthList):
    db = mysql(host, user, passwd, dbName)
    db.connect()
    allKeywordTrend = []
    for k in keywords:
        allCount = []
        for m in monthList:
            rows = db.getMonthlyKeywordCount(k, m)
            print rows
            count = 0
            for r in rows:
                count += r[0]
            persent = count * 1.0
            cc = db.getMonthlyTweetCount(m)
            if cc == 0:
                persent = 0.0
            else:
                persent /= cc
            allCount.append(persent)
        allKeywordTrend.append(allCount)
    db.close()

    for p in allKeywordTrend:
        pylab.plot(range(1, len(p) + 1), p)
    pylab.title(title)
    pylab.legend(keywords)
    pylab.xlabel("month")
    pylab.ylabel("frequency of occurrence")
    pylab.show()
Exemplo n.º 2
0
def plotMonthlyTrend(keywords, title, monthList):
    db = mysql(host, user, passwd, dbName)
    db.connect()
    allKeywordTrend = []
    for k in keywords:
        allCount = []
        for m in monthList:
            rows = db.getMonthlyKeywordCount(k, m)
            print rows
            count = 0
            for r in rows:
                count += r[0]
            persent = count*1.0
            cc = db.getMonthlyTweetCount(m)
            if cc == 0:
                persent = 0.0
            else:
                persent /= cc
            allCount.append(persent)
        allKeywordTrend.append(allCount)
    db.close()

    for p in allKeywordTrend:
        pylab.plot(range(1, len(p)+1), p)
    pylab.title(title)
    pylab.legend(keywords)
    pylab.xlabel("month")
    pylab.ylabel("frequency of occurrence")
    pylab.show()
Exemplo n.º 3
0
        # 发送邮件
        yag.send(users, subjecttitle, contents, file)
        # yag.send('*****@*****.**', '发送附件', contents, ["d://testresult.html"])


x = sendmail()
# # 邮箱正文
contents = [
    'This is the body, and here is just text http://somedomain/image.png',
    'You can find an audio file attached.', '/local/path/song.mp3'
]
x.sendmail('*****@*****.**', '发送邮件', contents)
# x.sendmailFile('*****@*****.**', '发送带附件的邮件', contents, ["D:/htmlOut2018-06-22.html"])

m = mysql()
m.insertSql()

# 成功的例子
# yag = yagmail.SMTP(user="******", password="******", host='smtp.163.com')
#
#
# # 邮箱正文
# contents = ['This is the body, and here is just text http://somedomain/image.png',
#             'You can find an audio file attached.', '/local/path/song.mp3']
#
# # 发送邮件
# yag.send('*****@*****.**', 'subject', contents)
#
# #给多个用户发送邮件#
# # 发送邮件
Exemplo n.º 4
0
def saveMonthlyTweetCount(monthList):
    db = mysql(host, user, passwd, dbName)
    db.connect()
    for m in monthList:
        db.computeAndSaveMonthlyTweetCount(m)
    db.close()
Exemplo n.º 5
0
 def __init__(self):
     self.db = mysql()
     self.db.connect()
Exemplo n.º 6
0
reload(sys)
sys.setdefaultencoding('utf-8')


def generateDateList(startYear, count):
    monthList = []
    for y in xrange(count):
        for m in xrange(1, 13):
            pattern = "%d-%d-01" % (startYear + y, m)
            monthList.append(pattern)
    return monthList


monthList = generateDateList(2006, 9)

for m in monthList:
    ana = analyser()
    db = mysql(host, user, passwd, dbName)
    db.connect()
    print "processing %s data..." % m
    for r in db.getMonthlyData(m):
        if (type(r[0]) == type(u' ')):
            ana.addAnalysisSentence(r[0])
    for k in ana.wordRate.keys():
        try:
            db.insertKeyword2DB(k, str(ana.wordRate[k]), m)
        except:
            continue
    db.close()
Exemplo n.º 7
0
 def __init__(self):
   self.c = mysql()
   return
Exemplo n.º 8
0
import MySQLdb
import io

reload(sys)
sys.setdefaultencoding('utf-8')

def generateDateList(startYear, count):
    monthList = []
    for y in xrange(count):
        for m in xrange(1, 13):
            pattern = "%d-%d-01" % (startYear+y, m)
            monthList.append(pattern)
    return monthList

monthList = generateDateList(2006, 9)

for m in monthList:
    ana = analyser()
    db = mysql(host, user, passwd, dbName)
    db.connect()
    print "processing %s data..." % m
    for r in db.getMonthlyData(m):
        if (type(r[0]) == type(u' ')):
            ana.addAnalysisSentence(r[0])
    for k in ana.wordRate.keys():
        try:
            db.insertKeyword2DB(k, str(ana.wordRate[k]), m)
        except:
            continue
    db.close()
Exemplo n.º 9
0
def saveMonthlyTweetCount(monthList):
    db = mysql(host, user, passwd, dbName)
    db.connect()
    for m in monthList:
        db.computeAndSaveMonthlyTweetCount(m)
    db.close()