This chapter turns raw text into numbers you can analyze. It starts with a small web text example (Project Gutenberg) to show tokenization, cleaning, and why common words follow a Zipf-like distribution. You then build a preprocessing pipeline in R (tm, SnowballC, optional textstem): lowercasing, stop-word and custom word removal, punctuation/number stripping, stemming/lemmatization, and whitespace cleanup. Next, the chapter formalizes feature representation via the Vector Space Model: terms, documents, corpora DTM/TDM (with an explicit orientation note). It compares one-hot, count vectors, and TF-IDF (with intuitive Tf/Idf math and an example), and discusses sparsity, hapax legomena, and removeSparseTerms() thresholds for size reduction. You’ll run exploratory analysis: term frequencies, bar plots, word clouds, and term associations with findAssocs() (Pearson correlations over document vectors). Moving beyond unigrams, you build bigrams with RWeka, then visualize word networks using igraph/ggraph, including Louvain community detection to surface topical clusters. A mini case study contrasts Kindle Fire vs. iPad2 reviews using commonality clouds, comparison clouds, mirrored bigram pyramids, and unique-bigram charts—bridging technical features with marketing uses like SEO keyword discovery (and long-tail strategy).

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Basic Text Analysis, Preprocessing, Bag-of-Words, TF-IDF, and Exploratory Statistics

  • Daniel Dan,
  • Thomas Reutterer

摘要

This chapter turns raw text into numbers you can analyze. It starts with a small web text example (Project Gutenberg) to show tokenization, cleaning, and why common words follow a Zipf-like distribution. You then build a preprocessing pipeline in R (tm, SnowballC, optional textstem): lowercasing, stop-word and custom word removal, punctuation/number stripping, stemming/lemmatization, and whitespace cleanup. Next, the chapter formalizes feature representation via the Vector Space Model: terms, documents, corpora DTM/TDM (with an explicit orientation note). It compares one-hot, count vectors, and TF-IDF (with intuitive Tf/Idf math and an example), and discusses sparsity, hapax legomena, and removeSparseTerms() thresholds for size reduction. You’ll run exploratory analysis: term frequencies, bar plots, word clouds, and term associations with findAssocs() (Pearson correlations over document vectors). Moving beyond unigrams, you build bigrams with RWeka, then visualize word networks using igraph/ggraph, including Louvain community detection to surface topical clusters. A mini case study contrasts Kindle Fire vs. iPad2 reviews using commonality clouds, comparison clouds, mirrored bigram pyramids, and unique-bigram charts—bridging technical features with marketing uses like SEO keyword discovery (and long-tail strategy).