frequencyTable: Word frequencies

Description Usage Arguments Value See Also Examples

Description

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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

Examples

1
2
3
4
5
6
7
8
9
data(rksp.0)
ftable <- frequencytable(rksp.0, 
                         byCharacter = TRUE)
                                              
filtered <- filterByDictionary(ftable, 
                               fieldnames=c("Krieg", "Familie"))

data(rksp.0)
st <- frequencytable(rksp.0)

DramaAnalysis documentation built on Jan. 13, 2021, 10:02 p.m.