赞
踩
Course Certificate
本文是 Natural Language Processing with Probabilistic Models 这门课的学习笔记,如有侵权,请联系删除。
Learn about autocorrect, minimum edit distance, and dynamic programming, then build your own spellchecker to correct misspelled words!
You use auto-correct everyday. When you send your friend a text message, or when you make a mistake in a query, there is an autocorrect behind the scenes that corrects the sentence for you. This week you are also going to learn about minimum edit distance, which tells you the minimum amount of edits to change one word into another. In doing that, you will learn about dynamic programming which is an important programming concept which frequently comes up in interviews and could be used to solve a lot of optimization problems.
Autocorrects are used everywhere. You use them in your phones, tablets, and computers.
To implement autocorrect in this week’s assignment, you have to follow these steps:
Identify a misspelled word
Find strings n edit distance away: (these could be random strings)
Filter candidates: (keep only the real words from the previous steps)
Calculate word probabilities: (choose the word that is most likely to occur in that context)
When identifying the misspelled word, you can check whether it is in the vocabulary. If you don’t find it, then it is probably a typo.
In this step, you want to take all the words generated above and then only keep the actual words that make sense and that you can find in your vocabulary.
NLP Course 2 Week 1 Lesson : Building The Model - Lecture Exercise 01
Estimated Time: 10 minutes
Vocabulary Creation
Create a tiny vocabulary from a tiny corpus
It’s time to start small !
# imports
import re # regular expression library; for tokenization of words
from collections import Counter # collections library; counter: dict subclass for counting hashable objects
import matplotlib.pyplot as plt # for data visualization
# the tiny corpus of text !
text = 'red pink pink blue blue yellow ORANGE BLUE BLUE PINK' # 声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Gausst松鼠会/article/detail/369341
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。