维特比算法解决最短路径问题:统计分词(unigram)
发布时间
阅读量:
阅读量
统计分词(unigram)
1 词库
在词库中,最长的字符串长度标记为m,而输入字符串的长度则表示为n,通常情况下n远大于m。
import xlrd
def create_dic_words(file_path, sheet_index=0):
workbook = xlrd.open_workbook(filename=file_path)
worksheet = workbook.sheet_by_index(sheet_index)
dic_words = {}
max_len_word = 0
for idx in range(worksheet.nrows):
word = worksheet.row(idx)[0].value.strip()
dic_words[word] = 0.00001
len_word = len(word)
if len_word > max_len_word:
max_len_word = len_word
return
全部评论 (0)
还没有任何评论哟~
