Spaces:
Build error
Build error
AhmedTaha012
commited on
Commit
•
ab1095f
1
Parent(s):
b54a28b
Update app.py
Browse files
app.py
CHANGED
@@ -10,6 +10,8 @@ from spacy import displacy
|
|
10 |
from word2number import w2n
|
11 |
from sentence_transformers import SentenceTransformer
|
12 |
from sklearn.metrics.pairwise import cosine_similarity
|
|
|
|
|
13 |
nltk.download('punkt')
|
14 |
nltk.download('stopwords')
|
15 |
|
@@ -231,10 +233,18 @@ def getQuarterPrediction(text):
|
|
231 |
logits = modelQuarter(**tokens).logits
|
232 |
predicted_class_id = logits.argmax().item()
|
233 |
return modelQuarter.config.id2label[predicted_class_id]
|
|
|
|
|
|
|
|
|
|
|
|
|
234 |
|
235 |
|
236 |
st.header("Transcript Analysis", divider='rainbow')
|
237 |
mainTranscript = st.text_area("Enter the transcript:", height=100)
|
|
|
|
|
238 |
quarter = st.text_input('Enter your quarter', '')
|
239 |
year = st.text_input('Enter your year', '')
|
240 |
if st.button("Analyze"):
|
@@ -280,26 +290,17 @@ if st.button("Analyze"):
|
|
280 |
profits=[x["profit"] for x in ner_result if "profit" in x]
|
281 |
revenues=[x["revenue"] for x in ner_result if "revenue" in x]
|
282 |
expences=[x["expense"] for x in ner_result if "expense" in x]
|
283 |
-
for idx in range(len(revenues)):
|
284 |
st.text_input(f'Revenue:{idx+1}', revenues[idx])
|
|
|
285 |
for idx in range(len(profits)):
|
286 |
st.text_input(f'Profit:{idx+1}', profits[idx])
|
|
|
287 |
for idx in range(len(expences)):
|
288 |
st.text_input(f'Expences:{idx+1}', expences[idx])
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
# entity_list=nlpPipe(chunks[idx])
|
293 |
-
# entities = []
|
294 |
-
# for entity in entity_list:
|
295 |
-
# span = doc.char_span(entity['start'], entity['end'], label=entity['entity_group'])
|
296 |
-
# entities.append(span)
|
297 |
-
# try:
|
298 |
-
# doc.ents = entities
|
299 |
-
# ent_html = displacy.render(doc, style="ent", jupyter=False)
|
300 |
-
# st.markdown(ent_html, unsafe_allow_html=True)
|
301 |
-
# except:
|
302 |
-
# pass
|
303 |
st.subheader("Investment Recommendation", divider='rainbow')
|
304 |
profitAmount=sum([convert_amount_to_number(x) for x in profits])
|
305 |
expencesAmount=sum([convert_amount_to_number(x) for x in expences])
|
|
|
10 |
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')
|
17 |
|
|
|
233 |
logits = modelQuarter(**tokens).logits
|
234 |
predicted_class_id = logits.argmax().item()
|
235 |
return modelQuarter.config.id2label[predicted_class_id]
|
236 |
+
def getSentence(listOfSentences,value):
|
237 |
+
for sent in listOfSentences:
|
238 |
+
if value in sent:
|
239 |
+
return sent
|
240 |
+
return value
|
241 |
+
|
242 |
|
243 |
|
244 |
st.header("Transcript Analysis", divider='rainbow')
|
245 |
mainTranscript = st.text_area("Enter the transcript:", height=100)
|
246 |
+
doc = nlp(mainTranscript)
|
247 |
+
sentences = [sent.text for sent in doc.sents]
|
248 |
quarter = st.text_input('Enter your quarter', '')
|
249 |
year = st.text_input('Enter your year', '')
|
250 |
if st.button("Analyze"):
|
|
|
290 |
profits=[x["profit"] for x in ner_result if "profit" in x]
|
291 |
revenues=[x["revenue"] for x in ner_result if "revenue" in x]
|
292 |
expences=[x["expense"] for x in ner_result if "expense" in x]
|
293 |
+
for idx in range(len(revenues)):
|
294 |
st.text_input(f'Revenue:{idx+1}', revenues[idx])
|
295 |
+
st.text_input(f'Sentences', getSentence(sentences,revenues[idx]))
|
296 |
for idx in range(len(profits)):
|
297 |
st.text_input(f'Profit:{idx+1}', profits[idx])
|
298 |
+
st.text_input(f'Sentences', getSentence(sentences,profits[idx]))
|
299 |
for idx in range(len(expences)):
|
300 |
st.text_input(f'Expences:{idx+1}', expences[idx])
|
301 |
+
st.text_input(f'Sentences', getSentence(sentences,expences[idx]))
|
302 |
+
|
303 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
304 |
st.subheader("Investment Recommendation", divider='rainbow')
|
305 |
profitAmount=sum([convert_amount_to_number(x) for x in profits])
|
306 |
expencesAmount=sum([convert_amount_to_number(x) for x in expences])
|