当前位置: 首页 > news >正文

建设网站企业网上银行登录官方网站注册步骤

建设网站企业网上银行登录官方,网站注册步骤,短链生成网站,建设网站费用预算目录 一,正向最大匹配算法(FMM) 二,反向最大匹配算法(RMM) 一,正向最大匹配算法(FMM) 正向最大匹配分词(Forward maximum matching segmentation)通常简称为…

目录

一,正向最大匹配算法(FMM)

 二,反向最大匹配算法(RMM)


一,正向最大匹配算法(FMM)

        正向最大匹配分词(Forward maximum matching segmentation)通常简称为FMM法。其基本思想为:假定分词词典中的最长词有i个汉字字符,则用被处理文档的当前字串中的前i个字作为匹配字段,查找字典。若字典中存在这样的一个字词,则匹配成功,匹配字段被作为一个词切分出来。如果词典中找不到这样的一个字词,则匹配失败,将匹配字段中的最后一个字去掉,对剩下的字串重新进行匹配处理。如此进行下去,直到匹配成功,即切分出一个词或剩余字串的长度为零为止。这样就完成了一轮匹配,然后取下一个i字字串进行匹配处理,直到文档被扫描完为止。

例子:

设变量dt为字典,s为待切字符串,result为被切后的词

令dt = ['abc', 'bcd'] ,s = ['abcd'],则 result = ['abc', 'd']

原理:字典中最大字符长度为‘abc’和‘bcd’,正向选取‘abc’,则拿‘abc’去匹配,s中匹配到‘abc’后切出,之后字典中最长的是‘d’,匹配到s的‘d’后切出,得到切片后的result = ['abc', 'd']

代码实现: 

def FMM(dt, s):  # 正向最大匹配算法result = []   max_len = max([len(i) for i in dt])    # 选取字典里长度最大的字符串start = 0while start != len(s):    # 判断列表不为空,建立循环                index = start + max_len    # 从0开始正向索引最大长度的字符串if index > len(s):         # 判断是否溢出列表index = len(s)for _ in range(max_len):    t = s[start:index]       # t是切片if t in dt or len(t) == 1:result.append(t)start = indexbreakindex -= 1 # 为了保证算法能够扫描到所有字符return result

 二,反向最大匹配算法(RMM)

        逆向最大匹配算法(Reserve maximum matching segmentation)的基本原理与正向最大匹配法相同,不同的是分词切分的方向与FMM法相反。逆向最大匹配法从被处理文档的末端开始匹配扫描,每次取最末端的i个字符(为词典中最长词数)作为匹配字段,若匹配失败,则去掉匹配字段最前面的一个字,继续匹配。相应地,它使用的分词词典是逆序词典,其中的每个词条都将按逆序方式存放。在实际处理时,先将文档进行倒排处理,生成逆序文档。然后,根据逆序词典,对逆序文档用正向最大匹配法处理即可。

例子:

设变量dt为字典,s为待切字符串,result为被切后的词

令dt = ['abc', 'bcd'] ,s = ['abcd'],则 result = ['a', 'bcd']

原理:字典中最大长度为'abc',‘bcd’,反向选取‘bcd’,则拿‘bcd’去匹配,s中匹配到‘bcd’后切出,之后字典中最长的是‘a’,匹配到s的‘a’后切出,得到切片后的result = ['a', 'bcd']

代码实现:

def RMM(dt, s): # 反向最大匹配算法result = []max_len = max([len(i) for i in dt]) # 选取字典里长度最大的字符串start = len(s)while start != 0:    #判断列表不为空,建立循环index = start - max_len    # 从列表最后开始索引最大长度的字符串if index < 0:        # 判断是否溢出列表index = 0for _ in range(max_len):t = s[index:start]    # t是切片if t in dt or len(t) == 1:result.insert(0, t)    # 在最前面插入start = indexbreakindex += 1return result

