Spaces:
Sleeping
Sleeping
Upload 4 files
Browse files- app.py +25 -0
- read_vocab.py +8 -0
- requirements.txt +1 -0
- vocab_clean.xlsx +0 -0
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import random
|
4 |
+
from read_vocab import read_vocab
|
5 |
+
|
6 |
+
|
7 |
+
st.title('中考考纲词汇练习')
|
8 |
+
|
9 |
+
n_samples = st.slider('选择要抽取的词汇数量:', 5, 20, 10, 5)
|
10 |
+
|
11 |
+
df = read_vocab()
|
12 |
+
df_new = pd.DataFrame(columns=df.columns)
|
13 |
+
|
14 |
+
if st.button('生成默写词汇'):
|
15 |
+
st.session_state['random_numbers'] = random.sample(range(1841), n_samples)
|
16 |
+
|
17 |
+
for i in st.session_state['random_numbers']:
|
18 |
+
df_new = pd.concat([df_new, df[i:i+1]])
|
19 |
+
|
20 |
+
st.session_state['df_new'] = df_new
|
21 |
+
|
22 |
+
if st.checkbox('显示中英独照'):
|
23 |
+
st.dataframe(st.session_state['df_new'])
|
24 |
+
else:
|
25 |
+
st.dataframe(st.session_state['df_new']['英文'])
|
read_vocab.py
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pandas as pd
|
2 |
+
|
3 |
+
|
4 |
+
def read_vocab(vocab_file = 'vocab_clean.xlsx'):
|
5 |
+
df = pd.read_excel(vocab_file)
|
6 |
+
df = df[['英文', '中文']]
|
7 |
+
|
8 |
+
return df
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
pandas
|
vocab_clean.xlsx
ADDED
Binary file (60.6 kB). View file
|
|