bluesearch.widgets.search_widget module¶
The Search widget.
- class SearchWidget(**kwargs)[source]¶
Bases:
ipywidgets.widgets.widget_box.VBox
Widget for search engine.
- Parameters
bbs_search_url (str) – The URL of the bbs_search server.
bbs_mysql_engine (sqlalchemy.engine.Engine) – Engine for connections to the bbs_mysql server.
article_saver (bluesearch.widgets.ArticleSaver, optional) – If specified, this article saver will keep all the article_id of interest for the user during the different queries.
results_per_page (int, optional) – The number of results to display per results page.
checkpoint_path (str or pathlib.Path, optional) – Path where checkpoints are saved to and loaded from. If None, defaults to ~/.cache/bluesearch/widgets_checkpoints.
- static highlight_in_paragraph(paragraph, sentence)[source]¶
Highlight a given sentence in the paragraph.
- Parameters
paragraph (str) – The paragraph in which to highlight the sentence.
sentence (str) – The sentence to highlight.
- Returns
formatted_paragraph – The paragraph containing sentence with the sentence highlighted in color
- Return type
str
- print_single_result(result_info, print_whole_paragraph)[source]¶
Retrieve metadata and complete the report with HTML string given sentence_id.
- Parameters
result_info (dict) – The information for a single result obtained by calling _fetch_result_info.
print_whole_paragraph (bool) – If true, the whole paragraph will be displayed in the results of the widget.
- Returns
article_metadata (str) – Formatted string containing the metadata of the article.
formatted_output (str) – Formatted output of the sentence.
- saved_results()[source]¶
Get all search results that were flagged for saving.
- Returns
saved_items_df – A data frame with all saved search results.
- Return type
pd.DataFrame
- set_page(new_page, force=False)[source]¶
Go to a given page in the results view.
- Parameters
new_page (int) – The new page number to go to.
force (bool) – By default, if new_page is the same one as the one currently viewed, the the page is not reloaded. To reload the page set this parameter to True. This is ueful when new results have been fetched and so the view needs to be updated.