eljanmahammadli commited on
Commit
8c8c07f
·
1 Parent(s): 744d9e3

#feat added reference section to the end

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -218,9 +218,10 @@ def generate_cited_html(cited_text, citations: dict):
218
  citation_numbers = {}
219
  next_number = 1
220
  citation_count = 0 # To track unique instances of each citation
 
221
 
222
  def replace_citations(match):
223
- nonlocal citation_count, next_number
224
  citation_id = match.group(1) # Extract citation number from the match
225
  ref_data = citations.get(int(citation_id))
226
 
@@ -243,6 +244,9 @@ def generate_cited_html(cited_text, citations: dict):
243
 
244
  if citation_id not in citation_numbers:
245
  citation_numbers[citation_id] = next_number
 
 
 
246
  next_number += 1
247
  citation_number = citation_numbers[citation_id]
248
 
@@ -266,6 +270,7 @@ def generate_cited_html(cited_text, citations: dict):
266
 
267
  # Replace inline citations in the text with the generated HTML
268
  html_code += re.sub(r"<(\d+)>", replace_citations, cited_text)
 
269
  html_code += "</div>"
270
  return html_code
271
 
 
218
  citation_numbers = {}
219
  next_number = 1
220
  citation_count = 0 # To track unique instances of each citation
221
+ references = "<b>References:</b><br><br>"
222
 
223
  def replace_citations(match):
224
+ nonlocal citation_count, next_number, references
225
  citation_id = match.group(1) # Extract citation number from the match
226
  ref_data = citations.get(int(citation_id))
227
 
 
244
 
245
  if citation_id not in citation_numbers:
246
  citation_numbers[citation_id] = next_number
247
+ source = ref_data["source"]
248
+ content = ref_data["content"]
249
+ references += f"[{next_number}] {source}<br>- {content}<br><br>"
250
  next_number += 1
251
  citation_number = citation_numbers[citation_id]
252
 
 
270
 
271
  # Replace inline citations in the text with the generated HTML
272
  html_code += re.sub(r"<(\d+)>", replace_citations, cited_text)
273
+ html_code += "<br><br>" + references
274
  html_code += "</div>"
275
  return html_code
276