forked from letiantian/TextRank4ZH
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7234885
commit 86d8375
Showing
7 changed files
with
192 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,9 @@ | |
|
||
主要功能的实现。 | ||
|
||
### 2015 | ||
### 2015-12 | ||
|
||
更新到v0.2。 | ||
|
||
接口有变化。 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#-*- encoding:utf-8 -*- | ||
from __future__ import print_function | ||
import codecs | ||
from textrank4zh import TextRank4Keyword, TextRank4Sentence | ||
|
||
text = codecs.open('../test/doc/01.txt', 'r', 'utf-8').read() | ||
tr4w = TextRank4Keyword() | ||
|
||
tr4w.analyze(text=text, lower=True, window=2) | ||
|
||
print( '关键词:' ) | ||
for item in tr4w.get_keywords(20, word_min_len=1): | ||
print(item.word, item.weight) | ||
|
||
print() | ||
print( '关键短语:' ) | ||
for phrase in tr4w.get_keyphrases(keywords_num=20, min_occur_num= 2): | ||
print(phrase) | ||
|
||
tr4s = TextRank4Sentence() | ||
tr4s.analyze(text=text, lower=True, source = 'all_filters') | ||
|
||
print() | ||
print( '摘要:' ) | ||
for item in tr4s.get_key_sentences(num=3): | ||
print(item.weight, item.sentence) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#-*- encoding:utf-8 -*- | ||
from __future__ import print_function | ||
import codecs | ||
from textrank4zh import TextRank4Keyword, TextRank4Sentence | ||
|
||
text = "这间酒店位于北京东三环,里面摆放很多雕塑,文艺气息十足。答谢宴于晚上8点开始。" | ||
tr4w = TextRank4Keyword() | ||
|
||
tr4w.analyze(text=text, lower=True, window=2) | ||
|
||
print() | ||
print('sentences:') | ||
for s in tr4w.sentences: | ||
print(s) | ||
|
||
print() | ||
print('words_no_filter') | ||
for words in tr4w.words_no_filter: | ||
print('/'.join(words)) | ||
|
||
print() | ||
print('words_no_stop_words') | ||
for words in tr4w.words_no_stop_words: | ||
print('/'.join(words)) | ||
|
||
print() | ||
print('words_all_filters') | ||
for words in tr4w.words_all_filters: | ||
print('/'.join(words)) |
Oops, something went wrong.