Spaces:
Sleeping
Sleeping
seawolf2357
commited on
Commit
โข
7e85524
1
Parent(s):
83ef4e2
Update app.py
Browse files
app.py
CHANGED
@@ -11,9 +11,6 @@ download('punkt')
|
|
11 |
download('averaged_perceptron_tagger')
|
12 |
download('stopwords')
|
13 |
|
14 |
-
# Google Cloud Translation ํด๋ผ์ด์ธํธ ์ค์
|
15 |
-
translate_client = translate.Client()
|
16 |
-
|
17 |
def extract_keywords(text):
|
18 |
# ์์ด ํ
์คํธ๋ฅผ ํ ํฐํ
|
19 |
tokens = word_tokenize(text)
|
@@ -25,7 +22,9 @@ def extract_keywords(text):
|
|
25 |
keywords = [word for word, tag in tagged if tag in ['NN', 'NNP', 'NNS', 'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ']]
|
26 |
return ' '.join(keywords)
|
27 |
|
28 |
-
def translate_and_extract_keywords(text):
|
|
|
|
|
29 |
# ์
๋ ฅ๋ฐ์ ํ๊ธ ๋ฌธ์ฅ์ ์์ด๋ก ๋ฒ์ญ
|
30 |
result = translate_client.translate(text, target_language='en')
|
31 |
translated_text = result['translatedText']
|
@@ -35,10 +34,13 @@ def translate_and_extract_keywords(text):
|
|
35 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
36 |
interface = gr.Interface(
|
37 |
fn=translate_and_extract_keywords,
|
38 |
-
inputs=
|
|
|
|
|
|
|
39 |
outputs="text",
|
40 |
title="ํ๊ธ ๋ฌธ์ฅ์ ์์ด ํค์๋๋ก ๋ฒ์ญ ๋ฐ ์ถ์ถ",
|
41 |
-
description="ํ๊ธ
|
42 |
)
|
43 |
|
44 |
# ์ ํ๋ฆฌ์ผ์ด์
์คํ
|
|
|
11 |
download('averaged_perceptron_tagger')
|
12 |
download('stopwords')
|
13 |
|
|
|
|
|
|
|
14 |
def extract_keywords(text):
|
15 |
# ์์ด ํ
์คํธ๋ฅผ ํ ํฐํ
|
16 |
tokens = word_tokenize(text)
|
|
|
22 |
keywords = [word for word, tag in tagged if tag in ['NN', 'NNP', 'NNS', 'VB', 'VBD', 'VBG', 'VBN', 'VBP', 'VBZ']]
|
23 |
return ' '.join(keywords)
|
24 |
|
25 |
+
def translate_and_extract_keywords(text, api_key):
|
26 |
+
# ํด๋ผ์ด์ธํธ ์ค์
|
27 |
+
translate_client = translate.Client(credentials=translate.Credentials(api_key))
|
28 |
# ์
๋ ฅ๋ฐ์ ํ๊ธ ๋ฌธ์ฅ์ ์์ด๋ก ๋ฒ์ญ
|
29 |
result = translate_client.translate(text, target_language='en')
|
30 |
translated_text = result['translatedText']
|
|
|
34 |
# Gradio ์ธํฐํ์ด์ค ์ ์
|
35 |
interface = gr.Interface(
|
36 |
fn=translate_and_extract_keywords,
|
37 |
+
inputs=[
|
38 |
+
gr.Textbox(lines=2, placeholder="ํ๊ธ ๋ฌธ์ฅ์ ์
๋ ฅํ์ธ์..."),
|
39 |
+
gr.Textbox(label="Google Cloud API ํค")
|
40 |
+
],
|
41 |
outputs="text",
|
42 |
title="ํ๊ธ ๋ฌธ์ฅ์ ์์ด ํค์๋๋ก ๋ฒ์ญ ๋ฐ ์ถ์ถ",
|
43 |
+
description="ํ๊ธ ๋ฌธ์ฅ๊ณผ Google Cloud API ํค๋ฅผ ์
๋ ฅํ๋ฉด, ๊ทธ ์๋ฏธ๊ฐ ํฌํจ๋ ์์ด ํค์๋๋ฅผ ์ถ์ถํ์ฌ ์ถ๋ ฅํฉ๋๋ค."
|
44 |
)
|
45 |
|
46 |
# ์ ํ๋ฆฌ์ผ์ด์
์คํ
|