Spaces:
Runtime error
Runtime error
arjunpatel
commited on
Commit
•
f3c22d7
1
Parent(s):
657dffa
files needed to make app work
Browse files- requirements.txt +3 -0
- utils.py +32 -0
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
transformers
|
2 |
+
pandas
|
3 |
+
tensorflow
|
utils.py
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
def filter_text(generated_move):
|
2 |
+
# removes any moves that follow after the genrated move
|
3 |
+
# needs to be updated to remove any move after the first that says "This move is..."
|
4 |
+
# this will prevent moves that are generated after the seed
|
5 |
+
# filter text such that additional moves are not used.
|
6 |
+
# takes care of potential tokenizing problems
|
7 |
+
|
8 |
+
generated_move = generated_move.replace("Sp.", "Special")
|
9 |
+
sentences = generated_move.split(".")
|
10 |
+
|
11 |
+
if len(sentences) > 2:
|
12 |
+
#check if multiple sentences start with "This move"
|
13 |
+
# remove sentences that describe the second move
|
14 |
+
#ret_set = ". ".join(sentences[:2])
|
15 |
+
this_move_indexes = [0]
|
16 |
+
for idx, sent in enumerate(sentences):
|
17 |
+
if idx > 0:
|
18 |
+
if "this move is called" in sent.lower():
|
19 |
+
this_move_indexes.append(idx)
|
20 |
+
# if this_move_indexes is longer than 1, then filter.
|
21 |
+
if len(this_move_indexes) > 1:
|
22 |
+
#filter to the second index, exclusive
|
23 |
+
sentences = sentences[:this_move_indexes[1]]
|
24 |
+
ret_set = "\n".join(sentences)
|
25 |
+
return ret_set
|
26 |
+
|
27 |
+
|
28 |
+
def format_moves(moves):
|
29 |
+
# given a list of dictionaries of moves
|
30 |
+
# formats into a string with newlines
|
31 |
+
move = filter_text(moves[0]["generated_text"])
|
32 |
+
return move
|