ow
This commit is contained in:
1 parent
4ea68c801f
commit
dbfa9bd1e8
8 files changed
+70
-34
No files matched your search
@@ -92,6 +92,11 @@ namespace CloudBuilder.Topshelf.Python
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
import sys
|
||||
# web api通過cmd調用,如果沒有加入下面三行,會出錯
|
||||
sys.stdout = open(os.devnull, 'w')
|
||||
sys.stderr = open(os.devnull, 'w')
|
||||
os.environ['TQDM_DISABLE'] = '1'
|
||||
|
||||
# 配置日志
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||
@@ -655,9 +660,22 @@ class HanLPProcessor:
|
||||
|
||||
# 直接返回提取的值
|
||||
return value
|
||||
|
||||
def get_surnames_json(self):
|
||||
"""返回姓氏词典数组的JSON格式字符串,供C#使用"""
|
||||
try:
|
||||
with open(self.surnames_path, 'r', encoding='utf-8') as f:
|
||||
surnames = [line.strip() for line in f if line.strip()]
|
||||
|
||||
return json.dumps(surnames, ensure_ascii=False)
|
||||
except Exception as e:
|
||||
logger.error(f"获取姓氏词典失败: {e}")
|
||||
return json.dumps([])
|
||||
|
||||
processor=HanLPProcessor()
|
||||
|
||||
# 测试split函数
|
||||
|
||||
# 测试split函数
|
||||
def test_split_function():
|
||||
# 测试用例1: 简单的逗号分隔
|
||||
@@ -838,4 +856,5 @@ if __name__ == "__main__":
|
||||
# processor=HanLPProcessor()
|
||||
print("")
|
||||
|
||||
|
||||
*/
|
||||
Reference in new issue
Block a user