示例#1
0
文件: main.py 项目: gonzarugil/BD
def setdayinterval(input):
    global dayinterval, news, cedwords
    dayinterval = input
    news = TDM.getDocsFromCsv(dayinterval)
    setcedwords(cedwords)
示例#2
0
文件: main.py 项目: gonzarugil/BD
    dayinterval = input
    news = TDM.getDocsFromCsv(dayinterval)
    setcedwords(cedwords)


# Loading lexicons
positiveLex = Utils.Data.loadLexicon(Config.POS_LEX)
negativeLex = Utils.Data.loadLexicon(Config.NEG_LEX)

# ------------------RETRIEVING DATA --------------------------------------
# Getting the list of news from the csv to do the emotion analysis
dayslist = Utils.Data.getListFromCsv("csv/Days.csv")
dayinterval = makelast30days(dayslist)
# last30days = makelast30days(dayslist)
# last30daysnews = TDM.getDocsFromCsv(last30days)  # it gets the news by day
news = TDM.getDocsFromCsv(dayinterval)
setcedwords(["default", "test"])


def EmotionAnalysis(epsilon, figure):
    global news, CED
    EM.setEpsilon(epsilon)
    # for each new compute the emotional value and show it
    output = []  # output is a list of tuples with [day,CED of that day]
    for i in range(0, len(dayinterval)):
        EM.computeday(news[i], negativeLex, positiveLex, CED)
        output.append([news[i], CED.copy()])
    Graph.plotallfigure(figure, output, dayinterval)
    # after the execution we need to clean the values of the CED so they doesnt iterfere with next execution
    for word in cedwords:
        CED[word] = 0