raghuram13 abdulmatinomotoso commited on
Commit
2a2c0ec
0 Parent(s):

Duplicate from valurank/keyword_and_keyphrase_extraction

Browse files

Co-authored-by: Omotoso Abdulmatin <[email protected]>

Files changed (5) hide show
  1. .gitattributes +27 -0
  2. LICENSE +26 -0
  3. README.md +14 -0
  4. app.py +40 -0
  5. requirements.txt +7 -0
.gitattributes ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ftz filter=lfs diff=lfs merge=lfs -text
6
+ *.gz filter=lfs diff=lfs merge=lfs -text
7
+ *.h5 filter=lfs diff=lfs merge=lfs -text
8
+ *.joblib filter=lfs diff=lfs merge=lfs -text
9
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
10
+ *.model filter=lfs diff=lfs merge=lfs -text
11
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
12
+ *.onnx filter=lfs diff=lfs merge=lfs -text
13
+ *.ot filter=lfs diff=lfs merge=lfs -text
14
+ *.parquet filter=lfs diff=lfs merge=lfs -text
15
+ *.pb filter=lfs diff=lfs merge=lfs -text
16
+ *.pt filter=lfs diff=lfs merge=lfs -text
17
+ *.pth filter=lfs diff=lfs merge=lfs -text
18
+ *.rar filter=lfs diff=lfs merge=lfs -text
19
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
20
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
21
+ *.tflite filter=lfs diff=lfs merge=lfs -text
22
+ *.tgz filter=lfs diff=lfs merge=lfs -text
23
+ *.wasm filter=lfs diff=lfs merge=lfs -text
24
+ *.xz filter=lfs diff=lfs merge=lfs -text
25
+ *.zip filter=lfs diff=lfs merge=lfs -text
26
+ *.zstandard filter=lfs diff=lfs merge=lfs -text
27
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
LICENSE ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MICROSOFT REFERENCE SOURCE LICENSE (MS-RSL)
2
+
3
+ This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software.
4
+
5
+ 1. Definitions
6
+ The terms "reproduce," "reproduction" and "distribution" have the same meaning here as under U.S. copyright law.
7
+
8
+ "You" means the licensee of the software.
9
+
10
+ "Your company" means the company you worked for when you downloaded the software.
11
+
12
+ "Reference use" means use of the software within your company as a reference, in read only form, for the sole purposes of debugging your products, maintaining your products, or enhancing the interoperability of your products with the software, and specifically excludes the right to distribute the software outside of your company.
13
+
14
+ "Licensed patents" means any Licensor patent claims which read directly on the software as distributed by the Licensor under this license.
15
+
16
+ 2. Grant of Rights
17
+ (A) Copyright Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free copyright license to reproduce the software for reference use.
18
+
19
+ (B) Patent Grant- Subject to the terms of this license, the Licensor grants you a non-transferable, non-exclusive, worldwide, royalty-free patent license under licensed patents for reference use.
20
+
21
+ 3. Limitations
22
+ (A) No Trademark License- This license does not grant you any rights to use the Licensor's name, logo, or trademarks.
23
+
24
+ (B) If you begin patent litigation against the Licensor over patents that you think may apply to the software (including a cross-claim or counterclaim in a lawsuit), your license to the software ends automatically.
25
+
26
+ (C) The software is licensed "as-is." You bear the risk of using it. The Licensor gives no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the Licensor excludes the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Keyword And Keyphrase Extraction
3
+ emoji: 👀
4
+ colorFrom: gray
5
+ colorTo: yellow
6
+ sdk: gradio
7
+ sdk_version: 3.0.17
8
+ app_file: app.py
9
+ pinned: false
10
+ license: other
11
+ duplicated_from: valurank/keyword_and_keyphrase_extraction
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #importing the necessary libraries
2
+
3
+ import pandas as pd
4
+ import numpy as np
5
+ import gradio as gr
6
+ from sentence_transformers import SentenceTransformer
7
+ from keybert import KeyBERT
8
+ from keyphrase_vectorizers import KeyphraseCountVectorizer
9
+
10
+ # Defining a function to read in the text file
11
+
12
+ def read_in_text(url):
13
+ with open(url, 'r') as file:
14
+ article = file.read()
15
+ return article
16
+
17
+ #tmp_model = SentenceTransformer('valurank/MiniLM-L6-Keyword-Extraction')
18
+ kw_extractor = KeyBERT('valurank/MiniLM-L6-Keyword-Extraction')
19
+
20
+ def get_keybert_results_with_vectorizer(text, number_of_results=20):
21
+ try:
22
+ keywords = kw_extractor.extract_keywords(text, vectorizer=KeyphraseCountVectorizer(), stop_words=None, top_n=number_of_results)
23
+ keywords = [i for i in keywords if i[1] > 0.20]
24
+
25
+ keybert_diversity_phrases = []
26
+ for i, j in keywords:
27
+ keybert_diversity_phrases.append(i)
28
+
29
+ output_df = pd.DataFrame()
30
+ output_df['keyword'] = np.array(keybert_diversity_phrases)
31
+ return output_df.head(20)
32
+ except Exception:
33
+ return "Error"
34
+
35
+ demo = gr.Interface(get_keybert_results_with_vectorizer, inputs=gr.inputs.Textbox(),
36
+ outputs=gr.outputs.Dataframe(),
37
+ title = "Keyword Extraction")
38
+
39
+ if __name__ == "__main__":
40
+ demo.launch(debug=True)
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ keybert
2
+ sentence_transformers
3
+ keyphrase_vectorizers
4
+ pandas
5
+ numpy
6
+ transformers==4.10.2
7
+ sentencepiece==0.1.96