Skip to content

Commit

Permalink
Added
Browse files Browse the repository at this point in the history
Add search language options: All, English, Vietnamese
Add command support commands in ADPN
  • Loading branch information
EndermanPC committed Feb 13, 2024
1 parent 227b130 commit 7b2b553
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 37 deletions.
17 changes: 17 additions & 0 deletions adpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,23 @@ def change_reliability_by_user_id(user_id, new_reliability):

if command == "exit":
exit()
elif command == "help":
print('''
exit: Exit ADPN.
help: This command.
clear: Clear the terminal.
start: Start the servers needed for MonoSearch.
api-config: Add the necessary API KEY environment variables to the servers.
atmt: Start ATMT STRT with keywords.
check: Lists the data that needs to be censored.
sync: Synchronize the censored database and the parent database (requirement: no data that needs to be censored).
sync-fts: Synchronize data in the root table with the virtual table.
log: Prints the server log.
users-list: Lists the list of users.
users-rel: Changes user reliability through their user id.
''')
elif command == "clear":
subprocess.call("cls", shell=True)
elif command == "start":
if os.environ.get('SG_API_KEY') is None or os.environ.get('GSB_API_KEY') is None:
print('The required API KEY to start the servers was not found, please use the "api-config" command to set the required environment API KEY variables.')
Expand Down
2 changes: 0 additions & 2 deletions log.txt
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
SYS: Loaded: users-account.db
SYS: Loaded: users-account.db
113 changes: 78 additions & 35 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import streamlit as st
import time
from langdetect import detect
from initializer.loader import database_loader
from manager.manager import *
from search.index import Search_Data
Expand Down Expand Up @@ -34,18 +35,19 @@

with col1:
keyword = st.text_input('Try to search something!', placeholder='Try to search something!', label_visibility='collapsed')
options_types = ['Text', 'Image', 'Video']
search_type = st.radio('Type:', options_types, index=0)
with col2:
submitted1 = st.form_submit_button('Search')
options_language = ['all', 'en', 'vi']
search_language = st.radio('Language:', options_language, index=0)
with col3:
submitted2 = st.form_submit_button('Add')
with col4:
submitted3 = st.form_submit_button('Edit')
with col5:
submitted4 = st.form_submit_button('Remove')

options_types = ['Text', 'Image', 'Video']
search_type = st.radio('', options_types, index=0)

if search_type == 'Text':
conn = conn0
elif search_type == 'Image':
Expand Down Expand Up @@ -105,43 +107,84 @@
if Search_Result is None:
st.write("No results found")
else:
for row in Search_Result:
row2 = return_special_characters(row[2])
row6 = return_special_characters(row[6])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
row_shorttext = row6.replace('\n', ' ')
row_shorttext = row_shorttext.replace('```', ' ')
st.markdown("### [" + row_title + ']' + '(' + row[1] + ') ' + '```' + str(row[0]) + '```')
st.markdown(row_shorttext)
st.markdown("   ")
if search_language == 'all':
for row in Search_Result:
row2 = return_special_characters(row[2])
row6 = return_special_characters(row[6])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
row_shorttext = row6.replace('\n', ' ')
row_shorttext = row_shorttext.replace('```', ' ')
st.markdown("### [" + row_title + ']' + '(' + row[1] + ') ' + '```' + str(row[0]) + '```')
st.markdown(row_shorttext)
st.markdown("   ")
else:
for row in Search_Result:
if detect(row[2]) == search_language or detect(row[6]) == search_language:
row2 = return_special_characters(row[2])
row6 = return_special_characters(row[6])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
row_shorttext = row6.replace('\n', ' ')
row_shorttext = row_shorttext.replace('```', ' ')
st.markdown("### [" + row_title + ']' + '(' + row[1] + ') ' + '```' + str(row[0]) + '```')
st.markdown(row_shorttext)
st.markdown("   ")
elif search_type == 'Image':
if Search_Result is None:
st.write("No results found")
else:
for i in range(0, len(Search_Result), 2):
cols = st.columns(2)
for j in range(2):
if i + j < len(Search_Result):
row = Search_Result[i + j]
cols[j].image(image=row[1])
row2 = return_special_characters(row[2])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
cols[j].markdown("### [" + row_title + ']' + '(' + row[1] + ')' + '```' + str(row[0]) + '```')
cols[j].markdown(row[4])
cols[j].markdown("   ")
if search_language == 'all':
for i in range(0, len(Search_Result), 2):
cols = st.columns(2)
for j in range(2):
if i + j < len(Search_Result):
row = Search_Result[i + j]
cols[j].image(image=row[1])
row2 = return_special_characters(row[2])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
cols[j].markdown("### [" + row_title + ']' + '(' + row[1] + ')' + '```' + str(row[0]) + '```')
cols[j].markdown(row[4])
cols[j].markdown("   ")
else:
for i in range(0, len(Search_Result), 2):
if detect(row[2]) == search_language:
cols = st.columns(2)
for j in range(2):
if i + j < len(Search_Result):
row = Search_Result[i + j]
cols[j].image(image=row[1])
row2 = return_special_characters(row[2])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
cols[j].markdown("### [" + row_title + ']' + '(' + row[1] + ')' + '```' + str(row[0]) + '```')
cols[j].markdown(row[4])
cols[j].markdown("   ")
elif search_type == 'Video':
if Search_Result is None:
st.write("No results found")
else:
for row in Search_Result:
col1, col2 = st.columns([1, 3])
col1.video(row[1])
row2 = return_special_characters(row[2])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
col2.markdown('```' + str(row[0]) + '``` ```' + row[1] + '```')
col2.markdown("### [" + row_title + ']' + '(' + row[1] + ')')
col2.markdown(row[7])
st.markdown("   ")
if search_language == 'all':
for row in Search_Result:
col1, col2 = st.columns([1, 3])
col1.video(row[1])
row2 = return_special_characters(row[2])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
col2.markdown('```' + str(row[0]) + '``` ```' + row[1] + '```')
col2.markdown("### [" + row_title + ']' + '(' + row[1] + ')')
col2.markdown(row[7])
st.markdown("   ")
else:
for row in Search_Result:
if detect(row[2]) == search_language:
col1, col2 = st.columns([1, 3])
col1.video(row[1])
row2 = return_special_characters(row[2])
row_title = row2.replace('\n', ' ')
row_title = row_title.replace(':', ' ')
col2.markdown('```' + str(row[0]) + '``` ```' + row[1] + '```')
col2.markdown("### [" + row_title + ']' + '(' + row[1] + ')')
col2.markdown(row[7])
st.markdown("   ")
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
langdetect
streamlit
sendgrid
requests
Expand Down

0 comments on commit 7b2b553

Please sign in to comment.