alphahg commited on
Commit
876fcc7
β€’
1 Parent(s): 8f51c49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -2,7 +2,6 @@
2
  import gradio as gr
3
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
4
  from nltk.tokenize import sent_tokenize
5
- from konlpy.tag import Kkma
6
  import gc
7
 
8
  import nltk
@@ -62,7 +61,7 @@ def split_sent(sentences, pipe, max_len=256):
62
  # %%
63
  def translate(text, lang, gpt_fix=False):
64
  from_en = False if lang == 'ν•œμ˜' else True
65
- sentences = sent_tokenize(text) if from_en else kkma.sentences(text)
66
  #print(sentences)
67
  if not sentences:
68
  return ''
@@ -115,7 +114,7 @@ def translate_with_sum(text, lang, gpt_fix=False):
115
  summary = en_sum(text, max_length=int(len_tokens(text, en_sum)/2)+32)
116
  text = summary[0]['summary_text']
117
 
118
- sentences = sent_tokenize(text) if from_en else kkma.sentences(text)
119
  #print(sentences)
120
  if not sentences:
121
  return ''
@@ -146,7 +145,7 @@ def summarize(text, lang):
146
  return summary
147
 
148
  def translate_styleonly(text):
149
- sentences = kkma.sentences(text)
150
  paragraphs = split_sent(sentences, style_pipe, max_len=180)
151
  #print(paragraphs)
152
 
 
2
  import gradio as gr
3
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM, pipeline
4
  from nltk.tokenize import sent_tokenize
 
5
  import gc
6
 
7
  import nltk
 
61
  # %%
62
  def translate(text, lang, gpt_fix=False):
63
  from_en = False if lang == 'ν•œμ˜' else True
64
+ sentences = sent_tokenize(text)
65
  #print(sentences)
66
  if not sentences:
67
  return ''
 
114
  summary = en_sum(text, max_length=int(len_tokens(text, en_sum)/2)+32)
115
  text = summary[0]['summary_text']
116
 
117
+ sentences = sent_tokenize(text)
118
  #print(sentences)
119
  if not sentences:
120
  return ''
 
145
  return summary
146
 
147
  def translate_styleonly(text):
148
+ sentences = sent_tokenize(text)
149
  paragraphs = split_sent(sentences, style_pipe, max_len=180)
150
  #print(paragraphs)
151