コード例 #1
0
def sentiment_analysis(username):
    """
    We create a query to obtain the sentiment analysis of a tweet published
    by a given username.
    """

    query = {"name": f"{username}"}
    text = list(collection.find(query, {"_id": 0, "name": 1, "text": 1}))
    sia = SentimentIntensityAnalyzer()
    sentence = list(collection.find(query, {"_id": 0, "text": 1}))
    extract = [tweet['text'] for tweet in sentence]
    polarity = sia.polarity_scores(extract[0])
    return f'Text input and name: {text} The sentiment analysis shows: {polarity}'
コード例 #2
0
def mensajes():
    """
    Función que devuelve todas las frases de Dumbledore :)
    """
    query = {"character_name": "Albus Dumbledore"}
    frases = list(collection.find(query,{"_id": 0}))
    return frases
コード例 #3
0
def mensajepersonaje(nombre):
    """
    Hago una query a la base de datos para sacar las frases de una persona
    """
    query = {"speaker": f"{nombre}"}
    frases = list(collection.find(query, {"_id": 0, "date": 0}))
    return frases
コード例 #4
0
def person_sentence(nombre):
    """
    Una query a la base de datos para obtener las frases de un personaje de Juego de Tronos
    """
    query = {"Name": f"{nombre}"}
    frases = list(collection.find(query, {"_id": 0, "Release Date": 0}))
    return frases
コード例 #5
0
def mensajespersonaje(personaje):
    """
    Función que devuelve todas las frases un personaje
    """
    query = {"character_name": f"{personaje}"}
    frases = list(collection.find(query,{"_id": 0}))
    return frases
コード例 #6
0
ファイル: getdata.py プロジェクト: SergioCaler0/iron_flask
def mensaje_personaje(nombre):
    """
    Hacemos una query a la base de datos para sacar las frases de un personaje
    """
    query = {"character_name": f"{nombre}"}
    frases = list(collection.find(query, {"_id": 0}))
    return frases
コード例 #7
0
def quotes_episode(episode_title):
    """
    Function that returns all the quotes of a certain episode (name of the episode must be given).
    """
    proj = {"_id": 0, "index": 0}
    query = {"episode_title": f"{episode_title}"}
    quotes = list(collection.find(query, proj))
    return quotes
コード例 #8
0
def quotes_character(character):
    """
    Function that returns all the quotes that a certain character says.
    """
    proj = {"_id": 0, "index": 0}
    query = {"author": f"{character}"}
    quotes = list(collection.find(query, proj))
    return quotes
コード例 #9
0
def insertamensaje(name_episode,name,frase): 
    dict_insert = {
    "episode name": f"{name_episode}",
    "name": f"{name}",
    "line": f"{frase}",
    }
    while dict_insert not in list(collection.find({}, {'name': 1,'episode name':1, 'line': 1, '_id': 0})):
        collection.insert_one(dict_insert)
コード例 #10
0
def text_by_user(username):
    """
    We create a query to obtain the tweets written by a certain user.
    """

    query = {"name": f"{username}"}
    text = list(collection.find(query, {"_id": 0, "name": 1, "text": 1}))
    return text
コード例 #11
0
def airline_by_user(username):
    """
    We create a query to obtain the airline.
    """

    query = {"name": f"{username}"}
    lines = list(collection.find(query, {"_id": 0, "name": 1, "airline": 1}))
    return lines
コード例 #12
0
def mayoresretweets(numero):
    """
   Función que devuelve los tweets con x numero de retweets
    """
    query_one = {'rt': {"$gt": numero}}
    print(query_one)
    tweets = list(collection.find(query_one, {"tweet": 1, "rt": 1, "_id": 0}))
    return tweets
コード例 #13
0
ファイル: getdata.py プロジェクト: Javi-Python/API-Project
def title_sentiment_over(number):
    """
    Devuelve los post con un title sentiment arriba de numero eligido,
    de -1 a 1.
    """
    query = {'title_sentiment': {'$gte': float(number)}}
    t_sent = list(collection.find(query, {'_id': 0}))
    return t_sent
コード例 #14
0
ファイル: getdata.py プロジェクト: Javi-Python/API-Project
def ticker_posts(ticker):
    '''
    Funcion que devuelve todos los posts que incluyen cierto ticker en el titulo.
    '''

    query = {'tickers': f"{ticker}"}
    ticker_posts = list(collection.find(query, {'_id': 0, 'Unnamed: 0': 0}))
    return ticker_posts
コード例 #15
0
def mensajepersonaje(Name):
    """
    Hacemos una query a la base de datos para sacar las frases de un personaje
    """
    query = {'Name': f'{Name}'}
    #id set to 0 so that id from mongo is not shown
    frases = list(collection.find(query, {"_id": 0, 'Season': 0}))
    return frases
コード例 #16
0
def quotes_season(season):
    """
    Function that returns all the quotes of a certain season.
    """
    proj = {"_id": 0, "index": 0}
    query = {"season": f"{season}"}
    quotes = list(collection.find(query, proj))
    return quotes
