mitiku commited on
Commit
43ec03e
·
verified ·
1 Parent(s): ea78d37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -47,7 +47,9 @@ def parse_md_link(md_link: str) -> Tuple[str, str]:
47
  """ parse markdown link to the title and link"""
48
  pattern = r'\[([^\]]+)\]\(([^)]+)\)'
49
  matches = re.findall(pattern, md_link)
50
- return matches
 
 
51
 
52
  def search_specific_website(topic: str, url: str, num_results: int):
53
  query = f"{url} {topic}"
@@ -56,7 +58,10 @@ def search_specific_website(topic: str, url: str, num_results: int):
56
  output = []
57
  for result in query_result:
58
  link, description = result.split("\n")
59
- title, url = parse_md_link(link)
 
 
 
60
  output.append(SearchResult(title=title, url=url, description=description))
61
  return output
62
 
@@ -88,7 +93,7 @@ def search_arxiv(topic: str, year: str = None, num_results: int = 10) -> str:
88
 
89
  output = []
90
  for result in query_results:
91
- output.append("Title: {} Abstract: {}".format(result.title, get_arxiv_paper_abstract(result.url)))
92
  return "\n\n".join(output)
93
 
94
 
 
47
  """ parse markdown link to the title and link"""
48
  pattern = r'\[([^\]]+)\]\(([^)]+)\)'
49
  matches = re.findall(pattern, md_link)
50
+ if len(matches) > 0:
51
+ return matches[0]
52
+ return None
53
 
54
  def search_specific_website(topic: str, url: str, num_results: int):
55
  query = f"{url} {topic}"
 
58
  output = []
59
  for result in query_result:
60
  link, description = result.split("\n")
61
+ title_url = parse_md_link(link)
62
+ if title_url is None:
63
+ continue
64
+ title, url = title_url
65
  output.append(SearchResult(title=title, url=url, description=description))
66
  return output
67
 
 
93
 
94
  output = []
95
  for result in query_results:
96
+ output.append("Title: {}\nAbstract: {}".format(result.title, get_arxiv_paper_abstract(result.url)))
97
  return "\n\n".join(output)
98
 
99