Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/bojone/nlp-zero
/ functions
Functions
48 in github.com/bojone/nlp-zero
⨍
Functions
48
◇
Types & classes
9
↓ 20 callers
Function
log
(x)
nlp_zero.py:33
↓ 6 callers
Method
add
(self, value)
nlp_zero.py:407
↓ 4 callers
Method
tokenize
比较完整的分词函数,包括分词前和分词后的处理。 分词前:按照标点或者换行符来切分长句,然后逐一分词,能提高效率; 分词后:合并连续的数字或字母(可选)
nlp_zero.py:256
↓ 3 callers
Method
__setitem__
(self, item, count)
nlp_zero.py:63
↓ 2 callers
Method
__hash__
(self)
nlp_zero.py:425
↓ 2 callers
Method
get_proba
(self, w, logit=True)
nlp_zero.py:139
↓ 2 callers
Method
plot
(self, prefix='+---> ')
nlp_zero.py:656
↓ 2 callers
Method
search
(self, sent)
nlp_zero.py:121
↓ 2 callers
Method
simple_tokenize
(self, sent)
nlp_zero.py:226
↓ 2 callers
Method
texts
(self, sents, filtering=True)
nlp_zero.py:289
↓ 2 callers
Method
texts
(self, sents, filtering=True)
nlp_zero.py:457
↓ 1 callers
Method
__delitem__
(self, item)
nlp_zero.py:91
↓ 1 callers
Method
__getitem__
(self, item)
nlp_zero.py:82
↓ 1 callers
Method
__str__
(self)
nlp_zero.py:114
↓ 1 callers
Method
__str__
(self)
nlp_zero.py:431
↓ 1 callers
Method
__str__
(self)
nlp_zero.py:671
↓ 1 callers
Method
_all_paths
(self, n)
nlp_zero.py:192
↓ 1 callers
Method
_parse
解析思路:递归进行——如果一种层次结构是最优的,那么它每个语义块的 层次结构都是最优的。利用这种特性,可以写成递层优化的算法。
nlp_zero.py:705
↓ 1 callers
Method
_search
查找原理:按照常规trie树的查找原则, 但是每个单词有两个匹配可能:1.匹配单词本身;2.匹配占位符None。 因此只好递归匹配。
nlp_zero.py:571
↓ 1 callers
Method
all_paths
(self)
nlp_zero.py:202
↓ 1 callers
Method
combine_Aa123
(self, simple_result)
nlp_zero.py:236
↓ 1 callers
Method
export_tokenizer
(self)
nlp_zero.py:391
↓ 1 callers
Method
export_trie
(self)
nlp_zero.py:388
↓ 1 callers
Method
max
(self, x)
nlp_zero.py:693
↓ 1 callers
Method
optimal_path
动态规划求最优路径 result的key是当前字的下标,代表截止到前一字的规划结果, result的第一个值是list,表示匹配片段的(start, end)下标对; result的第二个值是路径的分数
nlp_zero.py:164
↓ 1 callers
Method
update
(self, tire)
nlp_zero.py:135
Method
__eq__
(self, t)
nlp_zero.py:428
Method
__init__
(self, path_or_trie=None)
nlp_zero.py:46
Method
__init__
(self, nb_node, null_score=-100)
nlp_zero.py:153
Method
__init__
(self, word_trie=None)
nlp_zero.py:218
Method
__init__
(self, min_proba=1e-7, min_pmi=1)
nlp_zero.py:282
Method
__init__
(self, container=None)
nlp_zero.py:399
Method
__init__
(self, tokenize, window=5, min_proba=1e-5, min_pmi=2)
nlp_zero.py:448
Method
__init__
SentTree有三个属性: template是当前主模版, content是当前主模版覆盖的字符串 modules是语义块列表,每个元素也是一个SentTree
nlp_zero.py:637
Method
__init__
(self, templates, tokenize, null_score=-20)
nlp_zero.py:688
Method
__iter__
(self, _=None)
nlp_zero.py:103
Method
__iter__
(self)
nlp_zero.py:421
Method
__repr__
(self)
nlp_zero.py:118
Method
__repr__
(self)
nlp_zero.py:440
Method
__repr__
(self)
nlp_zero.py:677
Method
__setitem__
(self, start_end, score)
nlp_zero.py:158
Method
find
基本的新词识别算法 在train的基础上,计算互信息,通过互信息找出强相关的邻字,然后 通过这些邻字实现粗糙的分词,从粗糙的分词结果中筛选出可能的词语。 【参数含义】 filtering:是否过滤无关字符,只保留中文、数字和英文字母
nlp_zero.py:315
Method
find
基本的句模版构建算法 在train的基础上,然后计算互信息,通过互信息给每个词找出最邻近的 强相关的词语,然后将它们连接起来,就构成一个模版。 【参数含义】 filtering:是否过滤无关字符,只保留中文、数字和英文字母;
nlp_zero.py:489
Method
is_trivial
是否平凡模版,单个词且两边都是占位符的模版是平凡的。
nlp_zero.py:415
Method
parse
(self, sent)
nlp_zero.py:699
Method
search
重定义search函数,返回所有可能的匹配结果 输出output的格式为{(开始位置, 终止位置): {(匹配模版的词tuple): 模版频数}}
nlp_zero.py:561
Method
train
训练步骤,也就是统计字频和字对频率。 【参数含义】 filtering:是否过滤无关字符,只保留中文、数字和英文字母;
nlp_zero.py:297
Method
train
训练步骤,也就是统计词频和skip gram。 【参数含义】 filtering:是否过滤无关字符,只保留中文、数字和英文字母;
nlp_zero.py:471