aka7774 commited on
Commit
9cf5faf
1 Parent(s): 88a04eb

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +23 -0
  2. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import subprocess
3
+ import gradio as gr
4
+
5
+ # space setup
6
+ subprocess.run('python -m spacy download en_core_web_sm', shell=True)
7
+
8
+ import pke
9
+ from spacy.lang import ja
10
+
11
+ def fn_pke(text, n=10):
12
+ extractor = pke.unsupervised.MultipartiteRank()
13
+ extractor.load_document(input=text, language='ja', normalization=None)
14
+ extractor.candidate_selection()
15
+ extractor.candidate_weighting()
16
+ res = extractor.get_n_best(n=n)
17
+
18
+ return "\n".join([k for k, v in res])
19
+
20
+ gr.Interface(
21
+ fn=fn_pke,
22
+ inputs="text",
23
+ outputs="text").launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ git+https://github.com/boudinfl/pke.git