Spaces:
Running
Running
Rename app_5.py to app_6.py
Browse files- app_5.py → app_6.py +11 -2
app_5.py → app_6.py
RENAMED
@@ -137,12 +137,21 @@ def extract_arguments(text, tokenizer, model, beam_search=True):
|
|
137 |
"""Marks text in the original string based on character positions."""
|
138 |
# Inserts tags into the original text based on token offsets.
|
139 |
if start_token is not None and end_token is not None:
|
140 |
-
if start_token <= end_token:
|
141 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
|
143 |
start_idx, end_idx = offset_mapping[start_token][0], offset_mapping[end_token][1]
|
144 |
|
145 |
if start_idx is not None and end_idx is not None and start_idx < end_idx:
|
|
|
|
|
146 |
return (
|
147 |
original_text[:start_idx]
|
148 |
+ f"<mark style='background-color:{color}; padding:2px; border-radius:4px;'>"
|
@@ -151,7 +160,7 @@ def extract_arguments(text, tokenizer, model, beam_search=True):
|
|
151 |
+ original_text[end_idx:]
|
152 |
)
|
153 |
|
154 |
-
return
|
155 |
|
156 |
|
157 |
|
|
|
137 |
"""Marks text in the original string based on character positions."""
|
138 |
# Inserts tags into the original text based on token offsets.
|
139 |
if start_token is not None and end_token is not None:
|
|
|
140 |
|
141 |
+
st.write(f"Start: {start_token}, End: {end_token}")
|
142 |
+
|
143 |
+
|
144 |
+
if start_token > end_token:
|
145 |
+
return None
|
146 |
+
|
147 |
+
if start_token <= end_token:
|
148 |
+
|
149 |
|
150 |
start_idx, end_idx = offset_mapping[start_token][0], offset_mapping[end_token][1]
|
151 |
|
152 |
if start_idx is not None and end_idx is not None and start_idx < end_idx:
|
153 |
+
st.write(f"Start_idx: {start_idx}, End_idx: {end_idx}")
|
154 |
+
|
155 |
return (
|
156 |
original_text[:start_idx]
|
157 |
+ f"<mark style='background-color:{color}; padding:2px; border-radius:4px;'>"
|
|
|
160 |
+ original_text[end_idx:]
|
161 |
)
|
162 |
|
163 |
+
return original_text
|
164 |
|
165 |
|
166 |
|