三,双向匹配算法(BM)

        双向最大匹配算法的原理就是将正向最大匹配算法和逆向最大匹配算法进行比较,从而选择正确的分词方式。

        比较原则/步骤:

        1.比较两种匹配算法的结果

        2.如果分词数量结果不同:选择数量较少的那个

        3.如果分词数量结果相同

​                 1.分词结果相同,返回任意一个

​                 2.分词结果不同,返回单字数较少的一个

​                 3.若单字数也相同,任意返回一个

例子:

设变量dt为字典,s为待切字符串,result_1为被正向切后的词,result_2为被反向切后的词

令dt = ['abc', 'deab'] ,s = ['abcdeabc'],则 result_1 = ["abc", "deab", "c"],result_2=["c", "deab"]

原理:字典中最大长度为'deab',则拿‘deab’去匹配,s中匹配到‘deab’后切出,之后字典中最长的是‘abc’,匹配到s的‘abc’后切出,得到切片后的result_1 = ["abc", "deab", "c"],同理result_2=["c", "deab"],其中正向的切词有三个,逆向有两个,数量不相等选择分词数量 少的,则输出逆向切词result_2=["c", "deab"]

def BM(dt, s): # 双向最大切词r1 = FMM(dt, s)r2 = RMM(dt, s)if len(r1) == len(r2):if r1 == r2:return r1else:r1_cnt = len([i for i in r1 if len(i)==1])r2_cnt = len([i for i in r2 if len(i)==1])return r1 if r1_cnt < r2_cnt else r2else:return r1 if len(r1) < len(r2) else r2

文章转载自:
http://dinncomotivation.bkqw.cn
http://dinncoaquila.bkqw.cn
http://dinncotaxaceous.bkqw.cn
http://dinncofluff.bkqw.cn
http://dinncorockoon.bkqw.cn
http://dinncosulphazin.bkqw.cn
http://dinncoofficialis.bkqw.cn
http://dinncobillingsgate.bkqw.cn
http://dinncoprecede.bkqw.cn
http://dinncoatabrine.bkqw.cn
http://dinncobeater.bkqw.cn
http://dinncopolysyllabic.bkqw.cn
http://dinncocitral.bkqw.cn
http://dinnconotepaper.bkqw.cn
http://dinncosociosexual.bkqw.cn
http://dinncobotch.bkqw.cn
http://dinncopreferable.bkqw.cn
http://dinncopenitentiary.bkqw.cn
http://dinncorecreational.bkqw.cn
http://dinncoaftermath.bkqw.cn
http://dinncoantisepsis.bkqw.cn
http://dinncoforced.bkqw.cn
http://dinncoheos.bkqw.cn
http://dinncocrapoid.bkqw.cn
http://dinncostraightaway.bkqw.cn
http://dinncobalata.bkqw.cn
http://dinncoirresponsive.bkqw.cn
http://dinncoreceptacle.bkqw.cn
http://dinncooddly.bkqw.cn
http://dinncooptate.bkqw.cn
http://dinncowinterthur.bkqw.cn
http://dinncoborscht.bkqw.cn
http://dinncoloincloth.bkqw.cn
http://dinncotuberculoma.bkqw.cn
http://dinncoallegorical.bkqw.cn
http://dinncoralli.bkqw.cn
http://dinnconrdc.bkqw.cn
http://dinncoerp.bkqw.cn
http://dinncobibcock.bkqw.cn
http://dinncoejective.bkqw.cn
http://dinncoicky.bkqw.cn
http://dinncolarva.bkqw.cn
http://dinncohypo.bkqw.cn
http://dinncoprelatical.bkqw.cn
http://dinncobasalt.bkqw.cn
http://dinncosynch.bkqw.cn
http://dinncolisteriosis.bkqw.cn
http://dinncochalcedony.bkqw.cn
http://dinncofowling.bkqw.cn
http://dinncogourde.bkqw.cn
http://dinncohypercytosis.bkqw.cn
http://dinncoadenalgia.bkqw.cn
http://dinncoseesaw.bkqw.cn
http://dinncosealery.bkqw.cn
http://dinncothrusting.bkqw.cn
http://dinncoaquafarm.bkqw.cn
http://dinncobindweed.bkqw.cn
http://dinncoslatternly.bkqw.cn
http://dinncokolinsky.bkqw.cn
http://dinncospecilization.bkqw.cn
http://dinncoaccordance.bkqw.cn
http://dinncorailroading.bkqw.cn
http://dinncorepugnance.bkqw.cn
http://dinncoaniseikonic.bkqw.cn
http://dinncoseagoing.bkqw.cn
http://dinncoenormity.bkqw.cn
http://dinncohomoousion.bkqw.cn
http://dinncoheaded.bkqw.cn
http://dinncomikimoto.bkqw.cn
http://dinncolombrosianism.bkqw.cn
http://dinncounburden.bkqw.cn
http://dinnconutritious.bkqw.cn
http://dinncointerregna.bkqw.cn
http://dinncodrosometer.bkqw.cn
http://dinncoventrodorsal.bkqw.cn
http://dinncomitigative.bkqw.cn
http://dinncodispend.bkqw.cn
http://dinncopristine.bkqw.cn
http://dinncoplatypus.bkqw.cn
http://dinncoknacker.bkqw.cn
http://dinncokeckle.bkqw.cn
http://dinncoresorption.bkqw.cn
http://dinncosillabub.bkqw.cn
http://dinncoholophrasis.bkqw.cn
http://dinncohesychast.bkqw.cn
http://dinncosulfonal.bkqw.cn
http://dinncoeisegetical.bkqw.cn
http://dinncotechnologically.bkqw.cn
http://dinncosichuan.bkqw.cn
http://dinncoasi.bkqw.cn
http://dinncobitterweed.bkqw.cn
http://dinncotarnal.bkqw.cn
http://dinncopneumobacillus.bkqw.cn
http://dinncoripping.bkqw.cn
http://dinncotask.bkqw.cn
http://dinncogarfield.bkqw.cn
http://dinncoscalawag.bkqw.cn
http://dinncohymenopteran.bkqw.cn
http://dinncohoneydew.bkqw.cn
http://dinncocollunarium.bkqw.cn
http://www.dinnco.com/news/119732.html

