AhmedTaha012 commited on
Commit
e8eee94
·
1 Parent(s): ffce0c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -47
app.py CHANGED
@@ -28,15 +28,11 @@ model = AutoModelForTokenClassification.from_pretrained("AhmedTaha012/finance-ne
28
  # torch.compile(model)
29
  nlpPipe = pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
30
 
31
-
32
-
33
  if "disabled" not in st.session_state:
34
  st.session_state["disabled"] = False
35
-
36
  def disable():
37
  st.session_state["disabled"] = True
38
 
39
-
40
  def getSpeakers(data):
41
  if "Speakers" in data:
42
  return "\n".join([x for x in data.split("Speakers")[-1].split("\n") if "--" in x])
@@ -86,7 +82,6 @@ def clean_and_preprocess(text):
86
  l.append(cleaned_text)
87
  return "\n".join(l)
88
  def replace_abbreviations(text):
89
-
90
  replacements = {
91
  'Q1': 'first quarter',
92
  'Q2': 'second quarter',
@@ -142,39 +137,39 @@ def replace_abbreviations(text):
142
  'EBITDAR margin': 'earnings before interest, taxes, depreciation, amortization, and rent margin',
143
  'ROIC': 'return on invested capital',
144
  'EPS': 'earnings per share',
145
- 'P/E': 'price-to-earnings',
146
- 'EBITDA': 'earnings before interest, taxes, depreciation, and amortization',
147
- 'YOY': 'year-over-year',
148
- 'MOM': 'month-over-month',
149
- 'CAGR': 'compound annual growth rate',
150
- 'GDP': 'gross domestic product',
151
- 'ROI': 'return on investment',
152
- 'ROE': 'return on equity',
153
- 'EBIT': 'earnings before interest and taxes',
154
- 'DCF': 'discounted cash flow',
155
- 'GAAP': 'Generally Accepted Accounting Principles',
156
- 'LTM': 'last twelve months',
157
- 'EBIT margin': 'earnings before interest and taxes margin',
158
- 'EBT': 'earnings before taxes',
159
- 'EBTA': 'earnings before taxes and amortization',
160
- 'FTE': 'full-time equivalent',
161
- 'EBIDTA': 'earnings before interest, depreciation, taxes, and amortization',
162
- 'EBTIDA': 'earnings before taxes, interest, depreciation, and amortization',
163
- 'EBITDAR': 'earnings before interest, taxes, depreciation, amortization, and rent',
164
- 'COGS': 'cost of goods sold',
165
- 'APR': 'annual percentage rate',
166
- 'PESTEL': 'Political, Economic, Social, Technological, Environmental, and Legal',
167
- 'KPI': 'key performance indicator',
168
- 'SWOT': 'Strengths, Weaknesses, Opportunities, Threats',
169
- 'CAPEX': 'capital expenditures',
170
- 'EBITDARM': 'earnings before interest, taxes, depreciation, amortization, rent, and management fees',
171
- 'EBITDAX': 'earnings before interest, taxes, depreciation, amortization, and exploration expenses',
172
- 'EBITDAS': 'earnings before interest, taxes, depreciation, amortization, and restructuring costs',
173
- 'EBITDAX-C': 'earnings before interest, taxes, depreciation, amortization, exploration expenses, and commodity derivatives',
174
- 'EBITDAX-R': 'earnings before interest, taxes, depreciation, amortization, exploration expenses, and asset retirement obligations',
175
- 'EBITDAX-E': 'earnings before interest, taxes, depreciation, amortization, exploration expenses, and environmental liabilities'
176
-
177
- # Add more abbreviations and replacements as needed
178
  }
179
  for abbreviation, full_form in replacements.items():
180
  text = text.replace(abbreviation, full_form)
@@ -249,8 +244,6 @@ def getSentence(listOfSentences,value):
249
  return sent
250
  return value
251
 
252
-
253
-
254
  st.header("Transcript Analysis", divider='rainbow')
255
  mainTranscript = st.text_area("Enter the transcript:", height=100)
256
  doc = nlp(mainTranscript)
@@ -304,15 +297,14 @@ if st.button("Analyze"):
304
  expences=[x["expense"] for x in ner_result if "expense" in x]
305
  for idx in range(len(revenues)):
306
  st.text_input(f'Revenue:{idx+1}', revenues[idx])
307
- st.text_input(f'Sentences', getSentence(sentences,revenues[idx]),key=idx**2)
308
  for idx in range(len(profits)):
309
  st.text_input(f'Profit:{idx+1}', profits[idx])
310
- st.text_input(f'Sentences', getSentence(sentences,profits[idx]),key=idx**3)
311
  for idx in range(len(expences)):
312
  st.text_input(f'Expences:{idx+1}', expences[idx])
313
- st.text_input(f'Sentences', getSentence(sentences,expences[idx]),key=idx**4)
314
 
315
-
316
  st.subheader("Investment Recommendation", divider='rainbow')
317
  profitAmount=sum([convert_amount_to_number(x) for x in profits])
318
  expencesAmount=sum([convert_amount_to_number(x) for x in expences])
@@ -320,6 +312,3 @@ if st.button("Analyze"):
320
  st.markdown(f'<span style="color:green">{"This is a great chance for investment. Do consider it."}</span>', unsafe_allow_html=True)
321
  else:
322
  st.markdown(f'<span style="color:red">{"Not the best chance for investment."}</span>', unsafe_allow_html=True)
323
-
324
-
325
-
 
28
  # torch.compile(model)
29
  nlpPipe = pipeline("ner", model=model, tokenizer=tokenizer, grouped_entities=True)
30
 
 
 
31
  if "disabled" not in st.session_state:
32
  st.session_state["disabled"] = False
 
33
  def disable():
34
  st.session_state["disabled"] = True
35
 
 
36
  def getSpeakers(data):
37
  if "Speakers" in data:
38
  return "\n".join([x for x in data.split("Speakers")[-1].split("\n") if "--" in x])
 
82
  l.append(cleaned_text)
83
  return "\n".join(l)
84
  def replace_abbreviations(text):
 
85
  replacements = {
86
  'Q1': 'first quarter',
87
  'Q2': 'second quarter',
 
137
  'EBITDAR margin': 'earnings before interest, taxes, depreciation, amortization, and rent margin',
138
  'ROIC': 'return on invested capital',
139
  'EPS': 'earnings per share',
140
+ 'P/E': 'price-to-earnings',
141
+ 'EBITDA': 'earnings before interest, taxes, depreciation, and amortization',
142
+ 'YOY': 'year-over-year',
143
+ 'MOM': 'month-over-month',
144
+ 'CAGR': 'compound annual growth rate',
145
+ 'GDP': 'gross domestic product',
146
+ 'ROI': 'return on investment',
147
+ 'ROE': 'return on equity',
148
+ 'EBIT': 'earnings before interest and taxes',
149
+ 'DCF': 'discounted cash flow',
150
+ 'GAAP': 'Generally Accepted Accounting Principles',
151
+ 'LTM': 'last twelve months',
152
+ 'EBIT margin': 'earnings before interest and taxes margin',
153
+ 'EBT': 'earnings before taxes',
154
+ 'EBTA': 'earnings before taxes and amortization',
155
+ 'FTE': 'full-time equivalent',
156
+ 'EBIDTA': 'earnings before interest, depreciation, taxes, and amortization',
157
+ 'EBTIDA': 'earnings before taxes, interest, depreciation, and amortization',
158
+ 'EBITDAR': 'earnings before interest, taxes, depreciation, amortization, and rent',
159
+ 'COGS': 'cost of goods sold',
160
+ 'APR': 'annual percentage rate',
161
+ 'PESTEL': 'Political, Economic, Social, Technological, Environmental, and Legal',
162
+ 'KPI': 'key performance indicator',
163
+ 'SWOT': 'Strengths, Weaknesses, Opportunities, Threats',
164
+ 'CAPEX': 'capital expenditures',
165
+ 'EBITDARM': 'earnings before interest, taxes, depreciation, amortization, rent, and management fees',
166
+ 'EBITDAX': 'earnings before interest, taxes, depreciation, amortization, and exploration expenses',
167
+ 'EBITDAS': 'earnings before interest, taxes, depreciation, amortization, and restructuring costs',
168
+ 'EBITDAX-C': 'earnings before interest, taxes, depreciation, amortization, exploration expenses, and commodity derivatives',
169
+ 'EBITDAX-R': 'earnings before interest, taxes, depreciation, amortization, exploration expenses, and asset retirement obligations',
170
+ 'EBITDAX-E': 'earnings before interest, taxes, depreciation, amortization, exploration expenses, and environmental liabilities'
171
+
172
+ # Add more abbreviations and replacements as needed
173
  }
174
  for abbreviation, full_form in replacements.items():
175
  text = text.replace(abbreviation, full_form)
 
244
  return sent
245
  return value
246
 
 
 
247
  st.header("Transcript Analysis", divider='rainbow')
248
  mainTranscript = st.text_area("Enter the transcript:", height=100)
249
  doc = nlp(mainTranscript)
 
297
  expences=[x["expense"] for x in ner_result if "expense" in x]
298
  for idx in range(len(revenues)):
299
  st.text_input(f'Revenue:{idx+1}', revenues[idx])
300
+ st.text_input(f'Revenue-Sentence:{idx+1}', getSentence(sentences,revenues[idx]))
301
  for idx in range(len(profits)):
302
  st.text_input(f'Profit:{idx+1}', profits[idx])
303
+ st.text_input(f'Profit-Sentence:{idx+1}', getSentence(sentences,profits[idx]))
304
  for idx in range(len(expences)):
305
  st.text_input(f'Expences:{idx+1}', expences[idx])
306
+ st.text_input(f'Expences-Sentences:{idx+1}', getSentence(sentences,expences[idx]))
307
 
 
308
  st.subheader("Investment Recommendation", divider='rainbow')
309
  profitAmount=sum([convert_amount_to_number(x) for x in profits])
310
  expencesAmount=sum([convert_amount_to_number(x) for x in expences])
 
312
  st.markdown(f'<span style="color:green">{"This is a great chance for investment. Do consider it."}</span>', unsafe_allow_html=True)
313
  else:
314
  st.markdown(f'<span style="color:red">{"Not the best chance for investment."}</span>', unsafe_allow_html=True)