Update app.py
Browse files
app.py
CHANGED
@@ -422,6 +422,14 @@ class TextClassifier:
|
|
422 |
|
423 |
def analyze_text(text: str, mode: str, classifier: TextClassifier) -> tuple:
|
424 |
"""Analyze text using specified mode and return formatted results."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
425 |
if mode == "quick":
|
426 |
result = classifier.quick_scan(text)
|
427 |
|
@@ -431,6 +439,10 @@ def analyze_text(text: str, mode: str, classifier: TextClassifier) -> tuple:
|
|
431 |
Windows analyzed: {result['num_windows']}
|
432 |
"""
|
433 |
|
|
|
|
|
|
|
|
|
434 |
return (
|
435 |
text, # No highlighting in quick mode
|
436 |
"Quick scan mode - no sentence-level analysis available",
|
|
|
422 |
|
423 |
def analyze_text(text: str, mode: str, classifier: TextClassifier) -> tuple:
|
424 |
"""Analyze text using specified mode and return formatted results."""
|
425 |
+
# Count words in the text
|
426 |
+
word_count = len(text.split())
|
427 |
+
|
428 |
+
# If text is less than 200 words and detailed mode is selected, switch to quick mode
|
429 |
+
original_mode = mode
|
430 |
+
if word_count < 200 and mode == "detailed":
|
431 |
+
mode = "quick"
|
432 |
+
|
433 |
if mode == "quick":
|
434 |
result = classifier.quick_scan(text)
|
435 |
|
|
|
439 |
Windows analyzed: {result['num_windows']}
|
440 |
"""
|
441 |
|
442 |
+
# Add note if mode was switched
|
443 |
+
if original_mode == "detailed":
|
444 |
+
quick_analysis += f"\n\nNote: Switched to quick mode because text contains only {word_count} words. Minimum 200 words required for detailed analysis."
|
445 |
+
|
446 |
return (
|
447 |
text, # No highlighting in quick mode
|
448 |
"Quick scan mode - no sentence-level analysis available",
|