Learn R Programming

quanteda (version 0.99.22)

spacyr-methods: extensions for and from spacy_parse objects

Description

These functions provide quanteda methods for spacyr objects, and also extend spacy_parse to work with corpus objects.

Usage

# S3 method for corpus
spacy_parse(x, ...)

Arguments

x

an object returned by spacy_parse, or (for spacy_parse) a corpus object

...

unused except for spacy_parse, in which case it passes through extra arguments to that function

Usage

docnames(x) returns the document names

ndoc(x) returns the number of documents

ntoken(x, ...) returns the number of tokens by document

ntype(x, ...) returns the number of types (unique tokens) by document

spacy_parse(x, ...) is also defined for a quanteda corpus

Examples

Run this code
# NOT RUN {
library("spacyr")
spacy_initialize()

txt <- c(doc1 = "And now, now, now for something completely different.",
         doc2 = "Jack and Jill are children.")
parsed <- spacy_parse(txt)
ntype(parsed)
ntoken(parsed)
ndoc(parsed)
docnames(parsed)

corpus_subset(data_corpus_inaugural, Year <= 1793) %>% spacy_parse()
# }

Run the code above in your browser using DataLab