Description Usage Arguments Details Value Word types Word info codes Author(s) Examples
Generates sentences by inserting randomly selected words of specified word types at specified locations in sentence structures.
Use internal sentence structures and / or provide your own.
Use internal word lists and / or provide your own.
Specify constraints on the selection of words.
1 2 | generate_sentence(n = 1, structures = NULL, word_lists = NULL,
int_structures = TRUE, int_word_lists = TRUE)
|
n |
Number of sentences to generate (Integer). |
structures |
Character Vector. E.g.:
Constrain the selection of words by specifying word info codes. E.g. only sample elements from the word list with max. 1 word in them, i.e. no white spaces:
Pass multiple word types - from which one is randomly selected:
See available See available |
word_lists |
List of word lists. A word list is named by the word type, e.g. verb. |
int_structures |
Use internal structures (Logical). |
int_word_lists |
Use internal word lists (Logical). |
A structure is randomly chosen. To make sure you get a specific structure, pass only one structure and set int_structures to FALSE.
Character Vector
Word lists have been collected from the internet. They might contain words that seem out of place. Let me know and I'll remove them.
[superb] [positive_adj] [positive_vb] [positive_vb_past] [positive_adv]
[verb_base] [verb_past] [verb_past_participle] [verb_es] [verb_ing]
[noun] [noun_plural]
[salutation] [male_first_name] [female_first_name] [male_full_name] [female_full_name]
Notice: These are added as needed by author.
[create_syn] [small_syn] [big_syn]
[nationality_adj] [nationality_people]
[statistics_tradition]
Sample from elements with maximum number of words, i.e. number of white spaces -1.
E.g.: (w1)
Ludvig Renbo Olsen, r-pkgs@ludvigolsen.dk
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 | # Attach package
library(bhappyr)
# Create structures
st <- c("[salutation]! You are [positive_adj] today! ;)",
"You [positive_vb_past] that code! [positive_adj]!")
# Create list of word lists
wl <- list("salutation" = c("Sir", "Mother", "Dear", "Friend"),
"positive_adj" = c("beautiful", "bright", "smart"),
"positive_vb_past" = c("accomplished","played", "modified"))
## Example 1
# Using internal structures + word lists
# Generate 1 sentence
generate_sentence()
## Example 2
# Providing structures
# and not using internal structures
# Generate 2 sentences
generate_sentence(n = 3, structures = st,
int_structures = FALSE)
## Example 3
# Providing word_lists and structures
# and not using internal word_lists and structures
# Generate 3 sentences
generate_sentence(n = 3, structures = st,
word_lists = wl,
int_structures = FALSE,
int_word_lists = FALSE)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.