def addCapitalToList(analyzer, country, vertexname):
    lt.addLast(analyzer['landingPointsCapital'], (country, vertexname))
    return
def addSentiment(analyzer, sentiment):
    if sentiment['vader_avg'] != '':
        tple= (sentiment['hashtag'],sentiment['vader_avg'])
        lt.addLast(analyzer['sentiment'],tple)
def añadir_evento_AY(values,lst):
    for valor in lt.iterator(values):
        lt.addLast(lst,valor)
Exemple #4
0
def requerimiento5(info, diccio, diccion, rangoinf, rangomay):
    vaya = lt.newList()
    senti = mp.valueSet(diccion["sentimiento"])
    primero = it.newIterator(senti)
    while it.hasNext(primero):
        pasando = it.next(primero)

        lt.addLast(vaya, pasando)

    diccionarioo = mp.newMap()
    dumar = om.values(diccio["fecha"], rangoinf, rangomay)
    iteradorr = it.newIterator(dumar)
    while it.hasNext(iteradorr):
        act = it.next(iteradorr)
        iterardent = it.newIterator(act)
        while it.hasNext(iterardent):
            actuales = it.next(iterardent)
            id = actuales["created_at"]
            if not mp.contains(diccionarioo, id):
                mp.put(diccionarioo, id, actuales)

    gene = tablageneros("Metal")
    llave = mp.get(gene, "Metal")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma = 0
    diccionarios = mp.newMap()

    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma += 1

    gene = tablageneros("Rock")
    llave = mp.get(gene, "Rock")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma2 = 0
    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma2 += 1

    gene = tablageneros("Pop")
    llave = mp.get(gene, "Pop")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma3 = 0
    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma3 += 1

    gene = tablageneros("Chill-out")
    llave = mp.get(gene, "Chill-out")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma4 = 0
    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma4 += 1

    gene = tablageneros("Hip Hop")
    llave = mp.get(gene, "Hip Hop")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma5 = 0
    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma5 += 1
    gene = tablageneros("Down-tempo")
    llave = mp.get(gene, "Down-tempo")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma6 = 0
    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma6 += 1
    gene = tablageneros("Reggae")
    llave = mp.get(gene, "Reggae")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma7 = 0
    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma7 += 1
    gene = tablageneros("Jazz and Funk")
    llave = mp.get(gene, "Jazz and Funk")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma8 = 0
    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma8 += 1
    gene = tablageneros("R&B")
    llave = mp.get(gene, "R&B")
    valor = me.getValue(llave)
    rango3 = om.values(info["generos"], valor[0], valor[1])
    iterador = it.newIterator(rango3)
    suma9 = 0
    while it.hasNext(iterador):
        actu = it.next(iterador)
        iterardentro = it.newIterator(actu)
        while it.hasNext(iterardentro):
            actual = it.next(iterardentro)
            if mp.contains(diccionarioo, actual["created_at"]):
                suma9 += 1

    total = suma + suma2 + suma3 + suma4 + suma5 + suma6 + suma7 + suma8 + suma9

    return suma, suma2, suma3, suma4, suma5, suma6, suma7, suma8, suma9, total, diccionarioo
Exemple #5
0
        dan_max = float(input("Introduzca el máximo de danceabilidad: "))
        resultado = controller.req_2(catalog, en_min, en_max, dan_min, dan_max)
        print("{} canciones".format(resultado[0]))
        print_req_2(resultado[1])
    elif int(inputs[0]) == 4:
        inst_min = float(input("Introduzca el mínimo de instrumentalidad: "))
        inst_max = float(input("Introduzca el máximo de instrumentalidad: "))
        temp_min = float(input("Introduzca el mínimo de tempo: "))
        temp_max = float(input("Introduzca el máximo de tempo: "))
        resultado = controller.req_3(catalog, inst_min, inst_max, temp_min,
                                     temp_max)
        print("{} canciones".format(resultado[0]))
        print_req_3(resultado[1])
    elif int(inputs[0]) == 5:
        genero = "t"
        generos = lt.newList()
        while True:
            genero = input("Introduzca el género o deje vacío para terminar: ")
            if not genero:
                break
            lt.addLast(generos, genero)
        resultado = controller.req_4(catalog, generos)
        print_req_4(resultado)
    elif int(inputs[0]) == 6:
        resultado = controller.req_5(catalog)
        print_req_5(resultado[0])
        print("{} es el máximo con {} reproducciones".format(*resultado[1]))
    else:
        sys.exit(0)
