Example #1
0
username = urllib.parse.quote_plus('')
password = urllib.parse.quote_plus('')

client = MongoClient('' % (username, password))
db = client.twichu
UserTweets = db.userstweets
Users = db.users
Tweets = db.tweets
p = re.compile(r'https?://.+', re.DOTALL)
g = re.compile(r'@\S+\s')
chinese = re.compile(u'[⺀-⺙⺛-⻳⼀-⿕々〇〡-〩〸-〺〻㐀-䶵一-鿃豈-鶴侮-頻並-龎]', re.UNICODE)
japanese = re.compile(u'[\u3000-\u303f\u3040-\u309f\u30a0-\u30ff\uff00-\uff9f\u4e00-\u9faf\u3400-\u4dbf]', re.UNICODE)
# while True:
UserTweetsCursor = UserTweets.find({})
TweetsCursor = Tweets.find({})
TDM.init()

for TweetDocument in TweetsCursor:
    dict = dumps(TweetDocument)
    dict = json.loads(dict)
    if dict['isAnalyzing'] == True:
        Tweets.update_one(
            {'_id': ObjectId(dict['_id']['$oid'])},
            {
                '$set': {
                    'cate_keyword': TDM.twitter_to_keyword(dict['tweet']),
                    'isAnalyzing': False
                }
            }, upsert=False
        )
# 트렌드를 순회하는 부분
Example #2
0
import Utils
import TDM
import Config

feed = Utils.Rss.getrss(Config.RSS_URL)
# Retrieve the days of the news in a list **** This has to be saved along with the titles
dayslist = Utils.Rss.getrssdays(feed)
TDM.writeDaysList(dayslist)
# Getting a list of the titles (this is unused)
titlelist = []
for entry in feed["entries"]:
    titlelist.append(entry["title"])

TDM.writeTitleList(titlelist)
# Retrieve all news from feed and save them to csv
TDM.saveallcsv(feed, dayslist)
Example #3
0
def setdayinterval(input):
    global dayinterval, news, cedwords
    dayinterval = input
    news = TDM.getDocsFromCsv(dayinterval)
    setcedwords(cedwords)
Example #4
0
import socket
from TDM import *
import time
"""-----------------------------------------------------------------------"""

tdm = TDM()

n = int(input("Ingrese el numero de entradas : "))
tdm.add_sources(n)
for i in range(n):  #Ingresa mensajes para N canales
    message = input("Ingrese un mensaje : ")
    tdm.add_msj(message)

#Ingresar sincronizacion
#Ingresar unidad

to_send = tdm.mux()

print(to_send)
"""socket"""

IP = '127.0.0.1'
PORT = 3000
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  #Descriptor
sock.connect((IP, PORT))
print("connecting to %s with %s", IP, PORT)
i = 0
print(len(to_send))
for bit in to_send:
    #print("...")
    #print(i)
Example #5
0
    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