schematise/ICAT-v1-Query
0
1import streamlit as st2import get_results3import pandas as pd4import pipelineoperation5import json6import insert_data7 8#st.image("/home/sankalp-user/Pictures/schematiselda.png")9 10st.write("<h4>Please visit the <a href='https://sankalpsrv.in/blog'>detailed blog post </a> and <a href = 'https://deepnote.com/workspace/mutaabik-bb27ba89-ef3a-49de-b973-2fca2f4c74b7/project/ICAT-Beta-90d69f02-b39a-4259-98fa-d4c4ad7d7557/notebook/Notebook%201-8b7b316e2a394f56ae2b43e06e1530f1'>Data Analytics Platform </a> for more and; See more by Schematise on <a href = 'https://linktr.ee/schematiselda'> Linktree </a> <br> <a href='https://www.buymeacoffee.com/schematise' target='_blank'><img src='https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png' alt='Buy Me A Coffee' style='height: 60px;width: 217px;' ></a></a> </h4>", unsafe_allow_html=True) 11 12st.image("./ikanoon6_powered_transparent.png")13 14#st.write("<a href = 'https://huggingface.co/datasets/schematise/ICAT-version1/blob/main/Competition.pdf'> <b> SEE THE QUERY COMPETITION RULES HERE </b> </a>", unsafe_allow_html=True)15 16 17 18#st.image("./")19 20st.title("Get example contract clauses - ICAT Query Pipeline (BETA)")21 22searchquery = st.text_input("Search query for type of contracts e.g. 'arbitration', 'termination', 'trademark licensing'")23 24results = get_results.main(searchquery)25 26 27#st.dataframe(results)28 29if results:30 df = pd.DataFrame(results)31 dict_results = df.to_dict('records')32else:33 st.warning("No results found. This may be because the database is not properly configured or no matching data exists.")34 df = pd.DataFrame() # Empty DataFrame35 dict_results = []36 37st.button("Generate/View results after text-classification")38 39# Serialize and write the dictionary to a file40with open("Dict_Results.txt", "w") as fn:41 json.dump(dict_results, fn)42 43if st.button:44 results_from_classifier = pipelineoperation.pipeline_operations(dict_results)45else:46 results_from_classifier = {}47 48with open ("ResultsAfterClassification.txt", "w") as fn:49 fn.write(str(results_from_classifier))50 51try:52 53 dict_from_classified_results = [{'Title': result['Title'],54 'Matching clauses': result['matching_columns_after_classification'] + result['matching_indents_after_classification']55 } for result in results_from_classifier]56 57 filtered_data_list = [item for item in dict_from_classified_results if item.get('Matching clauses')]58 59 df_to_display = pd.DataFrame(filtered_data_list)60 st.dataframe(df_to_display)61 62 insert_data.add_classified_results(results_from_classifier, searchquery)63 64except Exception as e:65 print(f"Error code: {e}")66 st.write("Error: Click on the generate button if you haven't already")67 68 