ngrams that most frequently contain a keyword in a Gallicagram corpus for a specific month
gallicagram_with_month.Rd
Returns the most frequent ngrams containing a keyword for a given month
Usage
gallicagram_with_month(
keyword,
corpus = "lemonde",
year = 2022,
month = 1,
n_results = 20,
after = FALSE,
length = 2
)
Arguments
- keyword
A character string. Keyword to search. The string cannot contain more words than the
max_length
for this corpus, as indicated in thelist_corpora
dataset.- corpus
A character string. The corpus to search. The list of available corpora can be found in the
list_corpora
dataset.- year
An integer. The year of interest.
- month
An integer. The month of the
year
of interest.- n_results
An integer. The number of most frequently associated words to return.
n_results
can also be set to "all" to return all the available results.- after
A boolean. Whether to consider only words following the keyword and not those preceding. Set to
FALSE
by default.- length
An integer. The length of the ngrams considered. Can be up to 3 in the "books" and "press" corpora and 4 in the "lemonde" corpus.
Value
A tibble. With the n_results
most frequent ngrams containing
the keyword
searched (ngram
)
and the number of occurrences over the period (n_occur
).
It also returns the input parameters
keyword
, corpus
, year
and month
.
Details
This function is only available for the three main corpora (historical press, Gallica books, Le Monde newspaper).
This function corresponds to the joker_month
route of the API.
It is analogous to gallicagram_with
but for a precise month instead
of a given period.
For instance "camarade" is often followed by "staline" or "khrouchtchev" in
Le Monde. The function returns the most frequent ngrams of the form
"camarade *" when setting after = TRUE
. after = FALSE
also
includes the most frequent ngrams of the form "* camarade".
Searching the "press" corpus can require a long running time.
Examples
gallicagram_with_month("camarade")
#> # A tibble: 20 × 6
#> n_occur ngram keyword corpus year month
#> <int> <chr> <chr> <chr> <dbl> <dbl>
#> 1 9 un camarade camarade lemonde 2022 1
#> 2 8 camarade de camarade lemonde 2022 1
#> 3 5 le camarade camarade lemonde 2022 1
#> 4 4 d'un camarade camarade lemonde 2022 1
#> 5 4 camarade n camarade lemonde 2022 1
#> 6 3 son camarade camarade lemonde 2022 1
#> 7 3 leur camarade camarade lemonde 2022 1
#> 8 3 camarade staline camarade lemonde 2022 1
#> 9 3 camarade qui camarade lemonde 2022 1
#> 10 3 camarade du camarade lemonde 2022 1
#> 11 2 sa camarade camarade lemonde 2022 1
#> 12 2 du camarade camarade lemonde 2022 1
#> 13 2 camarade silencieux camarade lemonde 2022 1
#> 14 2 camarade pasternak camarade lemonde 2022 1
#> 15 2 camarade et camarade lemonde 2022 1
#> 16 2 bon camarade camarade lemonde 2022 1
#> 17 2 ancien camarade camarade lemonde 2022 1
#> 18 1 vrai camarade camarade lemonde 2022 1
#> 19 1 mauvais camarade camarade lemonde 2022 1
#> 20 1 explique camarade camarade lemonde 2022 1