yjunechoe / Snowglobe

Snowglobe
http://snowglobe.soc.northwestern.edu/
2 stars 0 forks source link

fetch abstracts after large search? #8

Closed mcweenysean closed 4 years ago

mcweenysean commented 4 years ago

One thing that crossed my mind was if someone decided they wanted abstracts after they ran a search. A "fetch abstracts from complete search" function might be nice - should be relatively easy to put in, right? I can work on this - do we already have the functions written for this or will I need to write a new one?

yjunechoe commented 4 years ago

Yeah so if you recall from my initial design (not sure if this part changed), there was a checkbox for fetching abstracts where if you check that box and press the Run Search button, the search will fetch abstracts after fetching paper info.

This is the part of the code that fetches abstracts and shows a progress bar while it does it (input$GetAbstracts is TRUE when box is checked):

https://github.com/yjunechoe/Snowballer/blob/81e952425f103e5665acaccd60388bffa836b4b9/server.R#L612-L631

The important piece of this is scrape.abst.ID(), which takes a vector of paper IDs and returns a dataframe with 2 columns: ID and Abstract.

So if you want to pass in the results from a search as input and add a column for abstracts and return that as output, that would look something like this:

search_result %>%
    mutate(Abstract = map_chr(ID, ~ scrape.abst.ID(.x)$Abstract))

Or you could run scrape.abst.ID() separately and then left_join() at a later point:

abstracts_df <- scrape.abst.ID(search_result$ID)

search_result %>%
    left_join(abstracts_df, by = "ID")

Or if you want to keep the progress bar, you can just recycle the big chunk of code above.

And if you want to trigger this with a button push, use observeEvent() - I have several examples of this in server.R

Hope this helps!

mcweenysean commented 4 years ago

I'm thinking this is unnecessary and I'm super busy so I'm going to close this one