Fix pip install on app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,21 @@
|
|
1 |
-
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
from keybert import KeyBERT
|
4 |
from keyphrase_vectorizers import KeyphraseCountVectorizer
|
5 |
import gradio as gr
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
|
11 |
def get_keywords(course_name, course_desc):
|
12 |
keywords_list = []
|
@@ -18,4 +27,4 @@ def get_keywords(course_name, course_desc):
|
|
18 |
|
19 |
iface = gr.Interface(fn=get_keywords, inputs=[gr.Textbox(label="Course Name"), gr.Textbox(label="Course Description")], outputs=gr.Textbox(label="Relevant Tags"),
|
20 |
title="College Course Tags Generator", description="Generating tags/keywords based on Keyphrase-BERT Extraction'")
|
21 |
-
iface.launch()
|
|
|
1 |
+
import subprocess
|
2 |
+
import sys
|
3 |
+
|
4 |
+
def install(package):
|
5 |
+
subprocess.check_call([sys.executable, "-m", "pip", "install", package], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
6 |
+
|
7 |
+
install("keybert")
|
8 |
+
install("keyphrase_vectorizers")
|
9 |
+
import warnings
|
10 |
from keybert import KeyBERT
|
11 |
from keyphrase_vectorizers import KeyphraseCountVectorizer
|
12 |
import gradio as gr
|
13 |
|
14 |
+
with warnings.catch_warnings():
|
15 |
+
warnings.simplefilter("ignore", category=UserWarning)
|
16 |
+
embedding = 'all-mpnet-base-v2'
|
17 |
+
key_model = KeyBERT(model=embedding)
|
18 |
+
vectorizer_params = KeyphraseCountVectorizer(spacy_pipeline='en_core_web_sm', pos_pattern='<J.*>*<N.*>+', stop_words='english', lowercase=True)
|
19 |
|
20 |
def get_keywords(course_name, course_desc):
|
21 |
keywords_list = []
|
|
|
27 |
|
28 |
iface = gr.Interface(fn=get_keywords, inputs=[gr.Textbox(label="Course Name"), gr.Textbox(label="Course Description")], outputs=gr.Textbox(label="Relevant Tags"),
|
29 |
title="College Course Tags Generator", description="Generating tags/keywords based on Keyphrase-BERT Extraction'")
|
30 |
+
iface.launch()
|