sys.exit(0)
def addBookTag(catalog, booktag):
    """
    Adiciona un tag a la lista de tags
    """
    t = newBookTag(booktag['tag_id'], booktag['goodreads_book_id'])
    lt.addLast(catalog['book_tags'], t)
Exemple #7
0
def requerimiento3(dicci, i1, i2, t1, t2):

    d = om.values(dicci["instrumentalness"], i1, i2)
    diccionario = mp.newMap()

    iterador = it.newIterator(d)

    while it.hasNext(iterador):

        actual = it.next(iterador)

        ite = it.newIterator(actual)

        while it.hasNext(ite):

            actual = it.next(ite)

            if float(actual["tempo"]) >= t1 and float(actual["tempo"]) <= t2:

                if mp.contains(diccionario, actual["track_id"]):

                    ola = mp.get(diccionario, actual["track_id"])
                    listo = me.getValue(ola)

                    lt.addLast(listo, actual)

                else:

                    listo = lt.newList()
                    mp.put(diccionario, actual["track_id"], listo)
                    lt.addLast(listo, actual)

    alejita = mp.size(diccionario)

    spiderman = mp.valueSet(diccionario)

    jefa = lt.size(spiderman)

    besos = random.randint(1, jefa)
    pecas = random.randint(1, jefa)
    bruno = random.randint(1, jefa)
    armando = random.randint(1, jefa)

    jamaica = lt.getElement(spiderman, besos)
    sos = lt.getElement(spiderman, pecas)
    xavi = lt.getElement(spiderman, bruno)
    armando = lt.getElement(spiderman, armando)

    pelea = jamaica["first"]["info"]
    sos = sos["first"]["info"]
    xavi = xavi["first"]["info"]
    armando = armando["first"]["info"]

    pelele = ("Track 1: " + str(pelea["track_id"]) +
              " with instrumentalness of " + str(pelea["instrumentalness"]) +
              "  and tempo of " + str(pelea["tempo"]))
    messi = ("Track 1: " + str(sos["track_id"]) +
             " with instrumentalness of " + str(sos["instrumentalness"]) +
             "  and tempo of " + str(sos["tempo"]))
    xavi = ("Track 1: " + str(xavi["track_id"]) +
            " with instrumentalness of " + str(xavi["instrumentalness"]) +
            "  and tempo of " + str(xavi["tempo"]))
    armando = ("Track 1: " + str(armando["track_id"]) +
               " with instrumentalness of " +
               str(armando["instrumentalness"]) + "  and tempo of " +
               str(armando["tempo"]))

    pep = (messi, pelele, xavi, armando)

    return alejita, pep
def subListVideos_porTag(tad_lista, tag: str):
    sublist = lt.newList(datastructure=tad_lista['type'])
    for video in lt.iterator(tad_lista):
        if video_tiene_tag(video, tag):
            lt.addLast(sublist, video)
    return sublist
def addVideo(catalog, video):
    # Se adiciona el video a la lista de videos
    lt.addLast(catalog['videos'], video)
    mp.put(catalog['VideosPorId'], video['video_id'], video)
    addVideo_a_Categoria(catalog, video)
def addPais(catalog, pais):
    # Se adiciona el pais a la lista de paises
    lt.addLast(catalog['paises'], pais)
def subListVideos_porPais(tad_lista, pais: str):
    sublist = lt.newList(datastructure=tad_lista['type'])
    for video in lt.iterator(tad_lista):
        if video['country'] == pais:
            lt.addLast(sublist, video)
    return sublist
def addCountry(analyzer, country):
    lt.addLast(analyzer['countries'], country)
    #m.put(analyzer['countries'], country['CountryName'], country)
    return
def addConnectionList(analyzer, connection):
    lt.addLast(analyzer['connectionsList'], connection)
    return
