filterByDictionary

0th

Percentile

Word frequencies

The function filterByDictionary() can be used to filter a matrix as produced by frequencytable() by the words in the given dictionary(/-ies).

The function frequencytable() generates a matrix of word frequencies by drama, act or scene and/or by character. The output of this function can be fed to stylo.

Usage
filterByDictionary(ft,
  fields = DramaAnalysis::base_dictionary[fieldnames],
  fieldnames = c("Liebe"))

frequencytable(drama, acceptedPOS = postags$de$words, column = "Token.lemma", byCharacter = FALSE, sep = "|", normalize = FALSE, sortResult = FALSE, segment = c("Drama", "Act", "Scene"))

Arguments
ft

A matrix as produced by frequencytable().

fields

A list of lists that contains the actual field names. By default, we load the base_dictionary (as in dictionaryStatistics()).

fieldnames

A list of names for the dictionaries.

drama

A QDDrama. May be covering multiple texts.

acceptedPOS

A list of accepted pos tags. Words of all POS tags not in this list are filtered out. Specify NULL or an empty list to include all words.

column

The column name we should use (should be either Token.surface or Token.lemma)

byCharacter

Logical. Whether the count is by character or by text.

sep

The separation symbol that goes between drama name and character (if applicable). Defaults to the pipe symbol.

normalize

Whether to normalize values or not. If set to TRUE, the values are normalized by row sums.

sortResult

Logical. If true, the columns with the highest sum are ordered left (i.e., frequent words are visible first). If false, the columns are ordered alphabetically by column name.

segment

Character vector. Whether the count is by drama (default), act or scene

Value

Matrix of word frequencies in the format words X segments

See Also

stylo

Aliases
  • filterByDictionary
  • frequencytable
Examples
# NOT RUN {
data(rksp.0)
ftable <- frequencytable(rksp.0, 
                         byCharacter = TRUE)
                                              
filtered <- filterByDictionary(ftable, 
                               fieldnames=c("Krieg", "Familie"))

data(rksp.0)
st <- frequencytable(rksp.0)
# }
# NOT RUN {
stylo(gui=FALSE, frequencies = st)
# }
Documentation reproduced from package DramaAnalysis, version 3.0.0, License: GPL (>= 3)

Community examples

Looks like there are no examples yet.