forked from letiantian/TextRank4ZH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example02.py
36 lines (29 loc) · 1005 Bytes
/
example02.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#-*- encoding:utf-8 -*-
from __future__ import print_function
import codecs
from textrank4zh import TextRank4Keyword, TextRank4Sentence
import sys
try:
reload(sys)
sys.setdefaultencoding('utf-8')
except:
pass
text = "这间酒店位于北京东三环,里面摆放很多雕塑,文艺气息十足。答谢宴于晚上8点开始。"
tr4w = TextRank4Keyword()
tr4w.analyze(text=text, lower=True, window=2)
print()
print('sentences:')
for s in tr4w.sentences:
print(s) # py2中是unicode类型。py3中是str类型。
print()
print('words_no_filter')
for words in tr4w.words_no_filter:
print('/'.join(words)) # py2中是unicode类型。py3中是str类型。
print()
print('words_no_stop_words')
for words in tr4w.words_no_stop_words:
print('/'.join(words)) # py2中是unicode类型。py3中是str类型。
print()
print('words_all_filters')
for words in tr4w.words_all_filters:
print('/'.join(words)) # py2中是unicode类型。py3中是str类型。