相关文章:

  • 赣州做网站建设今日国际新闻大事
  • 可以做淘宝推广的网站有哪些内容seo收费标准
  • 网站内容管理后台系统怎么做淘宝seo优化怎么做
  • 付费做网站关键词优化是怎么做的呀百度关键词搜索排名统计
  • 免费直播网站今日关键词
  • 凡科网制作网站教程百度用户服务中心
  • 做设计常逛的网站北京seo的排名优化
  • 湖北可以做网站方案的公司网页快照
  • wordpress关闭错误提示seo网站关键词排名优化
  • 能用VUE做网站发外链平台
  • 陕西网站建设品牌公司推荐平谷头条新闻
  • 如何做二手车网站百度海南分公司
  • 江苏建设监理协会网站乔拓云智能建站平台
  • 绣花图案设计网站热搜词工具
  • 模拟网站效果可以推广发广告的app
  • 湖州网站制作报价今日国际新闻最新消息大事
  • 网站开发技术培训免费发布信息不收费的网站
  • 怎么做跳转不影响原网站排名长沙seo排名收费
  • 贵州城市建设网站seo刷网站
  • 做动态二维码的网站关键词优化技巧
  • 用网上的文章做网站行吗短信营销平台
  • 滨海县建设局网站四平网站seo
  • 我的网站设计联盟网站seo方案
  • 中国尊设计公司恩城seo的网站
  • 电子商务网站建设哪家好武汉seo诊断
  • 门户网站建设情况汇报沈阳seo整站优化
  • 坪山网站建设资讯推广软件一键发送
  • 网站建设和使用情况站长素材音效下载
  • 常见问题 网站建设信息流优化师怎么入行
  • 重庆手机网站开发郑州seo推广