Spaces:
Build error
Build error
Commit
·
63c8a1e
1
Parent(s):
aab99cb
Update app.py
Browse files
app.py
CHANGED
@@ -210,10 +210,11 @@ def selectedCorpusForNextQuarterModel(x,quarter):
|
|
210 |
chunksAttention_mask=[tokens["attention_mask"][r*splitSize:(r+1)*splitSize] for r in range(math.ceil(len(tokens["attention_mask"])/splitSize))]
|
211 |
l=[]
|
212 |
for idx in range(len(chunksInput_ids)):
|
213 |
-
l.append({"input_ids":torch.tensor([list(
|
214 |
-
"token_type_ids":torch.tensor([list(
|
215 |
-
"attention_mask":torch.tensor([list(
|
216 |
-
})
|
|
|
217 |
selectedTopics = ["Stock Movement", "Earnings", "IPO", "Stock Commentary", "Currencies", "M&A | Investments", "Financials", "Macro", "Analyst Update", "Company | Product News"]
|
218 |
result = [tokenizerTopic.decode(x["input_ids"][0], skip_special_tokens=True) for x in l if getTopic(x) in selectedTopics]
|
219 |
result=[x for x in result if len(x)>10]
|
@@ -244,7 +245,7 @@ if st.button("Analyze"):
|
|
244 |
st.markdown(f'<span style="color:{sentiment_color}">{sentiment}</span>', unsafe_allow_html=True)
|
245 |
st.subheader("Next Quarter Perdiction", divider='rainbow')
|
246 |
# increase_decrease = [increase_decrease_model(x)[0]['label'] for x in chunks]
|
247 |
-
|
248 |
increase_decrease=max(increase_decrease,key=increase_decrease.count)
|
249 |
increase_decrease_color = "green" if increase_decrease == "Increase" else "red"
|
250 |
st.markdown(f'<span style="color:{increase_decrease_color}">{increase_decrease}</span>', unsafe_allow_html=True)
|
@@ -260,7 +261,7 @@ if st.button("Analyze"):
|
|
260 |
while idxx<len(ents):
|
261 |
if len(ents[idxx]["word"].split())==2:
|
262 |
ner_result.append({ents[idxx]["entity_group"]:ents[idxx]["word"]})
|
263 |
-
|
264 |
try:
|
265 |
ner_result.append({ents[idxx]["entity_group"]:ents[idxx]["word"]+ents[idxx+1]["word"]+ents[idxx+2]["word"]})
|
266 |
idxx=idxx+2
|
|
|
210 |
chunksAttention_mask=[tokens["attention_mask"][r*splitSize:(r+1)*splitSize] for r in range(math.ceil(len(tokens["attention_mask"])/splitSize))]
|
211 |
l=[]
|
212 |
for idx in range(len(chunksInput_ids)):
|
213 |
+
l.append({"input_ids":torch.tensor([list(chunksInput_ids[idx])]).to("cuda"),
|
214 |
+
"token_type_ids":torch.tensor([list(chunksToken_type_ids[idx])]).to("cuda"),
|
215 |
+
"attention_mask":torch.tensor([list(chunksAttention_mask[idx])]).to("cuda")
|
216 |
+
})
|
217 |
+
|
218 |
selectedTopics = ["Stock Movement", "Earnings", "IPO", "Stock Commentary", "Currencies", "M&A | Investments", "Financials", "Macro", "Analyst Update", "Company | Product News"]
|
219 |
result = [tokenizerTopic.decode(x["input_ids"][0], skip_special_tokens=True) for x in l if getTopic(x) in selectedTopics]
|
220 |
result=[x for x in result if len(x)>10]
|
|
|
245 |
st.markdown(f'<span style="color:{sentiment_color}">{sentiment}</span>', unsafe_allow_html=True)
|
246 |
st.subheader("Next Quarter Perdiction", divider='rainbow')
|
247 |
# increase_decrease = [increase_decrease_model(x)[0]['label'] for x in chunks]
|
248 |
+
increase_decrease=increase_decrease_model(selectedCorpusForNextQuarterModel(mainTranscript,quarter))[0]['label']
|
249 |
increase_decrease=max(increase_decrease,key=increase_decrease.count)
|
250 |
increase_decrease_color = "green" if increase_decrease == "Increase" else "red"
|
251 |
st.markdown(f'<span style="color:{increase_decrease_color}">{increase_decrease}</span>', unsafe_allow_html=True)
|
|
|
261 |
while idxx<len(ents):
|
262 |
if len(ents[idxx]["word"].split())==2:
|
263 |
ner_result.append({ents[idxx]["entity_group"]:ents[idxx]["word"]})
|
264 |
+
elif len(ents[idxx]["word"].split())==1:
|
265 |
try:
|
266 |
ner_result.append({ents[idxx]["entity_group"]:ents[idxx]["word"]+ents[idxx+1]["word"]+ents[idxx+2]["word"]})
|
267 |
idxx=idxx+2
|