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.
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"))
ft | A matrix as produced by |
---|---|
fields | A list of lists that contains the actual field names.
By default, we load the base_dictionary (as in |
fieldnames | A list of names for the dictionaries. |
drama | A |
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 |
Matrix of word frequencies in the format words X segments
stylo
data(rksp.0) ftable <- frequencytable(rksp.0, byCharacter = TRUE) filtered <- filterByDictionary(ftable, fieldnames=c("Krieg", "Familie")) data(rksp.0) st <- frequencytable(rksp.0)stylo(gui=FALSE, frequencies = st)#> Error in stylo(gui = FALSE, frequencies = st): could not find function "stylo"