def addLandingPoint(analyzer, landingPoint):
    lt.addLast(analyzer['landingPointsGeo'], landingPoint)
    #m.put(analyzer['landingPointsGeo'], landingPoint['landing_point_id'], landingPoint)
    return
def addCategory(catalog, category):

    c = newCategory(category["name"], category["id"])
    lt.addLast(catalog["categories"], c)
Exemple #16
0
def Recomendar_rutas(grafo, rango_edad):

    mayor_salida = 0
    mayor_llegada = 0
    estacion_salida = None
    estacion_llegada = None
    lista = m.keySet(grafo["Estaciones"])
    iterador = it.newIterator(lista)
    while it.hasNext(iterador):
        elemento = it.next(iterador)
        entry = m.get(grafo["Estaciones"], elemento)

        valor = me.getValue(entry)

        entry_salida = om.get(valor["Edades_salida"], rango_edad)
        entry_llegada = om.get(valor["Edades_llegada"], rango_edad)
        cant_edades_salida = None
        cant_edades_llegada = None
        if entry_salida is not None:
            cant_edades_salida = me.getValue(entry_salida)
        if entry_llegada is not None:
            cant_edades_llegada = me.getValue(entry_llegada)
        if cant_edades_salida is not None:
            if cant_edades_salida >= mayor_salida:
                mayor_salida = cant_edades_salida
                estacion_salida = elemento
        if cant_edades_llegada is not None:
            if cant_edades_llegada >= mayor_llegada:
                mayor_llegada = cant_edades_llegada
                estacion_llegada = elemento

    if estacion_salida == None and estacion_llegada == None:
        return None, None, None, None
    else:
        path = djk.Dijkstra(grafo["graph"], estacion_salida)
        path_ = djk.pathTo(path, estacion_llegada)
        costo = djk.distTo(path, estacion_llegada)

        estaciones = grafo["Estaciones"]

        entry_sal = m.get(estaciones, estacion_salida)
        entry_lle = m.get(estaciones, estacion_llegada)

        estacion_sali = me.getValue(entry_sal)["Nombre"]
        estacion_lleg = me.getValue(entry_lle)["Nombre"]

        lista2 = lt.newList("ARRAY_LIST", comparar_esta)
        while (not st.isEmpty(path_)):
            stop = st.pop(path_)
            entryA = m.get(estaciones, stop["vertexA"])
            estacion_1 = me.getValue(entryA)["Nombre"]
            if lt.isPresent(lista2, estacion_1) == 0:
                lt.addLast(lista2, estacion_1)

            entryB = m.get(estaciones, stop["vertexB"])
            estacion_2 = me.getValue(entryB)["Nombre"]
            if lt.isPresent(lista2, estacion_2) == 0:

                lt.addLast(lista2, estacion_2)

    if estacion_sali == estacion_lleg:
        return 0, estacion_sali, estacion_lleg, costo
    else:
        return lista2, estacion_sali, estacion_lleg, costo
def addTag(catalog, tag):
    """
    Adiciona un tag a la lista de tags
    """
    t = newTag(tag['tag_name'], tag['tag_id'])
    lt.addLast(catalog['tags'], t)
