NLP创建最大可能的分词
来源:互联网 发布:李刚java 官网 编辑:程序博客网 时间:2024/06/06 01:46
sample_memo = '''
Milt, we're gonna need to go ahead and move you downstairs into storage B. We have some new people coming in, and we need all the space we can get. So if you could just go ahead and pack up your stuff and move it down there, that would be terrific, OK?
Oh, and remember: next Friday... is Hawaiian shirt day. So, you know, if you want to, go ahead and wear a Hawaiian shirt and jeans.
Oh, oh, and I almost forgot. Ahh, I'm also gonna need you to go ahead and come in on Sunday, too...
Hello Peter, whats happening? Ummm, I'm gonna need you to go ahead and come in tomorrow. So if you could be here around 9 that would be great, mmmk... oh oh! and I almost forgot ahh, I'm also gonna need you to go ahead and come in on Sunday too, kay. We ahh lost some people this week and ah, we sorta need to play catch up.
'''
#
# Maximum Likelihood Hypothesis
#
#
# In this quiz we will find the maximum likelihood word based on the preceding word
#
# Fill in the NextWordProbability procedure so that it takes in sample text and a word,
# and returns a dictionary with keys the set of words that come after, whose values are
# the number of times the key comes after that word.
#
# Just use .split() to split the sample_memo text into words separated by spaces.
def NextWordProbability(sampletext,word):
dict = {}
words = sampletext.split(' ')
for i in xrange(len(words)):
if word == words[i]:
if word not in dict:
dict[words[i + 1]] = 0
dict[words[i + 1]] +=1
return dict
Milt, we're gonna need to go ahead and move you downstairs into storage B. We have some new people coming in, and we need all the space we can get. So if you could just go ahead and pack up your stuff and move it down there, that would be terrific, OK?
Oh, and remember: next Friday... is Hawaiian shirt day. So, you know, if you want to, go ahead and wear a Hawaiian shirt and jeans.
Oh, oh, and I almost forgot. Ahh, I'm also gonna need you to go ahead and come in on Sunday, too...
Hello Peter, whats happening? Ummm, I'm gonna need you to go ahead and come in tomorrow. So if you could be here around 9 that would be great, mmmk... oh oh! and I almost forgot ahh, I'm also gonna need you to go ahead and come in on Sunday too, kay. We ahh lost some people this week and ah, we sorta need to play catch up.
'''
#
# Maximum Likelihood Hypothesis
#
#
# In this quiz we will find the maximum likelihood word based on the preceding word
#
# Fill in the NextWordProbability procedure so that it takes in sample text and a word,
# and returns a dictionary with keys the set of words that come after, whose values are
# the number of times the key comes after that word.
#
# Just use .split() to split the sample_memo text into words separated by spaces.
def NextWordProbability(sampletext,word):
dict = {}
words = sampletext.split(' ')
for i in xrange(len(words)):
if word == words[i]:
if word not in dict:
dict[words[i + 1]] = 0
dict[words[i + 1]] +=1
return dict
阅读全文
0 0
- NLP创建最大可能的分词
- NLP中文信息处理---正向最大匹配法分词
- NLP分词
- NLP分词
- NLP: 中文分词算法--正向最大匹配 Forward Maximum Matching
- NLP——分词之正向(逆向、双向)最大
- 44、NLP的其他分词功能测试
- NLP-汉语分词
- NLP:中文分词
- 初识nlp (1 (分词
- nlp技能,jieba分词
- NLP中jieba分词的用法(一)
- NLP(二)_汉语言分词技术及最大匹配法
- NLP︱中文分词技术小结、几大分词引擎的介绍与比较
- 【NLP】中文分词:原理及分词算法
- NLP中的中文分词技术
- NLP 最近常用分词工具
- NLP中的并行分词方法
- ARGB与RGB、RGBA的区别
- 《算法分析与设计》Week 18
- 500. Keyboard Row
- struts2文件上传
- 淘淘商城系列——Redis集群的搭建
- NLP创建最大可能的分词
- java enum的常见用法
- ubuntu内核升级过程
- JAVA-OutputStreamWriter()和InputStreamReader()
- OC NSNumber
- Java异常封装(自己定义错误码和描述,附源码)
- [bzoj]2179: FFT快速傅立叶
- Nginx 配置文件(nginx.conf)
- js笔记3之变量的复制,参数传递与垃圾回收机制