Spaces:
Sleeping
Sleeping
grapplerulrich
commited on
Commit
·
2decb45
1
Parent(s):
2f05319
Add keyword search to strings
Browse files
app.py
CHANGED
@@ -76,6 +76,12 @@ def exception_notice( exception ):
|
|
76 |
else:
|
77 |
st.warning(str(exception))
|
78 |
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
def main():
|
80 |
st.title('Racoon Search')
|
81 |
query = st.text_input('Search query')
|
@@ -110,7 +116,11 @@ def main():
|
|
110 |
url_id = uuid.uuid5( uuid.NAMESPACE_URL, result['link'] ).hex
|
111 |
try:
|
112 |
strings = get_url_content( result['link'] )
|
113 |
-
|
|
|
|
|
|
|
|
|
114 |
summary = content_summary( url_id, content )
|
115 |
for sentence in summary:
|
116 |
st.write(sentence['summary_text'])
|
|
|
76 |
else:
|
77 |
st.warning(str(exception))
|
78 |
|
79 |
+
def is_keyword_in_string( keywords, string ):
|
80 |
+
for keyword in keywords:
|
81 |
+
if keyword in string:
|
82 |
+
return True
|
83 |
+
return False
|
84 |
+
|
85 |
def main():
|
86 |
st.title('Racoon Search')
|
87 |
query = st.text_input('Search query')
|
|
|
116 |
url_id = uuid.uuid5( uuid.NAMESPACE_URL, result['link'] ).hex
|
117 |
try:
|
118 |
strings = get_url_content( result['link'] )
|
119 |
+
keywords = query.split(' ')
|
120 |
+
content = ''
|
121 |
+
for string in strings:
|
122 |
+
if is_keyword_in_string( keywords, string ):
|
123 |
+
content += string + '\n'
|
124 |
summary = content_summary( url_id, content )
|
125 |
for sentence in summary:
|
126 |
st.write(sentence['summary_text'])
|