Spaces:
Runtime error
Runtime error
Update tools.py
Browse files
tools.py
CHANGED
|
@@ -33,6 +33,7 @@ def search_featured_articles_by_date_range(start_date: str, end_date: str) -> li
|
|
| 33 |
Returns:
|
| 34 |
list[str]: A list of article titles promoted as Featured Articles during that period.
|
| 35 |
"""
|
|
|
|
| 36 |
try:
|
| 37 |
base_url = "https://en.wikipedia.org/wiki/Wikipedia:Featured_articles"
|
| 38 |
archive_url = "https://en.wikipedia.org/wiki/Wikipedia:Featured_articles_by_year"
|
|
@@ -52,7 +53,9 @@ def search_featured_articles_by_date_range(start_date: str, end_date: str) -> li
|
|
| 52 |
soup = BeautifulSoup(response.text, "html.parser")
|
| 53 |
for li in soup.select("li"):
|
| 54 |
text = li.get_text()
|
| 55 |
-
date_matches = re.findall(r"\b(19|20
|
|
|
|
|
|
|
| 56 |
for match in date_matches:
|
| 57 |
try:
|
| 58 |
d = datetime.strptime(match, "%Y-%m-%d")
|
|
@@ -79,6 +82,7 @@ def detect_non_commutative_subset(table_text: str) -> str:
|
|
| 79 |
Returns:
|
| 80 |
str: Comma-separated list of elements in alphabetical order that are involved in non-commutative cases.
|
| 81 |
"""
|
|
|
|
| 82 |
try:
|
| 83 |
import re
|
| 84 |
from collections import defaultdict
|
|
@@ -117,6 +121,9 @@ def extract_wikipedia_section_html(page_title: str, section_title: str, mode: st
|
|
| 117 |
Returns:
|
| 118 |
str: The section content based on the mode, or an error message if not found.
|
| 119 |
"""
|
|
|
|
|
|
|
|
|
|
| 120 |
try:
|
| 121 |
wikipedia.set_lang("en")
|
| 122 |
page = wikipedia.page(page_title)
|
|
|
|
| 33 |
Returns:
|
| 34 |
list[str]: A list of article titles promoted as Featured Articles during that period.
|
| 35 |
"""
|
| 36 |
+
print(f"🛠️ search_featured_articles_by_date_range called with: {start_date} , {end_date}")
|
| 37 |
try:
|
| 38 |
base_url = "https://en.wikipedia.org/wiki/Wikipedia:Featured_articles"
|
| 39 |
archive_url = "https://en.wikipedia.org/wiki/Wikipedia:Featured_articles_by_year"
|
|
|
|
| 53 |
soup = BeautifulSoup(response.text, "html.parser")
|
| 54 |
for li in soup.select("li"):
|
| 55 |
text = li.get_text()
|
| 56 |
+
date_matches = date_matches = re.findall(r"\b(19\d{2}|20\d{2})-\d{2}-\d{2}\b", text)
|
| 57 |
+
print("🔍 Date matches:", date_matches)
|
| 58 |
+
|
| 59 |
for match in date_matches:
|
| 60 |
try:
|
| 61 |
d = datetime.strptime(match, "%Y-%m-%d")
|
|
|
|
| 82 |
Returns:
|
| 83 |
str: Comma-separated list of elements in alphabetical order that are involved in non-commutative cases.
|
| 84 |
"""
|
| 85 |
+
print(f"🛠️ detect_non_commutative_subset called with: {table_text}")
|
| 86 |
try:
|
| 87 |
import re
|
| 88 |
from collections import defaultdict
|
|
|
|
| 121 |
Returns:
|
| 122 |
str: The section content based on the mode, or an error message if not found.
|
| 123 |
"""
|
| 124 |
+
|
| 125 |
+
print(f"🛠️ extract_wikipedia_section_html called with: {table_text}")
|
| 126 |
+
|
| 127 |
try:
|
| 128 |
wikipedia.set_lang("en")
|
| 129 |
page = wikipedia.page(page_title)
|