Update Home.py
Browse files
Home.py
CHANGED
|
@@ -3,6 +3,7 @@ import streamlit as st
|
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
import re
|
|
|
|
| 6 |
|
| 7 |
|
| 8 |
#===config===
|
|
@@ -40,7 +41,7 @@ c1, c2 = st.columns([6,4])
|
|
| 40 |
text_search = c1.text_input("Cari berdasarkan penulis, judul, hingga full-text. Pisahkan dengan semikolon (;)")
|
| 41 |
|
| 42 |
# Get keywords from search bar
|
| 43 |
-
keyword_list_j = [keyword.strip() for keyword in text_search.split(";")]
|
| 44 |
|
| 45 |
# option to choose
|
| 46 |
part_opt = ["Title", "Abstract (en)", "Abstract (id)", "Keywords", "Introduction", "Method", "Result", "Discussion", "Result & Discussion", "Conclusion", "Full-text"]
|
|
@@ -51,17 +52,30 @@ search_opt = c2.multiselect(
|
|
| 51 |
part_opt,
|
| 52 |
["Title", "Abstract (en)", "Keywords"])
|
| 53 |
|
|
|
|
|
|
|
| 54 |
#tab1, tab2 = st.tabs(["🔍 Hasil Pencarian", "📊 Analisis Hasil"])
|
| 55 |
|
| 56 |
|
| 57 |
if keyword_list_j is not None:
|
| 58 |
-
key_df_j = pd.DataFrame()
|
| 59 |
-
patterns = [r'\b{}\b'.format(re.escape(word)) for word in keyword_list_j]
|
| 60 |
|
| 61 |
-
for col in search_opt:
|
| 62 |
-
conditions = [df[col].str.contains(pattern, regex=True, flags=re.IGNORECASE) for pattern in patterns]
|
| 63 |
-
column_result = df[np.logical_and.reduce(conditions)]
|
| 64 |
-
key_df_j = pd.concat([key_df_j, column_result]).drop_duplicates()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# creating result
|
| 67 |
if text_search:
|
|
@@ -76,8 +90,6 @@ if keyword_list_j is not None:
|
|
| 76 |
red = popover.checkbox("Show red items.", True)
|
| 77 |
blue = popover.checkbox("Show blue items.", True)
|
| 78 |
|
| 79 |
-
|
| 80 |
-
|
| 81 |
@st.cache_data
|
| 82 |
def get_data(df):
|
| 83 |
df = pd.DataFrame(
|
|
@@ -89,7 +101,7 @@ if keyword_list_j is not None:
|
|
| 89 |
def convert_for_download(dfs):
|
| 90 |
return df.to_csv().encode("utf-8")
|
| 91 |
|
| 92 |
-
dfs = get_data(
|
| 93 |
csv = convert_for_download(dfs)
|
| 94 |
|
| 95 |
popover.download_button(
|
|
|
|
| 3 |
import pandas as pd
|
| 4 |
import numpy as np
|
| 5 |
import re
|
| 6 |
+
from eldar import Query
|
| 7 |
|
| 8 |
|
| 9 |
#===config===
|
|
|
|
| 41 |
text_search = c1.text_input("Cari berdasarkan penulis, judul, hingga full-text. Pisahkan dengan semikolon (;)")
|
| 42 |
|
| 43 |
# Get keywords from search bar
|
| 44 |
+
#keyword_list_j = [keyword.strip() for keyword in text_search.split(";")]
|
| 45 |
|
| 46 |
# option to choose
|
| 47 |
part_opt = ["Title", "Abstract (en)", "Abstract (id)", "Keywords", "Introduction", "Method", "Result", "Discussion", "Result & Discussion", "Conclusion", "Full-text"]
|
|
|
|
| 52 |
part_opt,
|
| 53 |
["Title", "Abstract (en)", "Keywords"])
|
| 54 |
|
| 55 |
+
|
| 56 |
+
|
| 57 |
#tab1, tab2 = st.tabs(["🔍 Hasil Pencarian", "📊 Analisis Hasil"])
|
| 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 |
+
@st.cache_data
|
| 69 |
+
def search_data(text_search):
|
| 70 |
+
df = key_df_j
|
| 71 |
+
key_df_j["__combined__"] = key_df_j[selected_cols].fillna("").agg(" ".join, axis=1)
|
| 72 |
+
query = Query(text_search, ignore_case=True)
|
| 73 |
+
key_df_j["df_result"] = key_df_j["__combined__"].apply(query)
|
| 74 |
+
|
| 75 |
+
return key_df_j
|
| 76 |
+
|
| 77 |
+
key_df_j = search_data(text_search)
|
| 78 |
+
st.write(key_df_j)
|
| 79 |
|
| 80 |
# creating result
|
| 81 |
if text_search:
|
|
|
|
| 90 |
red = popover.checkbox("Show red items.", True)
|
| 91 |
blue = popover.checkbox("Show blue items.", True)
|
| 92 |
|
|
|
|
|
|
|
| 93 |
@st.cache_data
|
| 94 |
def get_data(df):
|
| 95 |
df = pd.DataFrame(
|
|
|
|
| 101 |
def convert_for_download(dfs):
|
| 102 |
return df.to_csv().encode("utf-8")
|
| 103 |
|
| 104 |
+
dfs = get_data(key_df_j)
|
| 105 |
csv = convert_for_download(dfs)
|
| 106 |
|
| 107 |
popover.download_button(
|