diff --git a/app.py b/app.py index 620347d..adc501a 100644 --- a/app.py +++ b/app.py @@ -1,9 +1,11 @@ from modules.analysis import isNBA -from modules.scraper import get_playoff_bracket, get_standings +from modules.scraper import * from modules.transformer import create_html_bracket from modules.query import Query from data.text_data import unsure, non_nba from flask import Flask, render_template, request, jsonify, redirect +import numpy as np + app = Flask(__name__) @@ -93,9 +95,7 @@ def authors(): def predictions(): bracket = get_playoff_bracket() bracket = create_html_bracket(bracket) - west_standings = get_standings("west") - east_standings = get_standings("east") - return render_template("predictions.html", bracket=bracket, west_standings=west_standings, east_standings=east_standings) + return render_template("predictions.html", bracket=bracket) """ Function to download requested blog for user. @@ -126,8 +126,8 @@ def download(id): """ Function to handle POST request from user -with embedded message. The message is then -passed to the chatbot and the response is returned +with embedded message. The message is then +passed to the chatbot and the response is returned to user. Parameters @@ -147,5 +147,23 @@ def get_bot_response(): response = handler.process() return jsonify(response) +@app.route("/v1/player//stats/") +def player(name, stat): + stats = get_total_stat(name, stat) + print(stats) + return jsonify(player_name=name, + stats=stats) + +@app.route("/v1/player/fullstat//") +def full_stat(name): + name = get_target_name(name) + json = [] + for key, value in dict.items(total_stat_map): + full_stats = get_total_stat(name, key) + json.append(full_stats) + + json_array = np.array(json) + return jsonify(player_name = name, stats = json) + if __name__ == "__main__": app.run() \ No newline at end of file diff --git a/inference/inference_network.py b/inference/inference_network.py index 43b1851..8bdb492 100644 --- a/inference/inference_network.py +++ b/inference/inference_network.py @@ -17,7 +17,23 @@ def __init__(self, query): model_file = "inference/models/classifiers/query_classifier.pkl" query_clf = joblib.load(model_file) self.node_type = query_clf.predict([query.lower()])[0] - + + """ + This function verifies that the request is related to NBA. + Parameters + ---------- + self : none + + Returns + ------- + Check if query is NBA related + unsure:int + non_nba:int + + node.response: string + node.response is equal to either ranknode or statnode + + """ def response(self): if self.node_type == "info": node = InfoNode()