txt_count {udpipe}R Documentation

Count the number of times a pattern is occurring in text

Description

Count the number of times a pattern is occurring in text. Pattern counting is performed by executing a regular expression using gregexpr and checking how many times the regular expression occurs.

Usage

txt_count(x, pattern, ...)

Arguments

x

a character vector with text

pattern

a text pattern which might be contained in x

...

other arguments, passed on to gregexpr

Value

an integer vector of the same length as x indicating how many times the pattern is occurring in x

Examples

x <- c("abracadabra", "ababcdab", NA)
txt_count(x, pattern = "ab")
txt_count(x, pattern = "AB", ignore.case = TRUE)
txt_count(x, pattern = "AB", ignore.case = FALSE)

[Package udpipe version 0.8.11 Index]