AhmedTaha012 commited on
Commit
a76e126
1 Parent(s): e8eee94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -11,6 +11,7 @@ from word2number import w2n
11
  from sentence_transformers import SentenceTransformer
12
  from sklearn.metrics.pairwise import cosine_similarity
13
  import en_core_web_sm
 
14
  nlp = en_core_web_sm.load()
15
  nltk.download('punkt')
16
  nltk.download('stopwords')
@@ -243,7 +244,9 @@ def getSentence(listOfSentences,value):
243
  if value in sent:
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,13 +300,16 @@ if st.button("Analyze"):
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])
 
11
  from sentence_transformers import SentenceTransformer
12
  from sklearn.metrics.pairwise import cosine_similarity
13
  import en_core_web_sm
14
+ from annotated_text import annotated_text
15
  nlp = en_core_web_sm.load()
16
  nltk.download('punkt')
17
  nltk.download('stopwords')
 
244
  if value in sent:
245
  return sent
246
  return value
247
+ def get_annotated_text(text,value,entity):
248
+ return [text.split(value)[0],(value,entity),text.split(value)[1]]
249
+
250
  st.header("Transcript Analysis", divider='rainbow')
251
  mainTranscript = st.text_area("Enter the transcript:", height=100)
252
  doc = nlp(mainTranscript)
 
300
  expences=[x["expense"] for x in ner_result if "expense" in x]
301
  for idx in range(len(revenues)):
302
  st.text_input(f'Revenue:{idx+1}', revenues[idx])
303
+ annotated_text(get_annotated_text(getSentence(sentences,revenues[idx]),str(revenues[idx]),"Revenue"))
304
+ # st.text_input(f'Revenue-Sentence:{idx+1}', getSentence(sentences,revenues[idx]))
305
  for idx in range(len(profits)):
306
  st.text_input(f'Profit:{idx+1}', profits[idx])
307
+ annotated_text(get_annotated_text(getSentence(sentences,revenues[idx]),str(revenues[idx]),"Profit"))
308
+ # st.text_input(f'Profit-Sentence:{idx+1}', getSentence(sentences,profits[idx]))
309
  for idx in range(len(expences)):
310
  st.text_input(f'Expences:{idx+1}', expences[idx])
311
+ annotated_text(get_annotated_text(getSentence(sentences,revenues[idx]),str(revenues[idx]),"Expences"))
312
+ # st.text_input(f'Expences-Sentences:{idx+1}', getSentence(sentences,expences[idx]))
313
 
314
  st.subheader("Investment Recommendation", divider='rainbow')
315
  profitAmount=sum([convert_amount_to_number(x) for x in profits])