invert_rules: invert_rules inverts a set of encoding rules.

View source: R/text_fun.R

invert_rulesR Documentation

invert_rules inverts a set of encoding rules.

Description

invert_rules allows decoding messages that were encoded by a set of rules x.

Usage

invert_rules(x)

Arguments

x

The rules used for encoding a message (as a named vector).

Details

x is assumed to be a named vector.

invert_rules replaces the elements of x by the names of x, and vice versa.

A message is issued if the elements of x are repeated (i.e., decoding is non-unique).

Value

A character vector.

See Also

transl33t for encoding text (e.g., into leet slang); l33t_rul35 for default rules used.

Other text objects and functions: Umlaut, capitalize(), caseflip(), cclass, chars_to_text(), collapse_chars(), count_chars_words(), count_chars(), count_words(), l33t_rul35, map_text_chars(), map_text_coord(), map_text_regex(), metachar, read_ascii(), text_to_chars(), text_to_sentences(), text_to_words(), transl33t(), words_to_text()

Examples

invert_rules(l33t_rul35)  # Note repeated elements

# Encoding and decoding a message:
(txt_0 <- "Hello world! How are you doing today?")             # message
(txt_1 <- transl33t(txt_0, rules = l33t_rul35))                # encoding 
(txt_2 <- transl33t(txt_1, rules = invert_rules(l33t_rul35)))  # decoding


ds4psy documentation built on Sept. 15, 2023, 9:08 a.m.