wordsDictionary: Create a wordsDictionary Object for txt File.

Description Usage Arguments Details Value Author(s) Examples

Description

This package includes functions to create wordsDictionary object for txt file, find frequency of target word in wordsDictionary and plot words' frequency.

Usage

1
2
3
4
5
6
7
wordsDictionary(fileName, removeStopWords = TRUE)
getFrequency(object, ...)
plotDic(object, ...)
## S3 method for class 'wordsDictionary'
getFrequency(object, word, type = "frequency", ...)
## S3 method for class 'wordsDictionary'
plotDic(object, yType = "frequency", minFeq = 1, ...)

Arguments

fileName

An URL, indicating the location of the target txt file.

removeStopWords

Logical value, indicating whether to remove stop words in dictionary. The default valur is TRUE.

object

A wordsDictionary object.

word

A string, indicating target word you want to find in dictionary.

type

"frequency" or "ratio", indicating the type of return value. The default value is "frequency".

yType

"frequency" or "ratio", indicating the type of value in y axis. The default value is "frequency".

minFeq

A number, indicating the minimal frequency, which is used to select words above the frequency to be plotted. The default value is 1.

...

Addtional arrguments not used here.

Details

wordsDictionary returns a list, you may use $ to access the element in a wordsDictionary object.

Value

wordsDictionary

returns a list. bagOfWords, unique words in txt file. dictionary, a dictionary generated from the txt file, implemented by a matrix.

getFrequency returns the frequency of the target word.

plotDic draws a plot of the dictionary.

Author(s)

Mengjie Wang

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Read in sample txt file, "rf.txt". It is a brief description of Roger Federer copied from Wiki.
mytxtPath <- system.file("extdata", "rf.txt", package = "wordsDictionary") 

# Create a wordsDictionary object.
myDictionary <- wordsDictionary(mytxtPath)

# Access the bagOfWords attribute, which is the unique word in this txt file.
myDictionary$bagOfWords

# Get the frequency of "roger" in txt file.
getFrequency(myDictionary, "roger")

# Get the ratio of "roger" in txt file.
getFrequency(myDictionary, "roger", "ratio")

# Plot the words whoes frequency is at least 3.
plotDic(myDictionary, minFeq = 3)

Mengjie4FED/CPSC499 documentation built on May 28, 2019, 6:40 a.m.