nlp函数的超快速cpp实现
nlpc的Python项目详细描述
NLPC
nlp c是一个超快速的c++库,它采用动态编程(dp)算法来解决以下经典的nlp问题。
The longest common subsequence问题是寻找一组序列(通常只有两个序列)中所有序列共有的最长子序列的问题。
The longest common substring问题是找到两个或多个字符串的子字符串(或是子字符串)的最长字符串。
我们还支持中文(或任何UTF-8)字符串
安装
要安装,只需执行pip install nlpc
即可从PyPI中下载最新版本。
python代码示例
importnlpc# finding the longest common subsequence length of string A and string BA='We are shannonai'B='We like shannonai'nlpc.lcs(A,B)""">>> nlpc.lcs(A, B)14"""# finding the longest common subsequence length of string A and a list of string BA='We are shannonai'B=['We like shannonai','We work in shannonai','We are not shannonai']nlpc.lcs_of_list(A,B)""">>> nlpc.lcs_of_list(A, B)[14, 14, 16]"""# finding the longest common substring length of string A and string BA='We are shannonai'B='We like shannonai'nlpc.lcs2(A,B)""">>> nlpc.lcs2(A, B)11"""# finding the longest common substring length of string A and a list of string BA='We are shannonai'B=['We like shannonai','We work in shannonai','We are not shannonai']nlpc.lcs2_of_list(A,B)""">>> nlpc.lcs2_of_list(A, B)[11, 10, 10]"""