Ejemplo n.º 1
0
def fourFactorsCompare(team1, team2, year):
    stats1 = sql.getFFA(team1, year)
    stats2 = sql.getFFA(team2, year)
    
    """Shooting 40%, Turnovers 25%, Rebounding 20%, Free Throws 15%"""
    """eFG% (index 24) + TOV% (index 33) + ORB% (index 27) + FT% (index 12)"""
    FFA1 = stats1[24] * 0.4 + stats1[33] * .25 + stats1[27] * .2 + stats1[12] * .15
Ejemplo n.º 2
0
def run(filepath):
    start = perf_counter()
    points = Sqlite.getData(filepath)
    demo = CF(points, k=200)
    demo.recommendByUser(len(demo.points))

    Sqlite.returnData(filepath, demo.recommandList)

    print("处理的数据为%d条" % (len(demo.points)))
    print("准确率: %.2f %%" % (demo.cost * 100))
    end = perf_counter()
    print("耗费时间: %f s" % (end - start))
Ejemplo n.º 3
0
def parseWholeSeason(lines):
    for i in lines:
        tempKeyword = 'class="left " csk="'
        keywordIndex = str(i).find(tempKeyword)
        tempString = str(i)
        if(keywordIndex != -1 and keywordIndex != None):
            gameName = ""
            keywordIndex += len(tempKeyword)
            while(tempString[keywordIndex] != '"'):
                gameName += tempString[keywordIndex]
                keywordIndex += 1
            print(gameName)
            sql.insertSQL(dlChart('0','0', gameName))
Ejemplo n.º 4
0
def FFAteam(team, year):
    stats = sql.getFFA(team, year)
#     print(stats[2])
    total = stats[2]
    FFA1 = (total[24]*100) * 0.4 + total[33] * .25 + total[27] * .2 + (total[12]*100) * .15
    
    return FFA1
Ejemplo n.º 5
0
# Developed and modified by Ye Liang at 11:11 June,3 2017
# All rights reserved
from ExtraTools import write_To_Csv, sleep_Module
import Twitter
import Sqlite
import Parser
import Cluster
CONST_DAYS_INCLUDED = 1


if __name__ == '__main__':
    #----------initialize the modules and settings---------------------begin
    db = Sqlite.Sqlite("database.db")
    parserModule = Parser.Parser()
    clusterModule = Cluster.Cluster()
    twitterModule = Twitter.Twitter(db, parserModule)
    #----------initialize the modules and settings---------------------end

    runSequence = True
    while(runSequence):
        # update all tweets into the database within CONST_DAYS_INCLUDED day
        twitterModule.update_All()
        # get all updated tweets within CONST_DAYS_INCLUDED day
        news24H = db.get_stored_news(CONST_DAYS_INCLUDED)
        # cluster, and find the best news
        sortedNews, labels, sortedScores = clusterModule.cluster_AP(news24H)
        # write to csv file
        write_To_Csv(sortedNews, sortedScores, 'Sorted_Best_Tweets (one for each cluster).csv')
        # sleeping procedure
        runSequence = sleep_Module(600)
    db.close()
Ejemplo n.º 6
0
def updateGames(year):
    allGames = sql.allGamesofYear(year)
    temp = allGames[len(allGames) - 1][1].split('_')
    lastGame = temp[2] + temp[3] + temp[4] + '0' + temp[1]
    print(lastGame)
    lastMonth = int(temp[3])
    foundLastgame = False
    
    vars = Variables.Variables()
    teams = vars.teams
    
    months = ['october', 'november', 'december', 'january', 'febuary', 'march', 'april', 'may', 'june' ]
    monthIndex = [10, 11, 12, 1, 2, 3, 4, 5, 6]
    start = monthIndex.index(lastMonth)
    print(start)
    
    while(start < len(months)):
        month = months[start]
        print(month)
        NBAurl = "http://www.basketball-reference.com/leagues/NBA_" + str(year) + "_games-" + month + ".html" 
        try:
            tempWebFile = request.urlopen(NBAurl).read()
        except:
            return None
        tempData = BeautifulSoup(tempWebFile,"lxml")
        lines = tempData.find_all('tr')
     
        for i in lines:
            tempKeyword = 'class="left " csk="'
            keywordIndex = str(i).find(tempKeyword)
            tempString = str(i)
            if(keywordIndex != -1 and keywordIndex != None):
                gameName = ""
                keywordIndex += len(tempKeyword)
                while(tempString[keywordIndex] != '"'):
                    gameName += tempString[keywordIndex]
                    keywordIndex += 1
                
                if(gameName == lastGame):
                    foundLastgame = True
                    continue
                
                if(foundLastgame == True):
                    print(gameName)
#                     sql.insertSQL(dlChart('0','0', gameName
        start += 1

# updateGames(2017)

#     for i in lines:
#         print(i)
    
