Commit
·
8317e1e
1
Parent(s):
af07826
Update app.py
Browse files
app.py
CHANGED
|
@@ -440,7 +440,8 @@ class Application:
|
|
| 440 |
st.markdown(
|
| 441 |
"""
|
| 442 |
This application finds the best matching historical players using vector search with [txtai](https://github.com/neuml/txtai).
|
| 443 |
-
Raw data is from the [Baseball Databank](https://github.com/chadwickbureau/baseballdatabank) GitHub project.
|
|
|
|
| 444 |
"""
|
| 445 |
)
|
| 446 |
|
|
@@ -457,7 +458,7 @@ class Application:
|
|
| 457 |
params = self.params()
|
| 458 |
|
| 459 |
# Category and stats
|
| 460 |
-
category = self.category(params.get("category"))
|
| 461 |
stats = self.batting if category == "Batting" else self.pitching
|
| 462 |
|
| 463 |
# Player name
|
|
@@ -505,12 +506,13 @@ class Application:
|
|
| 505 |
|
| 506 |
return params
|
| 507 |
|
| 508 |
-
def category(self, category):
|
| 509 |
"""
|
| 510 |
Builds category input widget.
|
| 511 |
|
| 512 |
Args:
|
| 513 |
category: category parameter
|
|
|
|
| 514 |
|
| 515 |
Returns:
|
| 516 |
category component
|
|
@@ -523,7 +525,7 @@ class Application:
|
|
| 523 |
default = categories.index(category) if category and category in categories else 0
|
| 524 |
|
| 525 |
# Radio box component
|
| 526 |
-
return st.radio("Stat", categories, index=default, horizontal=True, key=
|
| 527 |
|
| 528 |
def name(self, names, name):
|
| 529 |
"""
|
|
|
|
| 440 |
st.markdown(
|
| 441 |
"""
|
| 442 |
This application finds the best matching historical players using vector search with [txtai](https://github.com/neuml/txtai).
|
| 443 |
+
Raw data is from the [Baseball Databank](https://github.com/chadwickbureau/baseballdatabank) GitHub project. Read [this
|
| 444 |
+
article](https://medium.com/neuml/explore-baseball-history-with-vector-search-5778d98d6846) for more details.
|
| 445 |
"""
|
| 446 |
)
|
| 447 |
|
|
|
|
| 458 |
params = self.params()
|
| 459 |
|
| 460 |
# Category and stats
|
| 461 |
+
category = self.category(params.get("category"), "category")
|
| 462 |
stats = self.batting if category == "Batting" else self.pitching
|
| 463 |
|
| 464 |
# Player name
|
|
|
|
| 506 |
|
| 507 |
return params
|
| 508 |
|
| 509 |
+
def category(self, category, key):
|
| 510 |
"""
|
| 511 |
Builds category input widget.
|
| 512 |
|
| 513 |
Args:
|
| 514 |
category: category parameter
|
| 515 |
+
key: widget key
|
| 516 |
|
| 517 |
Returns:
|
| 518 |
category component
|
|
|
|
| 525 |
default = categories.index(category) if category and category in categories else 0
|
| 526 |
|
| 527 |
# Radio box component
|
| 528 |
+
return st.radio("Stat", categories, index=default, horizontal=True, key=key)
|
| 529 |
|
| 530 |
def name(self, names, name):
|
| 531 |
"""
|