UNAVS commited on
Commit
5e361d7
1 Parent(s): 03c50d7

Create app.py for deployment

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from keybert import KeyBERT
2
+ from keyphrase_vectorizers import KeyphraseCountVectorizer
3
+ import gradio as gr
4
+
5
+ embedding = 'all-mpnet-base-v2'
6
+ key_model = KeyBERT(model=embedding)
7
+ vectorizer_params = KeyphraseCountVectorizer(spacy_pipeline='en_core_web_sm', pos_pattern='<J.*>*<N.*>+', stop_words='english', lowercase=True)
8
+
9
+ def get_keywords(course_name, course_desc):
10
+ keywords_list = []
11
+ course_name, course_desc = course_name.strip().lower(), course_desc.strip().lower()
12
+ data = course_name+". "+course_desc
13
+ keywords = key_model.extract_keywords(data, vectorizer=vectorizer_params, stop_words='english', top_n=7, use_mmr=True)
14
+ keywords_list = list(dict(keywords).keys())
15
+ return ", ".join(keywords_list)
16
+
17
+ iface = gr.Interface(fn=get_keywords, inputs=[gr.Textbox(label="Course Name"), gr.Textbox(label="Course Description")], outputs=gr.Textbox(label="Relevant Tags"),
18
+ title="College Course Tags Generator", description="Generating tags/keywords based on Keyphrase-BERT Extraction'")
19
+ iface.launch()