|
|
@ -1,6 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
import site
|
|
|
|
import site
|
|
|
|
import os,re
|
|
|
|
import os,re,time
|
|
|
|
import string,operator
|
|
|
|
import string,operator
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
@ -21,7 +21,7 @@ testfilepath = os.path.join(basePath, 'cppy','data',testfilename )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
# 函数
|
|
|
|
# 项目函数
|
|
|
|
################################################################################
|
|
|
|
################################################################################
|
|
|
|
def read_file(path_to_file):
|
|
|
|
def read_file(path_to_file):
|
|
|
|
with open(path_to_file,encoding='utf-8') as f:
|
|
|
|
with open(path_to_file,encoding='utf-8') as f:
|
|
|
@ -68,5 +68,19 @@ def print_word_freqs( word_freqs, n = 10):
|
|
|
|
print( w, '-', c )
|
|
|
|
print( w, '-', c )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
# 通用工具
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def timing_decorator(func):
|
|
|
|
|
|
|
|
def wrapper(*args, **kwargs):
|
|
|
|
|
|
|
|
start_time = time.time() # 记录开始时间
|
|
|
|
|
|
|
|
result = func(*args, **kwargs) # 调用原始函数
|
|
|
|
|
|
|
|
end_time = time.time() # 记录结束时间
|
|
|
|
|
|
|
|
run_time = end_time - start_time # 计算运行时间
|
|
|
|
|
|
|
|
print(f"{func.__name__} 运行时间: {run_time*1000:.2f} 秒")
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
return wrapper
|
|
|
|
|
|
|
|
|
|
|
|
def test():
|
|
|
|
def test():
|
|
|
|
print( 'cppy welcome' )
|
|
|
|
print( 'cppy welcome' )
|