#     months = [10, 11, 12, 1, 2, 3, 4]
#     
#     """Regular Season Starts Oct - Apr"""
#     for month in months: 
#         days = daysMonth.get(month)
#         
#         for day in range(1,days):
#             """Convert Days/Months/Year into proper string """
#             if(day < 10):
#                 tempDay = '0' + str(day)
#             else: 
#                 tempDay = str(day)
#                 
#             if(month < 10):
#                 tempMonth = '0' + str(month)
#             else: 
#                 tempMonth = str(month)
#             
#             if(month >= 10): 
#                 year = str( int(year) - 1)
#                  
#             date = year + '/' + tempMonth + '/' + tempDay
#                         
#             for team in teams:
#                 print(str(team) + " : " + str(date))
#                 tempChart = dlChart(team, date)
#                 if(tempChart != None):
#                     print("game")
#                     sql.insertSQL(dlChart(team , date))


# getWholeSeason("2017")
            
# getWholeSeason('2017')
#http://www.basketball-reference.com/boxscores/201704100BOS.html
# sql.insertSQL(dlChart('BOS', '2017/04/10'))
# dlChart('MIL', '2017/03/03')
Ejemplo n.º 7
0
laucher_elements = {
    'lottery': {
        'label': 'Loterie',
        'image': 'images/d20-128x128.png',
        'callback': lottery_cb
    },
    'characters': {
        'label': 'Fiches de personnages',
        'image': 'images/knight-128.png',
        'callback': characters_cb
    },
    'bestiary': {
        'label': 'Bestiaire',
        'image': 'images/skeleton-128x128.png',
        'callback': bestiary_cb
    },
    'armory': {
        'label': 'Armurerie',
        'image': 'images/sword-128x128.png',
        'callback': armory_cb
    }
}

db = Sqlite.Database('sql/RPG.db', auto_commit = True)
db.execute_from_file('sql/RPG.sql')
Window.set_css_from_file('css/launcher.css')
app = Window.Launcher('glade/launcher.glade', laucher_elements)
app.load()
db.close()
Ejemplo n.º 8
0
def fourFactorsInsert(team, year = None):
    year = '2017'
    
    gameNames = sql.getAllGamesofTeam(team, year)
    teamStats = []
    
    for game in gameNames:
        teamStats.append(sql.getTeamStats(team, game))
        
#     for i in teamStats:
#         print(i)

    """Four Factors Set up. Get entire statistical regular season and then find average"""
    home, home_n = [], 0
    away, away_n = [], 0
    total, total_n = [], 0
     
    """Try to make all numbers into float"""
    for i in range(0,len(teamStats)):
        for j in range(0,len(teamStats[i])):
            if(teamStats[i][j] == '' or teamStats[i][j] == 'None' or teamStats[i][j] == None):
                teamStats[i][j] = 0 
            else:
                try:
                    teamStats[i][j] = float(teamStats[i][j])
                except:
                    pass
                     
#     for i in teamStats:
#         print(i)
     
    """This section will iterate through entire teamStats
    Then add it up and find the average of each statistic """
    for i in teamStats:
        if(i[0] == 'home'):
            if(len(home) == 0):
                for individualStats in i:
                    home.append(individualStats)
            else:
                for index in range(3, len(i)):
                    home[index] += i[index]
            home_n += 1
            
        elif(i[0] == 'away'):
            if(len(away) == 0):
                for individualStats in i:
                    away.append(individualStats)
            else:
                for index in range(3, len(i)):
                    away[index] += i[index]
            away_n += 1
        
        if(len(total) == 0):
            for individualStats in i:
                total.append(individualStats)
            total[0] = 'total'
        else:
            for index in range(3, len(i)):
                total[index] += i[index]
        total_n += 1
    
    """Find average of each statistic. """     
    for i in range(0,len(home)):
        try:
            home[i] /= home_n
            away[i] /= away_n
            total[i] /= total_n
        except:
            pass
    
    averages = []
    averages.append(home)
    averages.append(away)
    averages.append(total)
    
    sql.insertFFA(team, averages, year)
Ejemplo n.º 9
0
import PUBG_API as api
import Sqlite as db
import json

conn = db.connect_db()
db.init_db(conn)

test_account = 'account.95fb96ab3915485c998f6d9bc5eb84b6'
data = api.pubg_api_get_player_data(test_account)

if "data" in data:
    match_data = data["data"]["relationships"]["matches"]["data"]
    for match in match_data:
        print(match["id"])
        match_id = match["id"]
        match_record = db.get_match_by_id(conn, match_id)
        if match_record:
            print("  kills: %i" % match_record["kills"])
            print("  winPlace: %i" % match_record["rank"])
        else:
            match_resp = api.pubg_api_match_data(match_id)
            if "included" in match_resp:
                for item in match_resp["included"]:
                    if item["type"] == "participant":
                        stats = item["attributes"]["stats"]
                        if stats["playerId"] == test_account:
                            print("  kills: %i" % stats["kills"])
                            print("  winPlace: %i" % stats["winPlace"])
                            db.create_match_record(
                                conn, {
                                    "matchId": match_id,