Skip to contents

Returns the most frequent ngrams containing a keyword over a given period.

Usage

gallicagram_with(
  keyword,
  corpus = "lemonde",
  from = "earliest",
  to = "latest",
  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.

from

An integer or "earliest". The starting year. If set to "earliest", it uses the earliest date at which the data is reliable for this corpus, as described in list_corpora.

to

An integer or "latest". The end year. If set to "latest", it uses the latest date at which the data is reliable for this corpus, as described in list_corpora.

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, from and to.

Details

This function is only available for the three main corpora (historical press, Gallica books, Le Monde newspaper).

This function corresponds to the Joker route of the API, accessed through the 'Joker' function on the Gallicagram app. When length = 1, it is analogous to the 'Joker' function on Ngram Viewer.

It is analogous to gallicagram_with_month but for a period instead of a given month.

For instance "camarade" is often followed by "staline" or "khrouchtchev" in Le Monde. The function returns the most frequent ngrams of the form "camarade _" where "_" is a placeholder for any ngram of length up to length. When no placeholder is specified, it is assumed that one is located after keyword. The placeholder can be located within phrases. For example, "le _ staline".

The running time for the "presse" corpus can be long.

Examples

  gallicagram_with("camarade", from = 1960, to = 1970)
#> # A tibble: 20 × 6
#>    n_occur ngram                 keyword  corpus   from    to
#>      <int> <chr>                 <chr>    <chr>   <dbl> <dbl>
#>  1     256 camarade de           camarade lemonde  1960  1970
#>  2     124 camarade khrouchtchev camarade lemonde  1960  1970
#>  3      48 camarade dubcek       camarade lemonde  1960  1970
#>  4      44 camarade mao          camarade lemonde  1960  1970
#>  5      41 camarade et           camarade lemonde  1960  1970
#>  6      31 camarade waldeck      camarade lemonde  1960  1970
#>  7      27 camarade qui          camarade lemonde  1960  1970
#>  8      24 camarade du           camarade lemonde  1960  1970
#>  9      23 camarade togliatti    camarade lemonde  1960  1970
#> 10      22 camarade staline      camarade lemonde  1960  1970
#> 11      18 camarade d'écurie     camarade lemonde  1960  1970
#> 12      18 camarade à            camarade lemonde  1960  1970
#> 13      16 camarade maurice      camarade lemonde  1960  1970
#> 14      13 camarade a            camarade lemonde  1960  1970
#> 15      13 camarade des          camarade lemonde  1960  1970
#> 16      13 camarade le           camarade lemonde  1960  1970
#> 17      13 camarade roger        camarade lemonde  1960  1970
#> 18      12 camarade enver        camarade lemonde  1960  1970
#> 19      12 camarade guy          camarade lemonde  1960  1970
#> 20      11 camarade novotny      camarade lemonde  1960  1970