Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Mastering Text Mining with R
Mastering Text Mining with R

Mastering Text Mining with R: Extract and recognize your text data

eBook
€8.99 €26.99
Paperback
€32.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Mastering Text Mining with R

Chapter 2. Processing Text

A significant part of the time spent on any modeling or analysis activity goes into accessing, preprocessing, and cleaning the data. We should have the capability to access data from diverse sources, load them in our statistical analysis environment and process them in a manner conducive for advanced analysis.

In this chapter, we will learn to access data from a wide variety of sources and load it into our R environment. We will also learn to perform some standard text processing.

By the time you finish the chapter, you should be equipped with enough knowledge to retrieve data from most of the data sources and process it into custom corpus for further analysis:

  • Accessing texts from diverse sources
  • Processing texts using regular expressions
  • Normalizing texts
  • Lexical diversity
  • Language detection

Accessing text from diverse sources

Reading data from diverse sources for analysis, and exporting the results to another system for reporting purposes can be a daunting task that can sometimes take even more time than the real analysis. There are various sources from which we can gather text; some of them are HTML pages, social media, RSS feeds, JSON or XML, enterprise environments, and so on. The source has a very important role to play in the quality of textual data and the way we access the source. For instance, in the case of an enterprise environment, the common sources of text or data can be database and log files. In a web ecosystem, web pages are the source of data. When we consider web service applications, the sources can be JSON or XML over HTTP or HTTPS. We will look into various data sources and ways in which we can collect data from them.

File system

Reading from a file system is a very basic capability that any programming language should provide. We may have collections of...

Processing text using regular expressions

The web consists predominantly of unstructured text. One of the main tasks in web scraping is to collect the relevant information from heaps of textual data. Within the unstructured text we are often interested in specific information, especially when we want to analyze the data using quantitative methods. Specific information can include numbers such as phone numbers, zip codes, latitude, longitude, or addresses.

First, we gather the unstructured text, next we determine the recurring patterns behind the information we are looking for, and then we apply these patterns to the unstructured text to extract the information. When we are web scraping, we have to identify and extract those parts of the document that contain the relevant information. Ideally, we can do so using xpath althrough, sometimes the crucial information is hidden within values. Sometimes relevant information might be scattered across an HTML document. We need to write regular expressions...

Normalizing texts

Normalization in text basically refers to standardization or canonicalization of tokens, which we derived from documents in the previous step. The simplest scenario possible could be the case where query tokens are an exact match to the list of tokens in document, however there can be cases when that is not true. The intent of normalization is to have the query and index terms in the same form. For instance, if you query U.K., you might also be expecting U.K.

Token normalization can be performed either by implicitly creating equivalence classes or by maintaining the relations between unnormalized tokens. There might be cases where we find superficial differences in character sequences of tokens, in such cases query and index term matching becomes difficult. Consider the words anti-disciplinary and anti-disciplinary. If both these words get mapped into one term named after one of the members of the set for example anti-disciplinary, text retrieval would become so efficient...

Lexical diversity

Consider a speaker, who uses the term allow multiple times throughout the speech, compared to an another speaker who uses terms allow, concur, acquiesce, accede, and avow for the same word. The latter speech has more lexical diversity than the former. Lexical diversity is widely believed to be an important parameter to rate a document in terms of textual richness and effectiveness.

Lexical diversity, in simple terms, is a measurement of the breadth and variety of vocabulary used in a document. The different measures of lexical diversity are TTR, MSTTR, MATTR, C, R, CTTR, U, S, K, Maas, HD-D, MTLD, and MTLD-MA.

koRpus package in R provides functions to estimate the lexical diversity or complexity.

If N is the total number of tokens and V is the number of types:

Measure

Description

Wrapper Function (koRpus package in R)

TTR

Type-Token Ratio

TTR

MSTTR

Mean segment type token ratio

MSTTR

C

logTTR

C.ld

R

Root TTR

R.ld

CTTR

Corrected TTR

CTTR

U

Uber Index

U...

Language detection

TextCat is a text classification utility. The primary usage of TextCat is language identification. textcat package in R provides wrapper function for n-gram based text categorization and the language detection. It can detect up to 75 languages:

Library(textcat)>my.profiles <- TC_byte_profiles[names(TC_byte_profiles)]
>my.profiles

A textcat profile db of length 75.

> my.text <- c("This book is in English language",
 "Das ist ein deutscher Satz.",
 "Il s'agit d'une phrase française.",
 "Esta es una frase en espa~nol.")
 textcat(my.text, p = my.profiles)
> textcat(my.text, p = my.profiles)