Exemple #18
0
def Ruta_turistica_circular(graph, tiempo, estacion_inicio):

    Tiempo = float(tiempo) * 60
    kosa = scc.KosarajuSCC(graph["graph"])
    est_k_idscc = kosa["idscc"]
    dfs_recor = dfs.DepthFirstSearchsSCC(graph["graph"], estacion_inicio,
                                         est_k_idscc)

    Lista = m.keySet(dfs_recor["visited"])
    iterador = it.newIterator(Lista)
    L2 = lt.newList()
    while it.hasNext(iterador):
        element = it.next(iterador)
        camino = None
        if dfs.hasPathTo(dfs_recor, element):
            vertices = gr.adjacents(graph["graph"], element)

            it2 = it.newIterator(vertices)
            while it.hasNext(it2):
                elemento2 = it.next(it2)
                if elemento2 == estacion_inicio:
                    camino = dfs.pathTo(dfs_recor, element)
            if camino != None:
                lt.addLast(L2, camino)

    lista_rutas = lst = lt.newList("ARRAY_LIST")
    iterador2 = it.newIterator(L2)
    while it.hasNext(iterador2):
        elemento = it.next(iterador2)
        lst = []
        while (not st.isEmpty(elemento)):
            stop = st.pop(elemento)
            lst.append(stop)
        lt.addLast(lista_rutas, lst)

    lista_final = lt.newList()
    iterador_fin = it.newIterator(lista_rutas)
    while it.hasNext(iterador_fin):
        lista_pe = it.next(iterador_fin)

        total = 0
        total += (len(lista_pe) - 1) * 20 * 60
        edge = gr.getEdge(graph["graph"], lista_pe[len(lista_pe) - 1],
                          lista_pe[0])
        peso = float(edge["weight"])
        total += peso
        i = 0
        while i < len(lista_pe):
            estacion = lista_pe[i]
            j = i + 1
            while j != 0 and i < ((len(lista_pe)) - 1):
                estacion2 = lista_pe[j]
                edge2 = gr.getEdge(graph["graph"], estacion, estacion2)
                peso2 = float(edge2["weight"])
                total += peso2
                j = 0
            i += 1

        lista_parcial = []
        ruta = {"Peso": round(total, 2), "ruta": None}
        if total <= Tiempo:
            i = 0
            while i < len(lista_pe):
                estacion1 = lista_pe[i]
                entry = m.get(graph["Estaciones"], estacion1)
                valor = me.getValue(entry)
                nombre = valor["Nombre"]
                lista_parcial.append(nombre)
                i += 1

            ruta["ruta"] = lista_parcial
            lt.addLast(lista_final, ruta)

    return lista_final
Exemple #19
0
def addsong(dicci, song):

    if om.contains(dicci["instrumentalness"], float(song["instrumentalness"])):
        jef = om.get(dicci["instrumentalness"],
                     float(song["instrumentalness"]))
        lis = me.getValue(jef)
        lt.addLast(lis, song)

    else:

        lisa = lt.newList()
        om.put(dicci["instrumentalness"], float(song["instrumentalness"]),
               lisa)
        lt.addLast(lisa, song)

    if om.contains(dicci["acousticness"], float(song["acousticness"])):
        jef = om.get(dicci["acousticness"], float(song["acousticness"]))
        lis = me.getValue(jef)
        lt.addLast(lis, song)

    else:

        lisa = lt.newList()
        lt.addLast(lisa, song)
        om.put(dicci["acousticness"], float(song["acousticness"]), lisa)

    if om.contains(dicci["liveness"], float(song["liveness"])):
        jef = om.get(dicci["liveness"], float(song["liveness"]))
        lis = me.getValue(jef)
        lt.addLast(lis, song)

    else:

        lisa = lt.newList()
        lt.addLast(lisa, song)
        om.put(dicci["liveness"], float(song["liveness"]), lisa)

    if om.contains(dicci["speechiness"], float(song["speechiness"])):
        jef = om.get(dicci["speechiness"], float(song["speechiness"]))
        lis = me.getValue(jef)
        lt.addLast(lis, song)

    else:

        lisa = lt.newList()
        lt.addLast(lisa, song)
        om.put(dicci["speechiness"], float(song["speechiness"]), lisa)

    if om.contains(dicci["energy"], float(song["energy"])):
        jef = om.get(dicci["energy"], float(song["energy"]))
        lis = me.getValue(jef)
        lt.addLast(lis, song)

    else:

        lisa = lt.newList()
        lt.addLast(lisa, song)
        om.put(dicci["energy"], float(song["energy"]), lisa)

    if om.contains(dicci["danceability"], float(song["danceability"])):
        jef = om.get(dicci["danceability"], float(song["danceability"]))
        lis = me.getValue(jef)
        lt.addLast(lis, song)

    else:

        lisa = lt.newList()
        lt.addLast(lisa, song)
        om.put(dicci["danceability"], float(song["danceability"]), lisa)

    if om.contains(dicci["valence"], float(song["valence"])):
        jef = om.get(dicci["valence"], float(song["valence"]))
        lis = me.getValue(jef)
        lt.addLast(lis, song)

    else:
        lisa = lt.newList()
        lt.addLast(lisa, song)
        om.put(dicci["valence"], float(song["valence"]), lisa)

    return dicci
