amoldwalunj commited on
Commit
5b0a40d
1 Parent(s): 0cc1ee9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from pyabsa import available_checkpoints
3
+ from pyabsa import ATEPCCheckpointManager
4
+
5
+ import os
6
+ #import tensorflow_hub as hub
7
+ import numpy as np
8
+ import pandas as pd
9
+ import json
10
+
11
+ checkpoint_map = available_checkpoints()
12
+
13
+ aspect_extractor = ATEPCCheckpointManager.get_aspect_extractor(checkpoint='english',
14
+ auto_device=True # False means load model on CPU
15
+ )
16
+
17
+
18
+
19
+ def main():
20
+ st.set_page_config(page_title="Aspect based sentiment Anslysis", page_icon=":smiley:", layout="wide")
21
+ st.title("Aspect based sentiment Anslysis :smiley:")
22
+
23
+
24
+
25
+ st.header("Aspect based sentiment Anslysis")
26
+ st.write("Enter a review:")
27
+ st.write("e.g. Purchased this for my device, it worked as advertised. You can never have too much phone memory, since I download a lot of stuff this was a no brainer for me.")
28
+ input_string = st.text_input("")
29
+
30
+
31
+
32
+ if st.button("Enter"):
33
+ st.write("Aspect and sentiment is:")
34
+
35
+ example=[]
36
+ example.append(input_string)
37
+
38
+ inference_source = examples
39
+ atepc_result = aspect_extractor.extract_aspect(inference_source=inference_source, #
40
+ pred_sentiment=True, # Predict the sentiment of extracted aspect terms
41
+ )
42
+
43
+ for aspect, sentiment in zip(atepc_result[0]['aspect'], atepc_result[0]['sentiment']):
44
+ st.write(aspect + ': ' + sentiment)
45
+
46
+
47
+ if __name__ == "__main__":
48
+ main()