mgmtprofessor commited on
Commit
fa4a747
·
verified ·
1 Parent(s): d428815

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -9,7 +9,7 @@ from transformers import AutoModelForSequenceClassification, AutoTokenizer
9
  # Set up Streamlit app
10
  st.title("An App to Score Firm-Generated Text on Eight Risk Factors")
11
  st.write("Note: You can either upload a CSV file or a single TXT file for scoring.")
12
- st.write("If uploading a CSV file, ensure that it contains the following columns: cik, fyear, Item 1A. Item 1A should contain the respective risk factors section for each firm-year observation.")
13
  st.write("If uploading a txt file, ensure it contains the respective risk factors section for each firm-year observation.")
14
  # Hugging Face model directories
15
  model_directories = {
@@ -63,7 +63,7 @@ def score_document(model, tokenizer, text_data):
63
 
64
  # Function to find the relevant text column
65
  def get_text_column(df):
66
- possible_columns = ['Item 1A', 'Item 1A.', 'Item 1A. Risk Factors']
67
  for col in possible_columns:
68
  if col in df.columns:
69
  return col
@@ -87,7 +87,7 @@ if file_type == "CSV":
87
  text_column = get_text_column(df)
88
 
89
  if text_column is None:
90
- st.error("No valid text column found. Please ensure your CSV contains 'Item 1A', 'Item 1A.', or 'Item 1A. Risk Factors'.")
91
  else:
92
  # Extract text data from the identified column
93
  text_data = df[text_column].dropna().tolist() # Extracts all non-empty rows
 
9
  # Set up Streamlit app
10
  st.title("An App to Score Firm-Generated Text on Eight Risk Factors")
11
  st.write("Note: You can either upload a CSV file or a single TXT file for scoring.")
12
+ st.write("If uploading a CSV file, ensure that it contains the following columns: cik, fyear, Item 1A (or Text). Item 1A should contain the respective risk factors section for each firm-year observation.")
13
  st.write("If uploading a txt file, ensure it contains the respective risk factors section for each firm-year observation.")
14
  # Hugging Face model directories
15
  model_directories = {
 
63
 
64
  # Function to find the relevant text column
65
  def get_text_column(df):
66
+ possible_columns = ['Item 1A', 'Item 1A.', 'Item 1A. Risk Factors', 'text', 'Text']
67
  for col in possible_columns:
68
  if col in df.columns:
69
  return col
 
87
  text_column = get_text_column(df)
88
 
89
  if text_column is None:
90
+ st.error("No valid text column found. Please ensure your CSV contains 'Item 1A', 'Item 1A.', 'Item 1A. Risk Factors', 'Text', or 'text'.")
91
  else:
92
  # Extract text data from the identified column
93
  text_data = df[text_column].dropna().tolist() # Extracts all non-empty rows