Spaces:
Sleeping
Sleeping
Commit
·
600c17e
1
Parent(s):
a80b299
Fix Bugs
Browse files- Fixed error - No path exists
- classifier/classifier.py +9 -4
classifier/classifier.py
CHANGED
@@ -35,7 +35,7 @@ class ThemeClassifier:
|
|
35 |
sentence_batch_size = 20
|
36 |
script_batches = []
|
37 |
for index in range(0, len(script_sentences), sentence_batch_size):
|
38 |
-
script_batches.append("".join(script_sentences[index:index + sentence_batch_size]))
|
39 |
|
40 |
theme_output = self.theme_classifier(
|
41 |
script_batches,
|
@@ -55,10 +55,15 @@ class ThemeClassifier:
|
|
55 |
|
56 |
def get_themes(self, path, save_path=None):
|
57 |
|
58 |
-
|
|
|
|
|
|
|
59 |
if save_path is not None and os.path.exists(save_path):
|
60 |
df = pd.read_csv(save_path)
|
61 |
-
|
|
|
|
|
62 |
|
63 |
# Load dataset
|
64 |
df = load_subs(path)
|
@@ -73,4 +78,4 @@ class ThemeClassifier:
|
|
73 |
if save_path:
|
74 |
df.to_csv(save_path, index=False)
|
75 |
|
76 |
-
return df
|
|
|
35 |
sentence_batch_size = 20
|
36 |
script_batches = []
|
37 |
for index in range(0, len(script_sentences), sentence_batch_size):
|
38 |
+
script_batches.append(" ".join(script_sentences[index:index + sentence_batch_size]))
|
39 |
|
40 |
theme_output = self.theme_classifier(
|
41 |
script_batches,
|
|
|
55 |
|
56 |
def get_themes(self, path, save_path=None):
|
57 |
|
58 |
+
if save_path and not save_path.endswith(".csv"):
|
59 |
+
save_path += "series.csv"
|
60 |
+
|
61 |
+
# Read Saved Output, if Exists
|
62 |
if save_path is not None and os.path.exists(save_path):
|
63 |
df = pd.read_csv(save_path)
|
64 |
+
if set(df.columns) == set(self.theme_list):
|
65 |
+
return df
|
66 |
+
|
67 |
|
68 |
# Load dataset
|
69 |
df = load_subs(path)
|
|
|
78 |
if save_path:
|
79 |
df.to_csv(save_path, index=False)
|
80 |
|
81 |
+
return df
|