Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -385,15 +385,15 @@ def run_market_research(topic: str, progress_container, chat_container):
|
|
| 385 |
"sources": []
|
| 386 |
}
|
| 387 |
|
| 388 |
-
|
| 389 |
def extract_section(text, section_name):
|
| 390 |
"""Extract a section from the text"""
|
| 391 |
-
pattern =
|
| 392 |
-
match
|
| 393 |
-
return match
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
|
|
|
| 397 |
matches = re.finditer(source_pattern, text, re.MULTILINE)
|
| 398 |
return [match.group().strip() for match in matches]
|
| 399 |
|
|
|
|
| 385 |
"sources": []
|
| 386 |
}
|
| 387 |
|
|
|
|
| 388 |
def extract_section(text, section_name):
|
| 389 |
"""Extract a section from the text"""
|
| 390 |
+
pattern = rf"{section_name}.*?\n(.*?)(?=\n\n|<span class=\"math-inline\">)"
|
| 391 |
+
match = re.search(pattern, text, re.DOTALL | re.IGNORECASE)
|
| 392 |
+
return match.group(1).strip() if match else ""
|
| 393 |
+
|
| 394 |
+
def extract_sources(text):
|
| 395 |
+
"""Extract sources from the text"""
|
| 396 |
+
source_pattern = r"Source:.*?(?:\n|<span class=\"math-inline\">)|\[.*?\]|\(https?://.*?\)"
|
| 397 |
matches = re.finditer(source_pattern, text, re.MULTILINE)
|
| 398 |
return [match.group().strip() for match in matches]
|
| 399 |
|