Skip to content

Update inference_network.py #154

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
@@ -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__)

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -147,5 +147,23 @@ def get_bot_response():
response = handler.process()
return jsonify(response)

@app.route("/v1/player/<string:name>/stats/<string:stat>")
def player(name, stat):
stats = get_total_stat(name, stat)
print(stats)
return jsonify(player_name=name,
stats=stats)

@app.route("/v1/player/fullstat/<string:name>/")
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()
18 changes: 17 additions & 1 deletion inference/inference_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down