Update app.py
Browse files
app.py
CHANGED
@@ -36,21 +36,16 @@ clear = st.button("Clear text input", on_click=clear_text)
|
|
36 |
|
37 |
if submit:
|
38 |
if text is not None:
|
39 |
-
df = []
|
40 |
-
df = pd.DataFrame(df, columns=['abstract'])
|
41 |
-
df.loc[0] = [text]
|
42 |
nlp = English()
|
43 |
sentencizer = nlp.add_pipe("sentencizer")
|
44 |
-
doc = nlp(
|
45 |
abstract_lines = [str(sent) for sent in list(doc.sents)]
|
46 |
-
|
47 |
-
sample_lines = [
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
sample_dict["total_lines"] = total_lines_in_sample - 1
|
53 |
-
sample_lines.append(sample_dict)
|
54 |
|
55 |
test = pd.DataFrame(sample_lines)
|
56 |
testing_sentences = test['text'].tolist()
|
@@ -60,9 +55,8 @@ if submit:
|
|
60 |
new_model_probs = new_model.predict(testing_dataset)
|
61 |
new_model_preds = tf.argmax(new_model_probs, axis=1)
|
62 |
test_pred_classes = [label_encoder.classes_[pred] for pred in new_model_preds]
|
63 |
-
test["prediction"] = test_pred_classes
|
64 |
test["pred_prob"] = tf.reduce_max(new_model_probs, axis=1).numpy()
|
65 |
-
dict_abstract = enumerate(abstract_lines)
|
66 |
|
67 |
-
for i, line in
|
68 |
st.write(f'{test_pred_classes[i]} : {line}')
|
|
|
36 |
|
37 |
if submit:
|
38 |
if text is not None:
|
|
|
|
|
|
|
39 |
nlp = English()
|
40 |
sentencizer = nlp.add_pipe("sentencizer")
|
41 |
+
doc = nlp(text)
|
42 |
abstract_lines = [str(sent) for sent in list(doc.sents)]
|
43 |
+
|
44 |
+
sample_lines = [{
|
45 |
+
"text": str(line),
|
46 |
+
"line_number": i,
|
47 |
+
"total_lines": len(abstract_lines) - 1
|
48 |
+
} for i, line in enumerate(abstract_lines)]
|
|
|
|
|
49 |
|
50 |
test = pd.DataFrame(sample_lines)
|
51 |
testing_sentences = test['text'].tolist()
|
|
|
55 |
new_model_probs = new_model.predict(testing_dataset)
|
56 |
new_model_preds = tf.argmax(new_model_probs, axis=1)
|
57 |
test_pred_classes = [label_encoder.classes_[pred] for pred in new_model_preds]
|
58 |
+
test["prediction"] = test_pred_classes
|
59 |
test["pred_prob"] = tf.reduce_max(new_model_probs, axis=1).numpy()
|
|
|
60 |
|
61 |
+
for i, line in enumerate(abstract_lines):
|
62 |
st.write(f'{test_pred_classes[i]} : {line}')
|