import os import streamlit as st import streamlit.components.v1 as components from datasets import load_dataset from pyserini.search.lucene import LuceneSearcher st.set_page_config(page_title="IMDB Search", layout="wide") st.sidebar.markdown( """

IMDB Search

""", unsafe_allow_html=True, ) st.sidebar.markdown( """ """, unsafe_allow_html=True, ) query = st.sidebar.text_input(label="Search query", value="") footer = """ """ st.sidebar.markdown(footer, unsafe_allow_html=True) searcher = LuceneSearcher("index") ds = load_dataset("imdb", split="train") def search(query): hits = searcher.search(query, k=10) results = ds.select([int(hit.docid) for hit in hits]) return results["text"] if st.sidebar.button("Search 🔍"): results = search(query) results_html = "" for result in results: results_html += result + "




" rendered_results = f"""
{results_html}
""" components.html( rendered_results, height=800, scrolling=True, )