citations
langroid/utils/output/citations.py
extract_markdown_references(md_string)
¶
Extracts markdown references (e.g., [^1], [^2]) from a string and returns them as a sorted list of integers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
md_string
|
str
|
The markdown string containing references. |
required |
Returns:
Type | Description |
---|---|
List[int]
|
list[int]: A sorted list of unique integers from the markdown references. |
Source code in langroid/utils/output/citations.py
format_footnote_text(content, width=0)
¶
Formats the content so that each original line is individually processed. - If width=0, no wrapping is done (lines remain as is). - If width>0, lines are wrapped to that width. - Blank lines remain blank (with indentation). - Everything is indented by 4 spaces (for markdown footnotes).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
The text of the footnote to be formatted. |
required |
width
|
int
|
Maximum width of the text lines. If 0, lines are not wrapped. |
0
|
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
Properly formatted markdown footnote text. |
Source code in langroid/utils/output/citations.py
format_cited_references(citations, passages)
¶
Given a list of (integer) citations, and a list of passages, return a string that can be added as a footer to the main text, to show sources cited.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
citations
|
list[int]
|
list of citations, presumably from main text |
required |
passages
|
list[Document]
|
list of passages (Document objects) |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
formatted string of citations for footnote in markdown |