Skip to content

Commit 0afdb61

Browse files
otakutyrantAngledLuffa
authored andcommitted
Surpress a DeprecationWarning about pkg_resource from jieba.
1 parent 40d5e02 commit 0afdb61

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

stanza/pipeline/external/jieba.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"""
44

55
import re
6+
import warnings
67

78
from stanza.models.common import doc
89
from stanza.pipeline._constants import TOKENIZE
@@ -30,8 +31,12 @@ def __init__(self, config):
3031
if config['lang'] not in ['zh', 'zh-hans', 'zh-hant']:
3132
raise Exception("Jieba tokenizer is currently only allowed in Chinese (simplified or traditional) pipelines.")
3233

33-
check_jieba()
34-
import jieba
34+
# Surpress a DeprecationWarning about pkg_resource from jieba.
35+
with warnings.catch_warnings():
36+
warnings.filterwarnings("ignore", category=DeprecationWarning, module="jieba")
37+
check_jieba()
38+
import jieba
39+
3540
self.nlp = jieba
3641
self.no_ssplit = config.get('no_ssplit', False)
3742

0 commit comments

Comments
 (0)