Skip to contents

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,
  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 the list_corpora dataset. "*" is a wildcard that can be used at the end of words and will represent any set of letters, e.g. "ecolo*" will return the counts for all words starting with "ecolo".

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.

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       8 camarade de         camarade lemonde  2022     1
#>  2       4 camarade n          camarade lemonde  2022     1
#>  3       3 camarade staline    camarade lemonde  2022     1
#>  4       3 camarade qui        camarade lemonde  2022     1
#>  5       3 camarade du         camarade lemonde  2022     1
#>  6       2 camarade silencieux camarade lemonde  2022     1
#>  7       2 camarade pasternak  camarade lemonde  2022     1
#>  8       2 camarade et         camarade lemonde  2022     1
#>  9       1 camarade à          camarade lemonde  2022     1
#> 10       1 camarade zaw        camarade lemonde  2022     1
#> 11       1 camarade win        camarade lemonde  2022     1
#> 12       1 camarade socialiste camarade lemonde  2022     1
#> 13       1 camarade se         camarade lemonde  2022     1
#> 14       1 camarade pour       camarade lemonde  2022     1
#> 15       1 camarade j'ai       camarade lemonde  2022     1
#> 16       1 camarade françois   camarade lemonde  2022     1
#> 17       1 camarade est        camarade lemonde  2022     1
#> 18       1 camarade d'un       camarade lemonde  2022     1
#> 19       1 camarade contaminé  camarade lemonde  2022     1
#> 20       1 camarade camille    camarade lemonde  2022     1