File size: 2,063 Bytes
0d0f07a
 
 
14c3a4f
0d0f07a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14c3a4f
0d0f07a
14c3a4f
0d0f07a
 
 
14c3a4f
0d0f07a
14c3a4f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0d0f07a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from streamlit_option_menu import option_menu
from word2vec import *
import pandas as pd

st.set_page_config(page_title="Ancient Greek Word2Vec", layout="centered")

# Horizontal menu
active_tab = option_menu(None, ["Nearest neighbours", "Cosine similarity", "3D graph", 'Dictionary'], 
    menu_icon="cast", default_index=0, orientation="horizontal")

# Nearest neighbours tab
if active_tab == "Nearest neighbours":
    st.write("### TO DO: add description of function")
    col1, col2 = st.columns(2)
    with st.container():
        with col1:
            word = st.text_input("Enter a word", placeholder="ἀνήρ")
            
        with col2:
            time_slice = st.selectbox("Time slice", ["Archaic", "Classical", "Hellenistic", "Early Roman", "Late Roman"])
        
        n = st.slider("Number of neighbours", 1, 50, 15)
        
        nearest_neighbours_button = st.button("Find nearest neighbours")
        
        # If the button to calculate nearest neighbours is clicked
        if nearest_neighbours_button:
            
            # Rewrite timeslices to model names: Archaic -> archaic_cbow
            time_slice = time_slice.lower() + "_cbow"
            st.write(time_slice)
            
            # Check if all fields are filled in
            if validate_nearest_neighbours(word, time_slice, n) == False:
                st.error('Please fill in all fields')
            else:
                nearest_neighbours = get_nearest_neighbours(word, time_slice, n)
                df = pd.DataFrame(nearest_neighbours, columns=["Word", "Time slice", "Similarity"])
                st.table(df)
                
                
                
        
    
# Cosine similarity tab
elif active_tab == "Cosine similarity":
    with st.container():
        st.write("Cosine similarity tab")

# 3D graph tab
elif active_tab == "3D graph":
    with st.container():
        st.write("3D graph tab")

# Dictionary tab
elif active_tab == "Dictionary":
    with st.container():
        st.write("Dictionary tab")