Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -233,24 +233,23 @@ def create_embeddings(texts_to_embedd):
|
|
233 |
|
234 |
def predict(text_input, sample_size_slider, reduce_sample_checkbox, progress=gr.Progress()):
|
235 |
|
236 |
-
|
237 |
-
|
238 |
|
239 |
query, params = openalex_url_to_pyalex_query(text_input)
|
240 |
query_length = query.count()
|
|
|
241 |
|
242 |
records = []
|
243 |
total_pages = (query_length + 199) // 200 # Calculate total number of pages
|
244 |
-
|
245 |
|
246 |
-
for i, record in
|
247 |
records.append(record)
|
248 |
|
249 |
-
# Calculate progress from 0 to 0.1
|
250 |
-
achieved_progress = min(0., (i + 1) / query_length * 0.1)
|
251 |
|
252 |
# Update progress bar
|
253 |
-
progress(
|
254 |
|
255 |
|
256 |
|
@@ -410,9 +409,11 @@ with gr.Blocks() as block:
|
|
410 |
gr.Markdown("""
|
411 |
## Mapping OpenAlex-Queries
|
412 |
|
413 |
-
|
414 |
-
You're a philosopher of science who wonders where the concept of a fitness landscape has appeared...
|
415 |
""")
|
|
|
|
|
|
|
416 |
|
417 |
with gr.Column():
|
418 |
text_input = gr.Textbox(label="OpenAlex Fulltext-Search")
|
@@ -434,7 +435,8 @@ with gr.Blocks() as block:
|
|
434 |
def setup_basemap_data():
|
435 |
# get data.
|
436 |
print("getting basemap data...")
|
437 |
-
basedata_df = load("100k_filtered_OA_sample_cluster_and_positions.bz")
|
|
|
438 |
print(basedata_df)
|
439 |
return basedata_df
|
440 |
|
|
|
233 |
|
234 |
def predict(text_input, sample_size_slider, reduce_sample_checkbox, progress=gr.Progress()):
|
235 |
|
236 |
+
print('getting data to project')
|
237 |
+
progress(0, desc="Starting...")
|
238 |
|
239 |
query, params = openalex_url_to_pyalex_query(text_input)
|
240 |
query_length = query.count()
|
241 |
+
print(f'Requesting {query_length} entries...')
|
242 |
|
243 |
records = []
|
244 |
total_pages = (query_length + 199) // 200 # Calculate total number of pages
|
245 |
+
per_page = 0.3 / total_pages
|
246 |
|
247 |
+
for i, record in enumerate(chain(*query.paginate(per_page=200))):
|
248 |
records.append(record)
|
249 |
|
|
|
|
|
250 |
|
251 |
# Update progress bar
|
252 |
+
progress(per_page * i, desc="Getting queried data...")
|
253 |
|
254 |
|
255 |
|
|
|
409 |
gr.Markdown("""
|
410 |
## Mapping OpenAlex-Queries
|
411 |
|
412 |
+
Enter the URL to an OpenAlex-search below. It will take a few minutes, but then the result will be projected onto a map of the OA database as a whole.
|
|
|
413 |
""")
|
414 |
+
|
415 |
+
# This is a tool to further interdisciplinary research – you are a neuroscientist who has used ..., What have the ... been doing with them.
|
416 |
+
# You're a philosopher of science who wonders where the concept of a fitness landscape has appeared...
|
417 |
|
418 |
with gr.Column():
|
419 |
text_input = gr.Textbox(label="OpenAlex Fulltext-Search")
|
|
|
435 |
def setup_basemap_data():
|
436 |
# get data.
|
437 |
print("getting basemap data...")
|
438 |
+
#basedata_df = load("100k_filtered_OA_sample_cluster_and_positions.bz")
|
439 |
+
base_data_df =pickle.load(open('100k_filtered_OA_sample_cluster_and_positions.pkl', 'rb'))
|
440 |
print(basedata_df)
|
441 |
return basedata_df
|
442 |
|