Update Home.py
Browse files
Home.py
CHANGED
|
@@ -26,20 +26,17 @@ def connect_gsheet():
|
|
| 26 |
|
| 27 |
df = connect_gsheet()
|
| 28 |
|
| 29 |
-
st.write(df)
|
| 30 |
-
|
| 31 |
-
#paramx = st.query_params["art"]
|
| 32 |
-
#st.write(paramx)
|
| 33 |
|
| 34 |
#Title
|
| 35 |
st.title('TXTperpus: Article')
|
| 36 |
|
| 37 |
# Intro text
|
| 38 |
-
st.caption(f"
|
| 39 |
c1, c2, c3 = st.columns([5,2,3])
|
| 40 |
|
| 41 |
# The search bar
|
| 42 |
-
text_search = c1.text_input("
|
| 43 |
|
| 44 |
# Get keywords from search bar
|
| 45 |
keyword_list_j = [keyword.strip() for keyword in text_search.split(";")]
|
|
@@ -51,36 +48,41 @@ part_opt = ["Title", "Abstract (en)", "Abstract (id)", "Keywords", "Introduction
|
|
| 51 |
s_bhs = ["ID", "EN"]
|
| 52 |
sel_bahasa = c2.selectbox("Bahasa", s_bhs)
|
| 53 |
search_opt = c3.multiselect(
|
| 54 |
-
"
|
| 55 |
part_opt,
|
| 56 |
["Title", "Abstract (en)", "Keywords"])
|
| 57 |
|
| 58 |
|
| 59 |
-
|
| 60 |
-
if keyword_list_j is not None:
|
| 61 |
-
key_df_j = pd.DataFrame()
|
| 62 |
-
patterns = [r'\b{}\b'.format(re.escape(word)) for word in keyword_list_j]
|
| 63 |
-
|
| 64 |
-
for col in search_opt:
|
| 65 |
-
conditions = [df[col].str.contains(pattern, regex=True, flags=re.IGNORECASE) for pattern in patterns]
|
| 66 |
-
column_result = df[np.logical_and.reduce(conditions)]
|
| 67 |
-
key_df_j = pd.concat([key_df_j, column_result]).drop_duplicates()
|
| 68 |
|
| 69 |
-
|
| 70 |
-
if text_search:
|
| 71 |
-
st.caption(f"We found **{key_df_j.shape[0]}** article(s) available for you.")
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
df = connect_gsheet()
|
| 28 |
|
| 29 |
+
#st.write(df)
|
|
|
|
|
|
|
|
|
|
| 30 |
|
| 31 |
#Title
|
| 32 |
st.title('TXTperpus: Article')
|
| 33 |
|
| 34 |
# Intro text
|
| 35 |
+
st.caption(f"Eksplorasi dari **{df.shape[0]}** artikel yang dihimpun oleh TXTperpus.")
|
| 36 |
c1, c2, c3 = st.columns([5,2,3])
|
| 37 |
|
| 38 |
# The search bar
|
| 39 |
+
text_search = c1.text_input("Cari berdasarkan penulis, judul, hingga full-text. Pisahkan dengan semikolon (;)")
|
| 40 |
|
| 41 |
# Get keywords from search bar
|
| 42 |
keyword_list_j = [keyword.strip() for keyword in text_search.split(";")]
|
|
|
|
| 48 |
s_bhs = ["ID", "EN"]
|
| 49 |
sel_bahasa = c2.selectbox("Bahasa", s_bhs)
|
| 50 |
search_opt = c3.multiselect(
|
| 51 |
+
"Pilih kolom",
|
| 52 |
part_opt,
|
| 53 |
["Title", "Abstract (en)", "Keywords"])
|
| 54 |
|
| 55 |
|
| 56 |
+
tab1, tab2 = st.tabs(["π Hasil Pencarian", "π Analisis Hasil"], width="stretch")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
+
with tab1:
|
|
|
|
|
|
|
| 59 |
|
| 60 |
+
if keyword_list_j is not None:
|
| 61 |
+
key_df_j = pd.DataFrame()
|
| 62 |
+
patterns = [r'\b{}\b'.format(re.escape(word)) for word in keyword_list_j]
|
| 63 |
+
|
| 64 |
+
for col in search_opt:
|
| 65 |
+
conditions = [df[col].str.contains(pattern, regex=True, flags=re.IGNORECASE) for pattern in patterns]
|
| 66 |
+
column_result = df[np.logical_and.reduce(conditions)]
|
| 67 |
+
key_df_j = pd.concat([key_df_j, column_result]).drop_duplicates()
|
| 68 |
+
|
| 69 |
+
# creating result
|
| 70 |
+
if text_search:
|
| 71 |
+
st.caption(f"Kami menemukan **{key_df_j.shape[0]}** artikel yang sesuai dengan apa yang dicari.")
|
| 72 |
+
|
| 73 |
+
for _, row in key_df_j.reset_index().iterrows():
|
| 74 |
+
with st.container(border=True):
|
| 75 |
+
col1, col2 = st.columns([7,3])
|
| 76 |
+
col1.markdown(f"**{row['Title'].strip()}**")
|
| 77 |
+
col2.caption(f"**{row['Journal'].strip()}, {row['Volume'].strip()} ({row['Issue'].strip()}) - {row['Year'].strip()}**")
|
| 78 |
+
|
| 79 |
+
st.markdown(f"**{row['Authors'].strip()}**")
|
| 80 |
|
| 81 |
+
btn1, btn2, btn3 = st.columns([2,2,6])
|
| 82 |
+
popover = btn1.popover("Abstract", icon="π€", help="Click to Read Abstract", use_container_width=False)
|
| 83 |
+
popover.write(row['Abstract (en)'].strip() if row['Abstract (en)'] else "No abstract available.")
|
| 84 |
+
btn2.link_button("DOI", row["DOI"].strip(), icon="π")
|
| 85 |
+
btn3.link_button("Read", f"https://faizhalas-perpusdb.hf.space/reader?art={row['ID'].strip()}", icon="π")
|
| 86 |
+
|
| 87 |
+
with tab2:
|
| 88 |
+
st.write("Dalam pembangunan")
|