Skip to content

Commit eef8484

Browse files
author
louyk18
committed
append bib tex
1 parent f477d36 commit eef8484

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

python/graphy/apps/graph_analyzer.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,31 @@ def write_report(self, query, mind_map, max_token_per_subsection):
8787
)
8888

8989
result = self.generate("get_report", report_prompt)
90+
91+
bib_text = self.append_bib_text(result, {})
92+
result += bib_text
93+
9094
return result
95+
96+
def append_bib_text(self, text, id2bib):
97+
bib_text = ""
98+
cited_papers = set()
99+
matches = re.findall(r"\\cite{(.*?)}", text)
100+
101+
for match in matches:
102+
if "," in match:
103+
match_texts = match.split(",")
104+
for match_text in match_texts:
105+
cited_papers.add(match_text.strip())
106+
else:
107+
cited_papers.add(match.strip())
108+
109+
logger.debug(f"CITED PAPERS ARE {cited_papers}")
110+
111+
for paper_id in cited_papers:
112+
if paper_id in id2bib and id2bib[paper_id]:
113+
bib_text += "\n" + id2bib[paper_id] + "\n"
114+
else:
115+
bib_text += "\n" + f"bib of {paper_id}" + "\n"
116+
117+
return bib_text

0 commit comments

Comments
 (0)