Pretreatment: Pretreatment of textual documents for NLP.

Description Usage Arguments Details Value Author(s) Examples

View source: R/Personal_Functions.R

Description

This function goes through a number of pretreatment steps in preparation for vectorization. These steps are designed to help the data become more standard so that there are fewer outliers when training during NLP. The following effects are applied: 1. Non-alpha/numerics are removed. 2. Numbers are separated from letters. 3. Numbers are replaced with their word equivalents. 4. Words are stemmed (optional). 5. Words are lowercased (optinal).

Usage

1
Pretreatment(title_vec, stem = TRUE, lower = TRUE, parallel = F)

Arguments

title_vec

Vector of documents to be pre-treated.

stem

Boolian variable to decide whether to stem or not.

lower

Boolian variable to decide whether to lowercase words or not.

parallel

Boolian variable to decide whether to run this function in parallel or not.

Details

This function returns a list. It should be able to accept any format that the function lapply would accept. The parallelization is done with the function Mcapply from the package 'parallel' and will only work on systems that allow forking (Sorry windows users). Future updates will allow for socketing.

Value

output

The list of character strings post-pretreatment

Author(s)

Travis Barton

Examples

1
2
3
4
5
6
7
8
9
if(!('textclean' %in% sessionInfo()$otherPkgs || 'tm' %in% sessionInfo()$otherPkgs))
{
  #if(.Platform$OS.type != "unix"){install.packages('SnowballC')}
  library(textclean)
  library(tm)
}
test_vec = c('This is a test', 'Ahoy!', 'my battle-ship is on... b6!')
res = Pretreatment(test_vec)
print(res)

LilRhino documentation built on Oct. 31, 2019, 4:59 p.m.