Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -62,6 +62,19 @@ def analyze_and_complete(file_paths):
|
|
62 |
quotes = nltk_extract_quotes(text)
|
63 |
token_count = count_tokens(text)
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
results.append((str(spacy_entities), "\n".join(sentences), "\n".join(quotes), str(token_count)))
|
66 |
return results
|
67 |
|
@@ -69,7 +82,7 @@ def analyze_and_complete(file_paths):
|
|
69 |
interface = gr.Interface(
|
70 |
fn=analyze_and_complete,
|
71 |
inputs=gr.File(file_count="multiple", type="filepath"),
|
72 |
-
outputs=
|
73 |
title="Movie Script Analyzer and Completer",
|
74 |
description="Upload text, PDF, or DOCX files to analyze and complete the movie script."
|
75 |
)
|
|
|
62 |
quotes = nltk_extract_quotes(text)
|
63 |
token_count = count_tokens(text)
|
64 |
|
65 |
+
# Save results to files
|
66 |
+
with open(os.path.join(output_directory, f"{filename_prefix}_spacy_entities.txt"), "w", encoding="utf-8") as file:
|
67 |
+
file.write(str(spacy_entities))
|
68 |
+
|
69 |
+
with open(os.path.join(output_directory, f"{filename_prefix}_sentences.txt"), "w", encoding="utf-8") as file:
|
70 |
+
file.write("\n".join(sentences))
|
71 |
+
|
72 |
+
with open(os.path.join(output_directory, f"{filename_prefix}_quotes.txt"), "w", encoding="utf-8") as file:
|
73 |
+
file.write("\n".join(quotes))
|
74 |
+
|
75 |
+
with open(os.path.join(output_directory, f"{filename_prefix}_token_count.txt"), "w", encoding="utf-8") as file:
|
76 |
+
file.write(str(token_count))
|
77 |
+
|
78 |
results.append((str(spacy_entities), "\n".join(sentences), "\n".join(quotes), str(token_count)))
|
79 |
return results
|
80 |
|
|
|
82 |
interface = gr.Interface(
|
83 |
fn=analyze_and_complete,
|
84 |
inputs=gr.File(file_count="multiple", type="filepath"),
|
85 |
+
outputs=gr.outputs.JSON(),
|
86 |
title="Movie Script Analyzer and Completer",
|
87 |
description="Upload text, PDF, or DOCX files to analyze and complete the movie script."
|
88 |
)
|