countCompete: Count the number of competing referents to the current...

countCompetitorsR Documentation

Count the number of competing referents to the current mention

Description

This may either be counted within a window of tokens from the current one, or all referents competing with the current one may be counted, or a mix of both conditions. By default, we count referents intervening between the current and previous mention. Despite its name, tokenOrder can be set as unitSeqLast or similar.

Usage

countCompetitors(
  cond = NULL,
  windowSize = Inf,
  tokenSeq = NULL,
  unitSeq = NULL,
  chain = NULL,
  between = T,
  exclFrag = F,
  combinedChunk = NULL,
  nonFragmentMember = F,
  windowType = "unit"
)

countCompetitorsMatch(
  matchCol,
  windowSize = Inf,
  tokenOrder = NULL,
  chain = NULL,
  between = T,
  exclFrag = F,
  combinedChunk = NULL,
  nonFragmentMember = F
)

countMatchingCompetitors(
  matchCol,
  windowSize = Inf,
  tokenOrder = NULL,
  chain = NULL,
  between = T,
  exclFrag = F,
  combinedChunk = NULL,
  nonFragmentMember = F
)

Arguments

cond

The condition under which something counts as a competitor. Leave blank if anything goes.

windowSize

The size of the window in which you will be counting.

unitSeq

The vector of tokenOrder values where the mentions appeared. You can choose tokenOrderFirst, tokenOrderFirst, or maybe an average of the two. By default it's tokenOrderFirst.

chain

The chain that each mention belongs to.

between

Do we only count competitors between the current mention and previous mention? (If T, then the value is NA for first mentions.)

exclFrag

Exclude 'fragments' (i.e. members of a combined chunk which do not serve as meaningful chunks in their own right)

combinedChunk

The combinedChunk column of the rezrDF. By default, named combinedChunk.

nonFragmentMember

Vector indicating whether each entry is a non-fragment member, i.e. a member of a combined chunk that also serves as a meaningful chunk in its own right.

matchCol

The column for which a value is to be matched.

tokenOrder

The vector of sequence values values where the mentions appeared. Common choices are docTokenSeqFirst, docTokenSeqLast, wordTokenSeqFirst and wordTokenseqLast (the last two are available after running addIsWordField on a rezrObj. By default it's docTokenSeqLast.

Value

A vector of number of competitors.

Examples

sbc007$trackDF$default %>%
rez_mutate(isZero = (text == "<0>")) %>%
 rez_mutate(noCompetitors = countCompetitors(windowSize = 40, between = F),
            noMatchingCompetitors = countMatchingCompetitors(isZero, windowSize = 40, between = F))

johnwdubois/rezonateR documentation built on Nov. 19, 2024, 11:17 p.m.