-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslvc.py
144 lines (100 loc) · 3.68 KB
/
slvc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import streamlit as st
import pandas as pd
import numpy as np
### Laod the data ###
df = pd.read_csv("SLVC.csv")
### Utlities Functions ####
def _max_width_(prcnt_width:int = 90):
max_width_str = f"max-width: {prcnt_width}%;"
st.markdown(f"""
<style>
.reportview-container .main .block-container{{{max_width_str}}}
</style>
""",
unsafe_allow_html=True,
)
_max_width_()
def videoDisplayer(videoURLs):
if len(videoURLs) > 1:
col1.write("Results " + str(len(videoURLs)))
else:
col1.write("Results 0")
count = 0
nCols = int(len(videoURLs)/4)
while (count < len(videoURLs)):
columns = col_full.columns(4)
old_count = count
count +=4
urls = videoURLs.iloc[old_count:count]
for column, videoURL in zip(columns, urls):
column.video(videoURL)
def keywordSearch(input):
keywords = input.split(",")
videos = []
# videos = df.loc[df['PV_list_lemmtaized'].isin(keywords)]
for index, row in df.iterrows():
X = row["PV_list_lemmtaized"].replace(", ", ",")
VP_list = X.split(",")
# if x in ketwords and x in VP_list:
result = any(elem in keywords for elem in VP_list)
if result:
videos.append(row['File'])
return videos
### Forntend ####
st.header("The Second Language Video Complexity Corpus")
col1, col2 = st.columns([3, 1])
title = col1.text_input('Search videos')
search_option = col2.selectbox(
'Choose what to search?',
('All', 'Phrasal Verbs'))
if search_option == 'Phrasal Verbs':
selected_videos = keywordSearch(title)
if search_option == 'All':
selected_videos = keywordSearch(title)
expander = st.expander("Explore Data")
col_full = st.container()
#### Sidebar ####
with st.sidebar.form("my_form"):
st.subheader("Filter options")
video_gnere_option = st.selectbox(
"Select Video Genre",
("Academic Lectures", "Government advertisement")
)
video_gnere_option = list(video_gnere_option)
selected_videos = df.loc[df['Genre'].isin(video_gnere_option)]
accent_options = st.multiselect(
"Speaker's Accent",
['American', 'Australian', 'Canadian', 'British'],
['American']
)
accent_options = list(accent_options)
selected_videos = df.loc[df['Accent'].isin(accent_options)]
CEFR_options = st.selectbox(
"CEFR Levels",
('B1', '')
)
values = st.slider(
'Select a range of difficulty values',
5.0, 25.0, (10.0, 15.0))
values_list =list(values)
selected_videos = df[df['Difficulty'].between(values_list[0], values_list[1])]
COCA_list_options = st.radio(
'Lexical coverage',
('BNC/COCA K1', 'BNC/COCA K1-2', 'BNC/COCA K1-3', 'BNC/COCA K1-4', 'BNC/COCA K1-5'))
slider_val = st.slider("Lexical coverage %", 0,100, 10, step=10)
if COCA_list_options == 'BNC/COCA K1':
selected_videos = df[df['k1_percent'] < slider_val]
if COCA_list_options == 'BNC/COCA K1-2':
selected_videos = df[df['k1_2_percent'] < slider_val]
if COCA_list_options == 'BNC/COCA K1-3':
selected_videos = df[df['k1_3_percent'] < slider_val]
if COCA_list_options == 'BNC/COCA K1-4':
selected_videos = df[df['k1_4_percent'] < slider_val]
if COCA_list_options == 'BNC/COCA K1-5':
selected_videos = df[df['k1_5_percent'] < slider_val]
# Every form must have a submit button.
submitted = st.form_submit_button("Submit")
if submitted:
videoDisplayer(selected_videos['URL'])
else:
videoDisplayer(df['URL'][:50])