Spaces:
Sleeping
Sleeping
add sliders
Browse files26 unmodified lines272829303132335 unmodified lines3940414243444546474849505152535455565758596061626364656667685 unmodified lines747576777879808182838485868788899091929394959697989926 unmodified lines)return dscol1, col2, _ = st.columns([1, 1, 4])with col1:chosen_language = st.sidebar.selectbox(5 unmodified lines)st.sidebar.header("Filters")not_lexable = st.sidebar.checkbox("Not lexable?")low_alphanum = st.sidebar.checkbox("Low alphanum count?")long_lines = st.sidebar.checkbox("Long lines?")# load the dataset and get indexes of non lexable filessamples = load_data(chosen_language, chosen_ext)if not_lexable:samples = samples.filter(lambda x: not x["lexable"])if low_alphanum:samples = samples.filter(lambda x: x["low_alphanum"])if long_lines:samples = samples.filter(lambda x: x["long_lines"])max_docs = len(samples)samples = samples.add_column("idx", range(len(samples)))# info about extension# st.sidebar.markdown("### Information about the extension:")# text = f"Extension {chosen_ext} has {max_docs} files, {df[df['extension'] == chosen_ext]['low_alphanum_count'].values[0]} with very low alphanumeric ratio, \# {df[df['extension'] == chosen_ext]['long_lines_count'].values[0]} with very long lines, and {df[df['extension'] == chosen_ext]['non_lexable_count'].values[0]} \# are not lexable.\n These files are at indexes:\n {indexes_not_lexed}."# st.sidebar.markdown(text)if max_docs > 0:col_1, _ = st.columns([3, 3])5 unmodified linesvalue=0,step=1,)# info about the chosen exampleexample = samples[index_example]# st.markdown("#### Information about the chosen example:")# text_alpha = "**has**" if example["long_lines"] else "doesn't have"# text_lines = "**has**" if example["low_alphanum"] else "doesn't have"# text_lexer = "is" if example["lexable"] else "**isn't**"# st.markdown(# f"Example {index_example} {text_alpha} a very low alphanumeric ratio, \# {text_lines} very long lines, and {text_lexer} lexable."# )# display file contentst.markdown("#### File content:")if not example["lexable"]:st.write(f"File can't be lexed so we remove syntax highlighting.\nContent:\n")st.text(example['content'])else:st.code(example["content"], language=chosen_language)26 unmodified lines2728293031325 unmodified lines38394041424344454647484950515253545556575859606162635 unmodified lines6970717273747576777879808126 unmodified lines)return dscol1, col2, _ = st.columns([1, 1, 4])with col1:chosen_language = st.sidebar.selectbox(5 unmodified lines)st.sidebar.header("Filters")not_lexable = st.sidebar.checkbox("Not lexable")min_alphanum = st.sidebar.slider("Minimum alphanumeric fraction", 0.0, 1.0, 0.25)max_line_length = st.sidebar.slider("Maximum line length", 0, 1000, 100)max_mean_line_length = st.sidebar.slider("Maximum average line length", 0, 2000, 1000)st.sidebar.markdown("Printed files have `max_line_length` and `average_line_length` larger than the selected values.\`alphanumeric_fraction` is smaller than the selected value.")samples = load_data(chosen_language, chosen_ext)samples = samples.filter(lambda x: x["alphanum_fraction"] < min_alphanumand x["max_line_length"] > max_line_lengthand x["avg_line_length"] > max_mean_line_length)if not_lexable:samples = samples.filter(lambda x: not x["lexable"])max_docs = len(samples)samples = samples.add_column("idx", range(len(samples)))if max_docs > 0:col_1, _ = st.columns([3, 3])5 unmodified linesvalue=0,step=1,)# info about the chosen exampleexample = samples[index_example]st.markdown("#### File content:")if example["lexable"]:st.code(example["content"], language=chosen_language)else:st.text(f"File can't be lexed so we remove syntax highlighting.\nContent:\n")st.text(str(example["content"]))
app.py+17-35