Exemple #20
0
def Req5(analyzer, minH, maxH):
    analyzer = analyzer[0]
    tiempoMin = minH.split(':')
    f = minH.split(':')[0]
    g = minH.split(':')[1]
    tmin = (f + g)
    Tmin = int(tmin)
    tiempoMax = maxH.split(':')
    f2 = minH.split(':')[0]
    g2 = minH.split(':')[1]
    tmax = (f2 + g2)
    Tmax = int(tmax)
    feat = analyzer['dates']
    feat2 = analyzer['features']
    feat3 = analyzer['contextContent']

    rangoHoras = om.values(feat, Tmin, Tmax)
    print(rangoHoras)

    mapa1 = {
        'reggae': [60, 90],
        'down-tempo': [70, 100],
        'chill-out': [90, 120],
        'hip-hop': [85, 115],
        'jazzandfunk': [120, 150],
        'pop': [100, 130],
        'r&b': [60, 80],
        'rock': [110, 140],
        'metal': [100, 160]
    }

    b = oneList1(rangoHoras)
    reggae = lt.newList('ARRAY_LIST')
    down = lt.newList('ARRAY_LIST')
    chillOut = lt.newList('ARRAY_LIST')
    hipHop = lt.newList('ARRAY_LIST')
    jazzandfunk = lt.newList('ARRAY_LIST')
    pop = lt.newList('ARRAY_LIST')
    ryb = lt.newList('ARRAY_LIST')
    rock = lt.newList('ARRAY_LIST')
    metal = lt.newList('ARRAY_LIST')

    a = lit.newIterator(b)
    mew = lt.newList()

    while lit.hasNext(a):
        video = lit.next(a)
        sixe = lt.size(video[0])
        size += sixe
        e = lit.newIterator(video[1])
        si = lt.size(mew)
        while lit.hasNext(e):
            objeto = lit.next(e)
            a = lt.isPresent(mew, objeto)
            if a == 0:
                lt.addLast(mew, objeto)

    contador = 0
    max = 0
    maximom = ""
    maximo = None

    for i in lt.iterator(mew):
        if i[feat2]["tempo"] > 60 and i[feat2]["tempo"] < 90:
            lt.addLast(reggae, i)
        if i[feat2]["tempo"] > 70 and i[feat2]["tempo"] < 100:
            lt.addLast(down, i)
        if i[feat2]["tempo"] > 90 and i[feat2]["tempo"] < 120:
            lt.addLast(chillOut, i)
        if i[feat2]["tempo"] > 85 and i[feat2]["tempo"] < 115:
            lt.addLast(hipHop, i)
        if i[feat2]["tempo"] > 120 and i[feat2]["tempo"] < 125:
            lt.addLast(jazzandfunk, i)
        if i[feat2]["tempo"] > 100 and i[feat2]["tempo"] < 130:
            lt.addLast(pop, i)
        if i[feat2]["tempo"] > 60 and i[feat2]["tempo"] < 80:
            lt.addLast(ryb, i)
        if i[feat2]["tempo"] > 110 and i[feat2]["tempo"] < 140:
            lt.addLast(rock, i)
        if i[feat2]["tempo"] > 100 and i[feat2]["tempo"] < 160:
            lt.addLast(metal, i)
