Hafizhzpa commited on
Commit
aecb12d
·
verified ·
1 Parent(s): 6bab979

add status

Browse files
Files changed (1) hide show
  1. app.py +3 -2
app.py CHANGED
@@ -13,7 +13,7 @@ class NewsAnalytic():
13
  self.model = T5ForZeroShotClassification.from_pretrained('knowledgator/comprehend_it-multilingual-t5-base')
14
  self.tokenizer = T5Tokenizer.from_pretrained('knowledgator/comprehend_it-multilingual-t5-base')
15
  self.classifier = ZeroShotClassificationPipeline(model=self.model, tokenizer=self.tokenizer,ypothesis_template = '{}', encoder_decoder = True)
16
- nltk.download('punkt')
17
  def anoted_sentence(self,content,candidate_labels):
18
  sentences = nltk.sent_tokenize(content)
19
  sentences = [sent for sent in sentences if "simak" not in sent.lower()]
@@ -24,6 +24,7 @@ class NewsAnalytic():
24
  else:
25
  summary_result="neutral"
26
  pair_result=[(res['sequence'],res['labels'][0]) if res['labels'][0]!="neutral" else res['sequence'] for res in result]
 
27
  return pair_result, summary_result
28
  def get_news_content(self,url):
29
  response = requests.get(url)
@@ -40,7 +41,7 @@ class NewsAnalytic():
40
  paragraphs = soup.find_all('p')
41
  content = ' '.join([p.get_text() for p in paragraphs])
42
  content = ' '.join([text for text in content.split("\n") if len(text)>100])
43
-
44
  return {'title': title.strip(), 'content': content.strip()}
45
  def streamlit_run(self):
46
  st.markdown("<h2 style='text-align: center;'>Indonesian News Analytic </h2>", unsafe_allow_html=True)
 
13
  self.model = T5ForZeroShotClassification.from_pretrained('knowledgator/comprehend_it-multilingual-t5-base')
14
  self.tokenizer = T5Tokenizer.from_pretrained('knowledgator/comprehend_it-multilingual-t5-base')
15
  self.classifier = ZeroShotClassificationPipeline(model=self.model, tokenizer=self.tokenizer,ypothesis_template = '{}', encoder_decoder = True)
16
+ print("load model berhasil!")
17
  def anoted_sentence(self,content,candidate_labels):
18
  sentences = nltk.sent_tokenize(content)
19
  sentences = [sent for sent in sentences if "simak" not in sent.lower()]
 
24
  else:
25
  summary_result="neutral"
26
  pair_result=[(res['sequence'],res['labels'][0]) if res['labels'][0]!="neutral" else res['sequence'] for res in result]
27
+ print("sentiment per sentence berhasil!")
28
  return pair_result, summary_result
29
  def get_news_content(self,url):
30
  response = requests.get(url)
 
41
  paragraphs = soup.find_all('p')
42
  content = ' '.join([p.get_text() for p in paragraphs])
43
  content = ' '.join([text for text in content.split("\n") if len(text)>100])
44
+ print("mendapatkan konten berita berhasil!")
45
  return {'title': title.strip(), 'content': content.strip()}
46
  def streamlit_run(self):
47
  st.markdown("<h2 style='text-align: center;'>Indonesian News Analytic </h2>", unsafe_allow_html=True)