spacyr-methods: Extensions for and from spacy_parse objects

Description Usage Arguments Usage Examples

Description

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

Usage

1
2
## S3 method for class '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

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

## End(Not run)

quanteda/quanteda documentation built on Feb. 16, 2019, 5:45 a.m.