Exemple #21
0
def requerimiento4(info, nom1, nom2, nom3, nom4, des1, des2):

    gene1 = tablageneros(nom1)
    llave = mp.get(gene1, nom1)  #Da la llave y el valor de la tabla de hash
    valor = me.getValue(llave)  # El valor de la llave del genero
    rango1 = om.values(info["generos"], valor[0], valor[1])

    diccionario = mp.newMap()
    diccionarionuevo = mp.newMap()
    iterador = it.newIterator(rango1)
    suma1 = 0

    while it.hasNext(iterador):

        actu = it.next(iterador)
        suma1 += lt.size(actu)

        iterardentro = it.newIterator(actu)

        while it.hasNext(iterardentro):

            actual = it.next(iterardentro)
            if mp.contains(diccionario, actual["tempo"]):

                ola = mp.get(diccionario, actual["tempo"])
                listo = me.getValue(ola)
                lt.addLast(listo, actual)

            else:

                listo = lt.newList()
                mp.put(diccionario, actual["tempo"], listo)
                lt.addLast(listo, actual)

            if mp.contains(diccionarionuevo, actual["artist_id"]):

                llaves = mp.get(diccionarionuevo, actual["artist_id"])
                valores = me.getValue(llaves)

                lt.addLast(valores, actual)
            else:

                infor = lt.newList()
                mp.put(diccionarionuevo, actual["artist_id"], infor)
                lt.addLast(infor, actual)

    tamano1 = mp.size(diccionarionuevo)

    gene2 = tablageneros(nom2)
    llave = mp.get(gene2, nom2)
    valor2 = me.getValue(llave)
    rango2 = om.values(info["generos"], valor2[0], valor2[1])

    diccionario2 = mp.newMap()
    diccionarionuevo2 = mp.newMap()
    iterador = it.newIterator(rango2)
    suma2 = 0
    while it.hasNext(iterador):

        actu = it.next(iterador)
        suma2 += lt.size(actu)

        iterardentro = it.newIterator(actu)

        while it.hasNext(iterardentro):

            actual = it.next(iterardentro)
            if mp.contains(diccionario2, actual["tempo"]):

                ola = mp.get(diccionario2, actual["tempo"])
                listo = me.getValue(ola)

                lt.addLast(listo, actual)
            else:

                listo = lt.newList()
                mp.put(diccionario2, actual["tempo"], listo)
                lt.addLast(listo, actual)

            if mp.contains(diccionarionuevo2, actual["artist_id"]):

                llaves = mp.get(diccionarionuevo2, actual["artist_id"])
                valores = me.getValue(llaves)

                lt.addLast(valores, actual)
            else:

                infor = lt.newList()
                mp.put(diccionarionuevo2, actual["artist_id"], infor)
                lt.addLast(infor, actual)

    tamano2 = mp.size(diccionarionuevo2)

    gene3 = tablageneros(nom3)
    llave = mp.get(gene3, nom3)
    valor3 = me.getValue(llave)
    rango3 = om.values(info["generos"], valor3[0], valor3[1])

    diccionario3 = mp.newMap()
    diccionarionuevo3 = mp.newMap()
    iterador = it.newIterator(rango3)

    suma3 = 0
    while it.hasNext(iterador):

        actu = it.next(iterador)

        suma3 += lt.size(actu)

        iterardentro = it.newIterator(actu)

        while it.hasNext(iterardentro):

            actual = it.next(iterardentro)
            if mp.contains(diccionario3, actual["tempo"]):

                ola = mp.get(diccionario3, actual["tempo"])
                listo = me.getValue(ola)

                lt.addLast(listo, actual)
            else:

                listo = lt.newList()
                mp.put(diccionario3, actual["tempo"], listo)
                lt.addLast(listo, actual)

            if mp.contains(diccionarionuevo3, actual["artist_id"]):

                llaves = mp.get(diccionarionuevo3, actual["artist_id"])
                valores = me.getValue(llaves)

                lt.addLast(valores, actual)
            else:

                infor = lt.newList()
                mp.put(diccionarionuevo3, actual["artist_id"], infor)
                lt.addLast(infor, actual)

    tamano3 = mp.size(diccionarionuevo3)

    diccionarionuevo4 = mp.newMap()
    total = suma1 + suma2 + suma3
    suma4 = 0
    if nom4 != "":

        rango4 = om.values(info["generos"], des1, des2)

        diccionario4 = mp.newMap()
        iterador = it.newIterator(rango4)

        suma4 = 0
        while it.hasNext(iterador):

            actu = it.next(iterador)

            suma4 += lt.size(actu)

            iterardentro = it.newIterator(actu)

            while it.hasNext(iterardentro):

                actual = it.next(iterardentro)
                if mp.contains(diccionario4, actual["tempo"]):

                    ola = mp.get(diccionario4, actual["tempo"])
                    listo = me.getValue(ola)

                    lt.addLast(listo, actual)
                else:

                    listo = lt.newList()
                    mp.put(diccionario4, actual["tempo"], listo)
                    lt.addLast(listo, actual)
                if mp.contains(diccionarionuevo4, actual["artist_id"]):

                    llaves = mp.get(diccionarionuevo4, actual["artist_id"])
                    valores = me.getValue(llaves)

                    lt.addLast(valores, actual)
                else:

                    infor = lt.newList()
                    mp.put(diccionarionuevo4, actual["artist_id"], infor)
                    lt.addLast(infor, actual)

    tamano4 = mp.size(diccionarionuevo4)

    llave1 = mp.keySet(diccionarionuevo)
    llave2 = mp.keySet(diccionarionuevo2)
    llave3 = mp.keySet(diccionarionuevo3)

    iterador = it.newIterator(llave1)
    primero = lt.newList()
    while it.hasNext(iterador):

        actu = it.next(iterador)

        lt.addLast(primero, actu)

    artistas1 = lt.subList(primero, 0, 12)

    iterador = it.newIterator(llave2)
    segundo = lt.newList()
    while it.hasNext(iterador):

        actu = it.next(iterador)

        lt.addLast(segundo, actu)

    artistas2 = lt.subList(segundo, 0, 12)

    iterador = it.newIterator(llave3)
    tercero = lt.newList()
    while it.hasNext(iterador):

        actu = it.next(iterador)

        lt.addLast(tercero, actu)

    artistas3 = lt.subList(tercero, 0, 12)

    return suma1, suma2, suma3, total, suma4, tamano1, tamano2, tamano3, tamano4, artistas1, artistas2, artistas3
