week1-text preprocessing->feature extraction


tips: text classification can be used to sentiment analysis.

text preprocessing

Tokenization

How to process text depends on what you think of text as.
a sequence of

  • characters
  • words
  • phrases and named entities
  • sentences
  • paragraphs

Here, we think of text as a sequence of words because we reckon that a word is a meaningful sequence of characters.
Therefore, we should extract all words from a sentence.This process is called tokenization. So what’s the boundary of words?
Here, we mainly talk about English.
In English we can split a sentence by spaces or punctuation.
Three methods of tokenization are built in Python ntlk liberary.

  1. whitespace tokenizer
  2. puctuation tokenizer
  3. treebankword tokenizer

examples

Normalization

  • stemming
    rules of stemming

  • lemmatization
    rules of lemmatization

examples

transforming tokens into features / text to text vector

== bag of words==

  • count occurrences of a particular token in our text
    the most simple
    problems:
  1. loose word order
  2. counters are not normalized
  • so, for word order, we count token pairs, triplets,etc. n-gram
  • therefore, there are too many features
  • then, we remove some n-grams based on their occurrence frequency in documents of our corpus(df).(remove too high or too low)
  • and then, all features we have are moderately appearing among documents of our corpus. Next, we should focus on the value of feature columns.–or term frequency.
    step by step
  • and then more accurately, we can get df in detail, not just medium df.

-IDF

Then, we multiply them together as the value of feature column.
Tf-Idf

python code
python code

For now, you have vectorize your text by using a couple of numbers. You still don’t do text classification. The simplist way is logestic regression.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值