Spaces:
Runtime error
Runtime error
Commit
·
62497e0
1
Parent(s):
d439e5c
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,64 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import datasets
|
3 |
+
from datasets import load_dataset
|
4 |
+
import pandas as pd
|
5 |
+
from streamlit.components.v1 import html
|
6 |
+
from streamlit import markdown
|
7 |
+
import re
|
8 |
+
import os
|
9 |
+
import time
|
10 |
+
|
11 |
+
import json
|
12 |
+
|
13 |
+
|
14 |
+
st.title('StackOverflow Question Demo.')
|
15 |
+
|
16 |
+
library = st.radio('Select a library', ('numpy', 'tensorflow', 'pytorch', 'scipy', 'scikit-learn', 'pandas'))
|
17 |
+
|
18 |
+
#question_path = './{}.txt'.format(library)
|
19 |
+
question_path = 'numpy.txt'
|
20 |
+
# loading stackoverflow questions.
|
21 |
+
# using huggingface load_dataset function.
|
22 |
+
# not done yet
|
23 |
+
#@st.cache
|
24 |
+
#def load_data(path):
|
25 |
+
# return load_dataset('text', data_files = path, cache_dir = './data')
|
26 |
+
|
27 |
+
|
28 |
+
dataset = []
|
29 |
+
#dataset = load_data(question_path)
|
30 |
+
with open(question_path) as f:
|
31 |
+
lines = f.readlines()
|
32 |
+
question = ''
|
33 |
+
temp = {}
|
34 |
+
tag = ''
|
35 |
+
for line in lines:
|
36 |
+
if line == 'Origin:\n' or line == 'Function:\n' or re.match(r'A\d:\n', line):
|
37 |
+
if not tag:
|
38 |
+
tag = line[:-2]
|
39 |
+
else:
|
40 |
+
temp[tag] = question
|
41 |
+
question = ''
|
42 |
+
tag = line[:-2]
|
43 |
+
else:
|
44 |
+
if tag:
|
45 |
+
question += line
|
46 |
+
|
47 |
+
dataset.append(temp)
|
48 |
+
|
49 |
+
# Select index
|
50 |
+
number = st.number_input("Insert a index: range from",
|
51 |
+
min_value = 0, max_value = len(dataset) - 1)
|
52 |
+
st.write('The current index is ', number)
|
53 |
+
data_index = int(number)
|
54 |
+
|
55 |
+
# Selece modification
|
56 |
+
options = tuple(dataset[data_index].keys())
|
57 |
+
modification = st.radio('Which modification would you choose?',
|
58 |
+
options = options
|
59 |
+
)
|
60 |
+
|
61 |
+
|
62 |
+
st.write(dataset[data_index][modification])
|
63 |
+
|
64 |
+
|