Learn R Programming

crqanlp (version 0.3)

assign_codes: Assign codes

Description

It converts a sequence of words into a sequence of numerical identifier.

Usage

assign_codes(words, wordCode)

Arguments

words

Vector of strings (tokens)

wordCode

vector of strings (types)

Value

It returns the vector of words but now converted to a numerical identifier, which corresponds to the associated wordCode.

Details

Imagine we want to treat all words from the semantic category of animals in the same way. This function would allow the user to assign to different words, e.g, cat, dog or bird, the same identifier, e.g., 1. Note, words and wordCode need to have the same length.

Examples

Run this code
# NOT RUN {
library(corpus)
words    = c("bad", "bed", "joy", "sad") # words that we wish to locate in affect_wordnet
wordCode = affect_wordnet[,1]            # all words in affect_wordnet
assign_codes(words, wordCode)
 
# }

Run the code above in your browser using DataLab