Spaces:
Running
Running
Update main.py
Browse files
main.py
CHANGED
@@ -196,9 +196,25 @@ async def __ocr(im, file_id):
|
|
196 |
|
197 |
return out
|
198 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
199 |
async def __convert2md(inp):
|
200 |
# Use gfm-raw_html to strip styling data from source file
|
201 |
-
|
|
|
|
|
202 |
|
203 |
async def __convert2plain(inp):
|
204 |
return await __convert_text(inp, "plain", "html")
|
@@ -541,7 +557,7 @@ async def generate_questions(request):
|
|
541 |
|
542 |
# print(raw_segmented)
|
543 |
seg_index = 0
|
544 |
-
seg_index_map = ['Q
|
545 |
raw_segmented = []
|
546 |
print(o['content'])
|
547 |
for seg in o['content'].split('\n'):
|
|
|
196 |
|
197 |
return out
|
198 |
|
199 |
+
def convert_links_to_text(text):
|
200 |
+
"""Converts all Markdown links in a string to their link text.
|
201 |
+
|
202 |
+
Args:
|
203 |
+
text: The input string containing Markdown links.
|
204 |
+
|
205 |
+
Returns:
|
206 |
+
The modified string with links replaced by their text.
|
207 |
+
"""
|
208 |
+
|
209 |
+
link_pattern = r"\[(.*?)\]\(.*?\)"
|
210 |
+
return re.sub(link_pattern, r"\1", text)
|
211 |
+
|
212 |
+
|
213 |
async def __convert2md(inp):
|
214 |
# Use gfm-raw_html to strip styling data from source file
|
215 |
+
converted = await __convert_text(inp, "gfm-raw_html", "html")
|
216 |
+
converted_without_link = convert_links_to_text(converted)
|
217 |
+
return converted_without_link
|
218 |
|
219 |
async def __convert2plain(inp):
|
220 |
return await __convert_text(inp, "plain", "html")
|
|
|
557 |
|
558 |
# print(raw_segmented)
|
559 |
seg_index = 0
|
560 |
+
seg_index_map = ['Q', 'A', 'B', 'C', 'D', '{']
|
561 |
raw_segmented = []
|
562 |
print(o['content'])
|
563 |
for seg in o['content'].split('\n'):
|