Beispiel #1
0
def loadSentimentValues(catalog, sentimentvaluesfile):
    sentimentvaluesfile = cf.data_dir + sentimentvaluesfile
    input_file = csv.DictReader(open(sentimentvaluesfile, encoding="utf-8"),
                                delimiter=",")
    for hashtag in input_file:
        model.addHashtag(catalog, hashtag)
    return catalog
def loadHashtags(analyzer):
    """
    Carga las etiquetas del archivo csv.
    """
    tagsfile = cf.data_dir + 'subsamples-small/user_track_hashtag_timestamp-small.csv'
    input_file = csv.DictReader(open(tagsfile, encoding='utf-8'))
    for event in input_file:
        model.addHashtag(analyzer, event)
def loadSentimentValues(catalog):
    file = cf.data_dir + sentimentvalues_file
    input_file = csv.DictReader(open(file, encoding='utf-8'))
    for hashtag_leido in input_file:
        hashtag_agregar = {'hashtag': hashtag_leido['hashtag'].lower()}
        if hashtag_leido['vader_avg'] == '':
            hashtag_agregar['vader'] = -1
        else:
            hashtag_agregar['vader'] = float(hashtag_leido['vader_avg'])

        model.addHashtag(catalog, hashtag_agregar)
Beispiel #4
0
def loadSentimentValues(analyzer):
    sentimentFile = cf.data_dir + 'sentiment_values.csv'
    input_file = csv.DictReader(open(sentimentFile, encoding="utf-8"), delimiter=',')

    for line in input_file:
        filtered = {
            'hashtag': (line['hashtag'].lower()).replace(' ', ''),
            'vader': line['vader_avg']
        }

        model.addHashtag(analyzer, filtered)
    return analyzer
def loadHashtags(catalog):
    """
    Carga los hashtags del archivo. Por cada hashtag se toma el único dato necesario:
    el vader promedio.
    """
    videosfile = cf.data_dir + 'sentiment_values.csv'

    input_file = csv.DictReader(open(videosfile, encoding='utf-8'))
    for hashtag in input_file:
        try:
            cada_hashtag = {
                "hashtag": hashtag["hashtag"].lower(),
                "vader_avg": float(hashtag["vader_avg"])
            }
            model.addHashtag(catalog, cada_hashtag)
        except:
            pass
def loadData(catalog):
    delta_time = -1.0
    delta_memory = -1.0

    tracemalloc.start()
    start_time = getTime()
    start_memory = getMemory()

    songfile1 = cf.data_dir + 'Subsamples/user_track_hashtag_timestamp/user_track_hashtag_timestamp-small.csv'
    input_file1 = csv.DictReader(open(songfile1, encoding='utf-8'))
    songfile2 = cf.data_dir + 'Subsamples/context_content_features/context_content_features-small.csv'
    input_file2 = csv.DictReader(open(songfile2, encoding='utf-8'))
    songfile3 = cf.data_dir + 'Subsamples/sentiment_values/sentiment_values1.csv'
    input_file3 = csv.DictReader(open(songfile3, encoding='utf-8'))
    model.createCharact(catalog)
    model.createCharactSong(catalog)
    for dicc in input_file3:
        model.addHashtag(catalog['hashtags'], dicc)
    for song in input_file1:
        model.addTrack(catalog['tracksong'], song)
    lstevent = lt.newList('ARRAY_LIST')
    pos = 0
    for song in input_file2:
        issong = model.songByUserId(catalog, song)
        if issong is not None:
            pos += 1
            if (pos in range(1, 6)) or (pos in range(63229, 63234)):
                lt.addLast(lstevent, model.printEvent(issong))
            model.addSongbyCharact(catalog, issong)
            model.addArtist(catalog['artists'], issong)
            model.addTrackHashtag(catalog['trackhashtag'], issong)
            model.newAddSong(catalog)
    model.addSong(catalog)
    addGenre(catalog, None)

    stop_memory = getMemory()
    stop_time = getTime()
    tracemalloc.stop()

    delta_time = stop_time - start_time
    delta_memory = deltaMemory(start_memory, stop_memory)

    return (lstevent, (delta_time, delta_memory))
def loadData(analyzer, hashtag, sentiments, context):
    """
    Carga los datos de los archivos CSV en el modelo
    """
    hashtagsfile = cf.data_dir + hashtag
    hashtag_file = csv.DictReader(open(hashtagsfile, encoding="utf-8"),
                                  delimiter=",")
    contextfile = cf.data_dir + context
    context_file = csv.DictReader(open(contextfile, encoding="utf-8"),
                                  delimiter=",")
    sentimentsfile = cf.data_dir + sentiments
    sentiments_file = csv.DictReader(open(sentimentsfile, encoding="utf-8"),
                                     delimiter=",")
    for event in context_file:
        model.addEvent(analyzer, event)
    posEvent = 1
    for hastag in hashtag_file:
        posEvent = model.addHashtag(analyzer, hastag, posEvent)

    model.crearArboles(analyzer)

    for sentiment in sentiments_file:
        model.addSentiment(analyzer, sentiment)
    return analyzer
def loadHashtags(catalog):
    hashtagsfile = cf.data_dir + 'sentiment_values.csv'
    input_file = csv.DictReader(open(hashtagsfile, encoding='utf-8'))
    for hashtag in input_file:
        model.addHashtag(catalog, hashtag)
def loadHashtags(cat, hashtags):
    hfile = cf.data_dir + "subsamples-small" + "\\" + hashtags
    input_file = csv.DictReader(open(hfile, encoding="utf-8"), delimiter=",")
    for rep in input_file:
        model.addHashtag(cat, rep)
    print("Se cargó el archivo de Track-Hashtags")