Spaces:
Sleeping
Sleeping
Daryl Fung
commited on
Commit
·
a2287fc
1
Parent(s):
0b8e9c2
fix character
Browse files- keyphrase_extraction.py +3 -1
keyphrase_extraction.py
CHANGED
@@ -40,9 +40,11 @@ def get_top_key_phrases(text, top_n, save_output):
|
|
40 |
plt.savefig(save_output, dpi=300)
|
41 |
plt.close()
|
42 |
|
|
|
43 |
def display_key_phrases(text, save_output):
|
|
|
44 |
doc = nlp(text)
|
45 |
-
key_phrases = [{'start': chunk.start_char, 'end': chunk.end_char
|
46 |
|
47 |
# generate displacy html #
|
48 |
max_rank = float(key_phrases[0]['label'])
|
|
|
40 |
plt.savefig(save_output, dpi=300)
|
41 |
plt.close()
|
42 |
|
43 |
+
|
44 |
def display_key_phrases(text, save_output):
|
45 |
+
text = text.replace('\n', ' \n')
|
46 |
doc = nlp(text)
|
47 |
+
key_phrases = [{'start': chunk.start_char, 'end': chunk.end_char, 'label': str(round(phrase.rank, 2))} for phrase in doc._.phrases for chunk in phrase.chunks]
|
48 |
|
49 |
# generate displacy html #
|
50 |
max_rank = float(key_phrases[0]['label'])
|