コード例 #17
0
def serum_skincare_routine_url(routine_skin_option_for_query, routine_money_option_for_query):
    '''
    Query that returns the brand, category, name, skin type and rating according to the skin type
    input = user's input
    output = dictionary
    '''
    seventeen = list(collection.find({"$and":[{'Skin_Type':routine_skin_option_for_query},{'Price':{"$lte":routine_money_option_for_query}}, {'Category':'Face Serum'}]}, {'_id':0, 'Brand':0, 'Category':0, 'Skin_Type':0, 'Ingredients':0, 'Price':0, 'Rating':0}).limit(3).sort('Rating', -1))
    return seventeen
コード例 #18
0
def cleanser_skincare_routine(routine_skin_option_for_query, routine_money_option_for_query):
    '''
    Query that returns the brand, category, name, skin type and rating according to the skin type
    input = user's input
    output = dictionary
    '''
    eight = list(collection.find({"$and":[{'Skin_Type':routine_skin_option_for_query},{'Price':{"$lte":routine_money_option_for_query}}, {'Category':'Cleanser'}]}, {'_id':0, 'Ingredients':0, 'URL':0}).limit(3).sort('Rating', -1))
    return eight
コード例 #19
0
def number_quotes(character):
    """
    Function that returns the number of quotes that a certain character says.
    """
    proj = {"_id": 0, "index": 0}
    query = {"author": f"{character}"}
    nr = len(list(collection.find(query, proj)))
    return f"{character} says {nr} quotes"
コード例 #20
0
def money(money_option):
    '''
    Query that returns the brand, category, name, skin type and rating according to the price
    input = user's input
    output = dictionary
    '''
    six = list(collection.find({'Price':{"$lte":money_option}}, {'_id':0, 'Ingredients':0, 'URL':0}).limit(5))
    return six
コード例 #21
0
def rating(rating_option):
    '''
    Query that returns the brand, category, name, skin type and rating according to the rating
    input = user's input
    output = dictionary
    '''
    seven = list(collection.find({'Rating':rating_option}, {'_id':0, 'Ingredients':0, 'URL':0}).limit(5))
    return seven
コード例 #22
0
def multi_category(multi_category_option):
    '''
    Query that returns the brand, category, name, skin type and rating according to the product's categories
    input = user's input
    output = dictionary
    '''
    four = list(collection.find({'Category':{"$in":multi_category_option}}, {'_id':0, 'Ingredients':0, 'URL':0, 'Price':0}).limit(5).sort('Rating', -1))
    return four
コード例 #23
0
def skin_type(skin_option):
    '''
    Query that returns the brand, category, name, skin type and rating according to the skin type
    input = user's input
    output = dictionary
    '''
    five = list(collection.find({'Skin_Type':skin_option}, {'_id':0, 'Ingredients':0, 'URL':0, 'Price':0}).limit(5).sort('Rating', -1))
    return five
コード例 #24
0
def sentiment(character):
    """
    Function that returns the main sentiment of a certain character.
    """
    proj = {"_id": 0, "word": 0}
    query = {"character": f"{character}"}
    sent = list(collection.find(query, proj))
    return sent
コード例 #25
0
def brand(brand_option):
    '''
    Query that returns the brand, category, name, skin type and rating according to the brand
    input = user's input
    output = dictionary
    '''
    one = list(collection.find({'Brand':brand_option}, {'_id':0, 'Ingredients':0, 'URL':0, 'Price':0}).limit(6).sort('Rating', -1))
    return one
コード例 #26
0
def word(character):
    """
    Function that returns the most repeated word of a certain character

    """
    proj = {"_id": 0, "sentiment": 0}
    query = {"character": f"{character}"}
    wrd = list(collection.find(query, proj))
    return wrd
コード例 #27
0
def quotes_word(word):
    """
    Function that returns all the quotes that contains a certain word or sentence.

    """
    proj = {"_id": 0, "index": 0}
    query = {"quote": {'$regex': f"{word}"}}
    quotes = list(collection.find(query, proj))
    return quotes
コード例 #28
0
def quotes_season_episode(season, episode):
    """
    Function that returns all the quotes of a certain episode (number of the episode and must be given).

    """
    proj = {"_id": 0, "index": 0}
    query = {"season": f"{season}", "episode_number": f"{episode}"}
    quotes = list(collection.find(query, proj))
    return quotes
コード例 #29
0
def textoxclave(clave):
    """
    Función que devuelve todas los textos que tengan esa keyword
    """
    query = {"Keywords": f"{clave}"}
    textos = list(collection.find(query, {"_id": 0}))
    if len(textos) == 0:
        return ("su búsqueda no ha dado ningún resultado")
    else:
        return textos
コード例 #30
0
def textoxpartido(partido):
    """
    Función que devuelve todas los textos de un partido
    """
    query = {"Partido": f"{partido}"}
    textos = list(collection.find(query, {"_id": 0}))
    if len(textos) == 0:
        return ("su búsqueda no ha dado ningún resultado")
    else:
        return textos