[1] "english" "german"  "french"  "spanish"

Accessing text from diverse sources


Reading data from diverse sources for analysis, and exporting the results to another system for reporting purposes can be a daunting task that can sometimes take even more time than the real analysis. There are various sources from which we can gather text; some of them are HTML pages, social media, RSS feeds, JSON or XML, enterprise environments, and so on. The source has a very important role to play in the quality of textual data and the way we access the source. For instance, in the case of an enterprise environment, the common sources of text or data can be database and log files. In a web ecosystem, web pages are the source of data. When we consider web service applications, the sources can be JSON or XML over HTTP or HTTPS. We will look into various data sources and ways in which we can collect data from them.

File system

Reading from a file system is a very basic capability that any programming language should provide. We may have collections of...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • Develop all the relevant skills for building text-mining apps with R with this easy-to-follow guide
  • Gain in-depth understanding of the text mining process with lucid implementation in the R language
  • Example-rich guide that lets you gain high-quality information from text data

Description

Text Mining (or text data mining or text analytics) is the process of extracting useful and high-quality information from text by devising patterns and trends. R provides an extensive ecosystem to mine text through its many frameworks and packages. Starting with basic information about the statistics concepts used in text mining, this book will teach you how to access, cleanse, and process text using the R language and will equip you with the tools and the associated knowledge about different tagging, chunking, and entailment approaches and their usage in natural language processing. Moving on, this book will teach you different dimensionality reduction techniques and their implementation in R. Next, we will cover pattern recognition in text data utilizing classification mechanisms, perform entity recognition, and develop an ontology learning framework. By the end of the book, you will develop a practical application from the concepts learned, and will understand how text mining can be leveraged to analyze the massively available data on social media.

Who is this book for?

If you are an R programmer, analyst, or data scientist who wants to gain experience in performing text data mining and analytics with R, then this book is for you. Exposure to working with statistical methods and language processing would be helpful.

What you will learn

  • Get acquainted with some of the highly efficient R packages such as OpenNLP and RWeka to perform various steps in the text mining process
  • Access and manipulate data from different sources such as JSON and HTTP
  • Process text using regular expressions
  • Get to know the different approaches of tagging texts, such as POS tagging, to get started with text analysis
  • Explore different dimensionality reduction techniques, such as Principal Component Analysis (PCA), and understand its implementation in R
  • Discover the underlying themes or topics that are present in an unstructured collection of documents, using common topic models such as Latent Dirichlet Allocation (LDA)
  • Build a baseline sentence completing application
  • Perform entity extraction and named entity recognition using R

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Dec 28, 2016
Length: 258 pages
Edition : 1st
Language : English
ISBN-13 : 9781782174707
Category :
Languages :
Concepts :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Dec 28, 2016
Length: 258 pages
Edition : 1st
Language : English
ISBN-13 : 9781782174707
Category :
Languages :
Concepts :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 130.97
R: Recipes for Analysis, Visualization and Machine Learning
€67.99
Learning Bayesian Models with R
€29.99
Mastering Text Mining with R
€32.99
Total 130.97 Stars icon
Banner background image

Table of Contents

8 Chapters
1. Statistical Linguistics with R Chevron down icon Chevron up icon
2. Processing Text Chevron down icon Chevron up icon
3. Categorizing and Tagging Text Chevron down icon Chevron up icon
4. Dimensionality Reduction Chevron down icon Chevron up icon
5. Text Summarization and Clustering Chevron down icon Chevron up icon
6. Text Classification Chevron down icon Chevron up icon
7. Entity Recognition Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.4
(11 Ratings)
5 star 9.1%
4 star 9.1%
3 star 18.2%
2 star 36.4%
1 star 27.3%
Filter icon Filter
Top Reviews

Filter reviews by




Akhilesh Jan 13, 2017
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Nice explanation of complex concepts in simple language , with great flow . Its a good read for beginners and intermediate readers in text mining.
Amazon Verified review Amazon
ajitB Feb 15, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Great compendium of state-of-the-art algos for text mining!
Amazon Verified review Amazon
Dr. S. B. Bhattacharyya Jul 18, 2018
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Far too many typographical errors. Examples just satisfactory.
Amazon Verified review Amazon
Raman Kumar Dec 02, 2018
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
Good book, although if you are a beginner in NLP, dont go for it, it wont make much sense. If you are good in statiatics atleast basics this books will he helpful for some of the approaches.
Amazon Verified review Amazon
Chris May 26, 2017
Full star icon Full star icon Empty star icon Empty star icon Empty star icon 2
Barely found this book is useful.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.