def loadData(catalog, video):
    lt.addLast(catalog['video'], video)
def addVideos(catalog, video):
    # Se adiciona el libro a la lista de libros
    lt.addLast(catalog['videos'], video)
Exemple #24
0
def addAccident(analyzer, accident):
    """
    """
    lt.addLast(analyzer['accidents'], accident)
    updateDateIndex(analyzer['dateIndex'], accident)
    return analyzer
Exemple #25
0
def criticStations(citibike):
    """
    Top 3 Llegada, Top 3 Salida y Top 3 menos usadas
    Req 3
    """
    #Listas respuesta
    topLlegada = lt.newList(datastructure='ARRAY_LIST',
                            cmpfunction=compareroutes)
    topSalida = lt.newList(datastructure='ARRAY_LIST',
                           cmpfunction=compareroutes)
    intopUsadas = lt.newList(datastructure='ARRAY_LIST',
                             cmpfunction=compareroutes)

    #Listas temporales para obtener el top 3
    top3LS = lt.newList(datastructure='ARRAY_LIST', cmpfunction=compareroutes)
    inTop3 = lt.newList(datastructure='ARRAY_LIST', cmpfunction=compareroutes)

    tempLT = lt.newList(cmpfunction=compareroutes)
    ltKeys = gr.edges(citibike['connections'])
    for arc in range(1, lt.size(ltKeys) + 1):
        lt.addLast(tempLT, lt.getElement(ltKeys, arc)['count'])

    ms.mergesort(tempLT, greatequal)

    for i in range(1, 10):
        lt.addLast(top3LS, lt.getElement(tempLT, i))
    for i in range(3):
        lt.addLast(inTop3, lt.getElement(tempLT, lt.size(tempLT) - i))

    vxl = 1
    while vxl <= lt.size(tempLT) and lt.size(topLlegada) <= 3:
        if lt.isPresent(top3LS, lt.getElement(ltKeys, vxl)['count']):
            vxA = getStation(citibike,
                             lt.getElement(ltKeys, vxl)['vertexA'])[1]
            if not lt.isPresent(topLlegada, vxA):
                lt.addLast(topLlegada, vxA)
        vxl += 1

    vxs = 1
    while vxs <= lt.size(tempLT) and lt.size(topSalida) <= 3:
        if lt.isPresent(top3LS, lt.getElement(ltKeys, vxs)['count']):
            vxB = getStation(citibike,
                             lt.getElement(ltKeys, vxs)['vertexB'])[1]
            if not lt.isPresent(topLlegada, vxB):
                lt.addLast(topSalida, vxB)
        vxs += 1

    vxin = 1
    while vxin <= lt.size(tempLT) and lt.size(intopUsadas) <= 3:
        if lt.isPresent(inTop3, lt.getElement(ltKeys, vxin)['count']):
            vxA = getStation(citibike,
                             lt.getElement(ltKeys, vxin)['vertexA'])[1]
            if not lt.isPresent(intopUsadas, vxA):
                lt.addLast(intopUsadas, vxA)
        vxin += 1

    return topLlegada, topSalida, intopUsadas
