ExtractWords: Function to extract words from a .txt file

Description Usage Arguments Examples

Description

Function to extract words from a .txt file. For example a book from Project Gutenberg http://www.gutenberg.org/wiki/Main_Page.

Usage

1
ExtractWords(data.txt = NULL, data.r = NULL, words.min.length = 3)

Arguments

data.txt

a .txt file from your working directory (say, your favorite book)

data.r

a character string

words.min.length

The minimum legth of the words to be extracted. Default value is 3.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
library(PasswordGen)

# Using the \code{gutenbergr} R package we will download a book and 
# extract words from it. Let's say, "The Adventures of Sherlock Holmes" by 
# Doyle, Arthur Conan

library(gutenbergr)
library(stringr)
# look up book and check the id on Gutenberg Project
info <- gutenberg_works(str_detect(title, "The Adventures of Sherlock Holmes"))
info$gutenberg_id # this should be 1661

# download the book
my_book <- gutenberg_download(gutenberg_id = 1661, meta_fields = "title",
                              mirror = "http://gutenberg.pglaf.org")

# Extract words
words <- ExtractWords(data.r = my_book$text)
words

# Generate passwords
password(no_words = 5, data = words)

# -----------
# Example 2 - Extract russian words and generate passwords

# check the id of the book on Gutenberg Project
info <- gutenberg_works(languages = 'ru')
info # let's take the first id: 5316

# download the book
my_book <- gutenberg_download(gutenberg_id = 5316, meta_fields = "title",
                              mirror = "http://gutenberg.pglaf.org")

# Extract words
words <- ExtractWords(data.r = my_book$text)

password(no_words = 5, data = words,
         numbers = FALSE, symbols = FALSE, sep = "-")

mpascariu/PasswordGen documentation built on May 23, 2019, 6:26 a.m.