-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from LlmKira/cjieba
Cjieba
- Loading branch information
Showing
9 changed files
with
30 additions
and
50 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
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import jieba | ||
import jieba.analyse | ||
import cjieba | ||
|
||
from ..keywords import STOPWORDS | ||
from ..solo import singleton | ||
|
||
|
||
@singleton | ||
class TfidfKeywords: | ||
def __init__(self, delete_stopwords=True, topK=20, withWeight=False): | ||
if delete_stopwords: | ||
jieba.analyse.set_stop_words(STOPWORDS) | ||
|
||
self.topk = topK | ||
self.with_wight = withWeight | ||
|
||
def keywords(self, sentence): | ||
return jieba.analyse.extract_tags(sentence, topK=self.topk, withWeight=self.with_wight) | ||
return cjieba.extract(text=sentence, top_k=self.topk, with_weight=self.with_wight) | ||
# return jieba.analyse.extract_tags(sentence, topK=self.topk, withWeight=self.with_wight) |
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
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
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 |
---|---|---|
|
@@ -37,3 +37,4 @@ numpy | |
jieba | ||
fasttext-wheel | ||
scikit-learn | ||
cjieba |