def addCrime(analyzer, crime):
    """
    """
    lt.addLast(analyzer['crimes'], crime)
    updateDateIndex(analyzer['dateIndex'], crime)
    return analyzer
def añadir_evento_artista_AY(values,lstEvent,lstArtistas):
    for event in lt.iterator(values):
        lt.addLast(lstEvent,event)
        if event['artist_id'] not in lt.iterator(lstArtistas):
            lt.addLast(lstArtistas,event['artist_id'])
def addVideo(catalog, videoname):

    lt.addLast(catalog["videos"], videoname)
def generos_musicales(analyzer,generos,newGen,min1,max1):
    generos = generos.lower()
    generos = generos.split(',')

    lst_new_gen = None
    if newGen != None:
        lst_new_gen = oms.values(analyzer['tempo'],min1,max1)

    
    reggae = oms.values(analyzer["tempo"],60,90)
    down_tempo = oms.values(analyzer["tempo"],70,100)
    chill_out = oms.values(analyzer["tempo"],90,120)
    hip_hop = oms.values(analyzer["tempo"],85,115)
    jazz_funk= oms.values(analyzer["tempo"],120,125)
    pop= oms.values(analyzer["tempo"],100,130)
    r_b= oms.values(analyzer["tempo"],60,80)
    rock =oms.values(analyzer["tempo"],110,140)
    metal = oms.values(analyzer["tempo"],140,160)

    num_rep = 0
    lst_rep_gen = lt.newList('ARRAY_LIST')

    for genero in generos:
        if genero == "reggae":
            rango = '60 - 90'
            map1 = obtener_valores_R4_AY(genero,reggae,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma

        elif genero == "down-tempo":
            rango = '70 - 100'
            map1 = obtener_valores_R4_AY(genero,down_tempo,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma
        elif genero == "chill-out":
            rango = '90 - 120'
            map1 = obtener_valores_R4_AY(genero,chill_out,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma
        elif genero == "hip-hop":
            rango = '85 - 115'
            map1 = obtener_valores_R4_AY(genero,hip_hop,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma
        elif genero == "jazz and funk":
            rango = '120 - 125'
            map1 = obtener_valores_R4_AY(genero,jazz_funk,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma
        elif genero == "pop":
            rango = '100 - 130'
            map1 = obtener_valores_R4_AY(genero,pop,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma
        elif genero == "r&B":
            rango = '60 - 80'
            map1 = obtener_valores_R4_AY(genero,r_b,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma
        elif genero == "rock":
            rango = '110 - 140'
            map1 = obtener_valores_R4_AY(genero,rock,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma
        elif genero == "metal":
            rango = '100 - 160'
            map1 = obtener_valores_R4_AY(genero,metal,rango)
            suma = getValue(map1,'num_rep')
            lt.addLast(lst_rep_gen,map1)
            num_rep+=suma
        else:
            if newGen != None:
                rango = f'{min1} - {max1}'
                map1 = obtener_valores_R4_AY(newGen,lst_new_gen,rango)
                suma = getValue(map1,'num_rep')
                lt.addLast(lst_rep_gen,map1)
                num_rep+=suma
    return (num_rep,lst_rep_gen)        
def addVideos(catalog, video):
    # Se adiciona el video a la lista de videos
    lt.addLast(catalog['videos'], video)
    mp.put(catalog['category'], video['category_id'], video)
    addVideoCategory(catalog, video)