[Problem and Solution: nltk python natural language processing a code error in the Chinese translation version

Source: Internet
Author: User
Tags nltk nltk python

I am also a newbie to NLP. My tutor gave us the learning materials for getting started. It is a free Chinese Version translated by Chinese fans of Natural Language Processing with Python. In the Chinese version, it is inevitable that there will be some minor errors. Most of them can be corrected after careful study.

A small code error was found here for your sharing.

In section 11.3 "special considerations when dealing with endangered languages" in data collection, there is a code that standardizes the alphabetic order of consonants. This code is not hard to understand. However, in Chinese translation, typographical errors may occur due to the carelessness of the typographical staff.

In the Chinese version, this code is as follows:

>>>mappings= [(, ), (, ), (, ), (, , ), (r, r>>> patt,repl == re.findall( .join(char  piecein pieces  charin sorted(piece))[:8>>>signature(>>>signature(>>>signature(

Follow pieces = re. findall... In this line, it is found that a has an extra ^ symbol on it, which is incorrect here.

The Code should be written as pieces = re. findall ('[^ aeiou] +', word). readers who have learned Regular Expressions and read this section should know why this change is necessary.

The complete code is as follows:

>>> mappings = [(, ), (, ), (, ), (, , ), (r, r>>>  patt, repl == re.findall( .join(char  piece  pieces  char  sorted(piece))[:8>>> signature(>>> signature(>>> signature(

 

Thanks again for the help of the author!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.