Spaces:
Sleeping
Sleeping
File size: 4,205 Bytes
46af628 14ff9c4 b62e42f 6169f27 02d9582 e2393a1 776f615 2fc2e11 02d9582 e2393a1 d70c8d8 e2393a1 6ca2a04 e2393a1 6ca2a04 e2393a1 6ca2a04 44e0cdf 6ca2a04 44e0cdf 6ca2a04 44e0cdf 6ca2a04 da7e215 44e0cdf 6ca2a04 e2393a1 6ca2a04 da7e215 61afaad 6ca2a04 b0e183d 6ca2a04 536d96b ae013ce 6ca2a04 cd42a41 6ca2a04 cd42a41 6ca2a04 c516297 7bb6ae5 efd14d3 043fe71 da7e215 e2393a1 e8ad8b1 c475583 da7e215 44e0cdf da7e215 6ca2a04 1e8bbcc 4fc18fb 6ca2a04 30f0829 6ca2a04 30f0829 6ca2a04 30f0829 6ca2a04 5b25195 da7e215 b3d7164 |
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 144 145 146 |
import streamlit as st
import pandas as pd
from huggingface_hub import Repository
import os
from pathlib import Path
import json
import numpy as np
# Declaring the variables for later use to talk to dataset
# the token is saved as secret key-value pair in the environment which can be access as shown below
#auth_token = os.environ.get("space_to_dataset") or True
#DATASET_REPO_URL = 'ppsingh/annotation_data' # path to dataset repo
#DATA_FILENAME = "paralist.json"
#DATA_FILE = os.path.join("data", DATA_FILENAME)
# cloning the dataset repo
#repo = Repository( local_dir="data", clone_from=DATASET_REPO_URL, repo_type="dataset", use_auth_token= auth_token)
# Data file name
#file_name = 'paralist.json'
# reading the json
#with open('data/{}'.format(file_name), 'r', encoding="utf8") as json_file:
# paraList = json.load(json_file)
# getting outer level keys in json
#keys = paraList.keys()
#data = pd.read_csv("test.csv")
# sidebar with info and drop down to select from the keys
#st.sidebar.markdown(
# """
# Data Annotation Demo
#This app is demo how to use the space to provide user interface for the data annotation/tagging. The data resides in repo_type 'dataset'.
#"""
#)
#topic = None
#if keys is not None:
# topic = st.sidebar.selectbox(
# label="Choose dataset topic to load", options=keys )
# st.write(line)
#st.write(paraList)
#if topic is not None:
# subtopics = list(paraList[topic].keys())
#st.write(subtopics)
# val = np.random.randint(0,len(subtopics)-1)
# choice = subtopics[val]
# st.write(choice)
#if np.random.randint(0,1) == 0:
# choice = "Gender"
#else:
# choice = "Women Empowernment"
# idx = np.random.randint(0,3)
# st.write(idx)
#c1, c2, c3 = st.columns([3, 1, 1])
#with c1:
# st.header('Text')
#st.write(paraList[topic][choice][idx]['textsegment'])
#with c2:
# st.header('Tag')
#st.text(choice)
# with c3:
#st.header('Feedback')
#feedback = None
# feedback = st.selectbox('0 If Tag is not a good keyword for text, 5 for prefect match',(0,1,2,3,4,5))
# if feedback:
# if st.button('Submit'):
# paraList[topic][choice][idx]['annotation'].append(feedback)
# with open('data/{}'.format(file_name), 'r', encoding="utf8") as json_file:
# json.dump(paraList,json_file, ensure_ascii = True)
# repo.push_to_hub('added new annotation')
#st.write(paraList)
#new_row = title
# data = data.append(new_row, ignore_index=True)
# st.write(data)
# st.write(os.getcwd())
# data.to_csv('test.csv', index= False)
#st.write(df)
# st.write('data/test.csv')
# iterate over files in
# that directory
#directory = os.getcwd()
#files = Path(directory).glob('*')
#for file in files:
# st.write(file)
#with open(DATA_FILE, "a") as csvfile:
# writer = csv.DictWriter(csvfile, fieldnames=["Sentences"])
# writer.writerow({'Sentences': new_row})
# repo.push_to_hub('adding new line')
# st.write('Succcess')
import streamlit as st
col1, col2, col3 = st.columns(3)
#session_state = st.session_state.get(col1=False, col2=False, col3=False)
st.session_state.col1 = False
st.session_state.col2 = False
st.session_state.col3 = False
col1_one = col1.button("CARTE", key="1")
col2_one = col2.button("TABLEAU", key="2")
col3_one = col3.button("SYNTHÈSE", key="3")
if col1_one or st.session_state.col1:
st.session_state.col1 = True
st.session_state.col2 = False
st.session_state.col3 = False
sel_Map = st.selectbox("Choose Map type :", options=['Hello1', 'Hello2'], index=1)
if sel_Map == 'Hello1':
st.write("Hello world! 1")
elif sel_Map == 'Hello2':
st.write("Hello world! 2")
if col2_one or st.session_state.col2:
st.session_state.col1 = False
st.session_state.col2 = True
st.session_state.col3 = False
st.write("Hello world! 3")
if col3_one or st.session_state.col3:
st.session_state.col1 = False
st.session_state.col2 = False
st.session_state.col3 = True
st.write("Hello world! 4")
if st.button('Refresh'):
st.session_state.col1 = False
st.session_state.col2 = False
st.session_state.col3 = False
|