Using CQP queries requires a two-step procedure: At first, you execute a query using cqp_query. Then, cqp_dump_subcorpus will return a matrix with the regions of the matches for the query.

cqp_query(corpus, query, subcorpus = "QUERY")

cqp_dump_subcorpus(corpus, subcorpus = "QUERY")

cqp_subcorpus_size(corpus, subcorpus = "QUERY")

cqp_list_subcorpora(corpus)

cqp_drop_subcorpus(corpus)

Arguments

corpus

a CWB corpus

query

a CQP query

subcorpus

subcorpus name

Details

The cqp_query function executes a CQP query. The cqp_subcorpus_size function returns the number of matches for the CQP query. The cqp_dump_subcorpus function will return a two-column matrix with the left and right corpus positions of the matches for the CQP query.

References

Evert, S. 2005. The CQP Query Language Tutorial. Available online at https://cwb.sourceforge.io/files/CWB_Encoding_Tutorial.pdf

Author

Andreas Blaette, Bernard Desgraupes, Sylvain Loiseau

Examples

cqp_query(corpus = "REUTERS", query = '"oil";')
#> <pointer: 0x600001ead680>
cqp_subcorpus_size("REUTERS")
#> [1] 78
cqp_dump_subcorpus("REUTERS")
#>       [,1] [,2]
#>  [1,]   15   15
#>  [2,]   50   50
#>  [3,]   57   57
#>  [4,]   72   72
#>  [5,]   89   89
#>  [6,]  119  119
#>  [7,]  121  121
#>  [8,]  129  129
#>  [9,]  163  163
#> [10,]  173  173
#> [11,]  177  177
#> [12,]  200  200
#> [13,]  243  243
#> [14,]  300  300
#> [15,]  370  370
#> [16,]  473  473
#> [17,]  494  494
#> [18,]  549  549
#> [19,]  585  585
#> [20,]  608  608
#> [21,]  773  773
#> [22,]  780  780
#> [23,]  840  840
#> [24,] 1053 1053
#> [25,] 1091 1091
#> [26,] 1183 1183
#> [27,] 1244 1244
#> [28,] 1264 1264
#> [29,] 1294 1294
#> [30,] 1570 1570
#> [31,] 1689 1689
#> [32,] 1704 1704
#> [33,] 1818 1818
#> [34,] 1830 1830
#> [35,] 1953 1953
#> [36,] 2087 2087
#> [37,] 2112 2112
#> [38,] 2165 2165
#> [39,] 2189 2189
#> [40,] 2207 2207
#> [41,] 2295 2295
#> [42,] 2346 2346
#> [43,] 2451 2451
#> [44,] 2498 2498
#> [45,] 2520 2520
#> [46,] 2641 2641
#> [47,] 2785 2785
#> [48,] 2843 2843
#> [49,] 2875 2875
#> [50,] 2892 2892
#> [51,] 2920 2920
#> [52,] 2929 2929
#> [53,] 2984 2984
#> [54,] 3008 3008
#> [55,] 3026 3026
#> [56,] 3053 3053
#> [57,] 3072 3072
#> [58,] 3095 3095
#> [59,] 3144 3144
#> [60,] 3152 3152
#> [61,] 3183 3183
#> [62,] 3211 3211
#> [63,] 3252 3252
#> [64,] 3314 3314
#> [65,] 3319 3319
#> [66,] 3368 3368
#> [67,] 3412 3412
#> [68,] 3463 3463
#> [69,] 3468 3468
#> [70,] 3517 3517
#> [71,] 3585 3585
#> [72,] 3611 3611
#> [73,] 3645 3645
#> [74,] 3710 3710
#> [75,] 3749 3749
#> [76,] 3785 3785
#> [77,] 3835 3835
#> [78,] 3999 3999

cqp_query(corpus = "REUTERS", query = '"crude" "oil";')
#> <pointer: 0x600001ead680>
cqp_subcorpus_size("REUTERS", subcorpus = "QUERY")
#> [1] 12
cqp_dump_subcorpus("REUTERS")
#>       [,1] [,2]
#>  [1,]   14   15
#>  [2,]   56   57
#>  [3,]  548  549
#>  [4,]  584  585
#>  [5,]  607  608
#>  [6,] 2497 2498
#>  [7,] 2842 2843
#>  [8,] 2891 2892
#>  [9,] 2928 2929
#> [10,] 3644 3645
#> [11,] 3709 3710
#> [12,] 3998 3999