Spaces:
Runtime error
Runtime error
domenicrosati
commited on
Commit
β’
a776895
1
Parent(s):
03de2e8
improve snippet matching
Browse files
app.py
CHANGED
@@ -64,24 +64,22 @@ def search(term, limit=10, clean=True, strict=True, abstracts=True):
|
|
64 |
)
|
65 |
|
66 |
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
def find_source(text, docs):
|
71 |
for doc in docs:
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
|
|
85 |
return None
|
86 |
|
87 |
|
|
|
64 |
)
|
65 |
|
66 |
|
|
|
|
|
|
|
67 |
def find_source(text, docs):
|
68 |
for doc in docs:
|
69 |
+
for snippet in doc[1]:
|
70 |
+
if text in remove_html(snippet.get('snippet', '')):
|
71 |
+
new_text = text
|
72 |
+
for snip in remove_html(snippet.get('snippet', '')).split('.'):
|
73 |
+
if text in snip:
|
74 |
+
new_text = snip
|
75 |
+
return {
|
76 |
+
'citation_statement': snippet['snippet'].replace('<strong class="highlight">', '').replace('</strong>', ''),
|
77 |
+
'text': new_text,
|
78 |
+
'from': snippet['source'],
|
79 |
+
'supporting': snippet['target'],
|
80 |
+
'source_title': doc[2],
|
81 |
+
'source_link': f"https://scite.ai/reports/{doc[0]}"
|
82 |
+
}
|
83 |
return None
|
84 |
|
85 |
|