目录
4.1 Word Tokenisation: English
4.2 Word Tokenisation: Chinese
1. 为什么第一步要进行预处理?
语言是有构成的。作为人类,我们可以将这些文件分解成各个组成部分。为了理解语言,计算机也应该这样做。
2. 预处理的步骤
- Remove unwanted formatting (e.g. HTML) 删除不需要的格式(如HTML)
- 句子分割 Sentence segmentation: break documents into sentences 将文件分割成句子
- 词语标记化 Word tokenization: break sentences into words 将句子分成词语
- 词语规范化 Word normalization: transform words into canonical forms 词语化为规范形式
- 删除止损词 Stopword removal: delete unwanted words 删除不需要的词
3. Sentence Segmentation 句子分割
按标点分割:
- 最天真的方法是按照句子的标点符号进行分割
- 但当遇到:“U.S.dollar,...,Yahoo!“这类词的时候如果使用标点符号进行分割就会不恰当。
按照标点后有大写字母的规则进行分割:
- 可以使用正则表达式实现这个想法
- 但当遇到:”Mr.Brown“这类词的时候虽然也满足正则表达式,但是分割的不恰当。
按照词典分割:
- 这似乎是一个更好的办法,但是我们很难罗列出所有的名字和缩写。
总的来说,我们没有合适的规则用于句子分割,应该使用 machine learning。
3.1 Binary Classifier 二分类器
- Looks at every "." and decides whether it is the end of a sentence.
- Decision trees, logistic regression
- Features
- Look at the words before and after ".”
- Word shapes:
- Uppercase, lowercase, ALL_CAPS, number 大写、小写、ALL_CAPS、数字
- Character length 字符长度
- Part-of-speech tags
- Determiners tend to start a sentence 定语从句倾向于开始一个句子
4. Word Tokenisation
4.1 Word Tokenisation: English
- Naive approach: separate out alphabetic strings (\w+)
- Abbreviations (U.S.A.)