The features of two objects, usually a partition defining a corpus of interest (coi), and a partition defining a reference corpus (ref) are compared. The most important purpose is term extraction.

features(x, y, ...)

# S4 method for class 'partition'
features(x, y, included = FALSE, method = "chisquare", verbose = FALSE)

# S4 method for class 'count'
features(
  x,
  y,
  by = NULL,
  included = FALSE,
  method = "chisquare",
  verbose = TRUE
)

# S4 method for class 'partition_bundle'
features(
  x,
  y,
  included = FALSE,
  method = "chisquare",
  verbose = TRUE,
  mc = getOption("polmineR.mc"),
  progress = FALSE
)

# S4 method for class 'count_bundle'
features(
  x,
  y,
  included = FALSE,
  method = "chisquare",
  verbose = !progress,
  mc = getOption("polmineR.mc"),
  progress = FALSE
)

# S4 method for class 'ngrams'
features(x, y, included = FALSE, method = "chisquare", verbose = TRUE, ...)

# S4 method for class 'Cooccurrences'
features(x, y, included = FALSE, method = "ll", verbose = TRUE)

Arguments

x

A partition or partition_bundle object.

y

A partition object, it is assumed that the coi is a subcorpus of ref

...

further parameters

included

TRUE if coi is part of ref, defaults to FALSE

method

the statistical test to apply (chisquare or log likelihood)

verbose

A logical value, defaults to TRUE

by

the columns used for merging, if NULL (default), the p-attribute of x will be used

mc

logical, whether to use multicore

progress

logical

References

Baker, Paul (2006): Using Corpora in Discourse Analysis. London: continuum, p. 121-149 (ch. 6).

Manning, Christopher D.; Schuetze, Hinrich (1999): Foundations of Statistical Natural Language Processing. MIT Press: Cambridge, Mass., pp. 151-189 (ch. 5).

Author

Andreas Blaette

Examples

if (FALSE) { # \dontrun{
use("polmineR")

kauder <- partition(
  "GERMAPARLMINI",
  speaker = "Volker Kauder", interjection = "speech",
  p_attribute = "word"
  )
all <- partition("GERMAPARLMINI", interjection = "speech", p_attribute = "word")

terms_kauder <- features(x = kauder, y = all, included = TRUE)
top100 <- subset(terms_kauder, rank_chisquare <= 100)
head(top100)

# a different way is to compare count objects
kauder_count <- as(kauder, "count")
all_count <- as(all, "count")
terms_kauder <- features(kauder_count, all_count, included = TRUE)
top100 <- subset(terms_kauder, rank_chisquare <= 100)
head(top100)
} # }

# get matrix with features (dontrun to keep time for examples short)
if (FALSE) { # \dontrun{
use("RcppCWB")
docs <- partition_bundle("REUTERS", s_attribute = "id") %>%
  enrich( p_attribute = "word")
all <- corpus("REUTERS") %>%
  count(p_attribute = "word")
docs_terms <- features(docs[1:5], all, included = TRUE, progress = FALSE)
dtm <- as.DocumentTermMatrix(docs_terms, col = "chisquare", verbose = FALSE)
} # }
# Get features of objects in a count_bundle
ref <- corpus("GERMAPARLMINI") %>% count(p_attribute = "word")
cois <- corpus("GERMAPARLMINI") %>%
  subset(speaker %in% c("Angela Dorothea Merkel", "Hubertus Heil")) %>%
  split(s_attribute = "speaker") %>%
  count(p_attribute = "word")
#> ℹ bundle class: subcorpus_bundle
#> ℹ objects in bundle: plpr_subcorpus
#> ℹ s-attribute for splitting ("speaker") is sibling of s-attribute "speaker"
#> ℹ s-attribute "speaker" has values: yes
#> ℹ get list of regions
#> ✔ get list of regions [7ms]
#> 
#> ℹ instantiate 2 plpr_subcorpus objects 
#> ✔ instantiate 2 plpr_subcorpus objects  [10ms]
#> 
y <- features(cois, ref, included = TRUE, method = "chisquare", progress = TRUE)