R/spacyr.R

Defines functions tagged_sents.spacyr_parsed tagged_words.spacyr_parsed sents.spacyr_parsed words.spacyr_parsed

## Viewer methods for objects of class "spacyr_parsed" as obtained by
## spacyr::spacy_parse().

words.spacyr_parsed <-
function(x, ...)
{
    x$token
}

sents.spacyr_parsed <-
function(x, ...)
{
    split(x$token, x$sentence_id)
}

tagged_words.spacyr_parsed <-
function(x, which = c("pos", "tag"), ...)
{
    which <- match.arg(which)
    Tagged_Token(x$token, x[[which]])
}

tagged_sents.spacyr_parsed <-
function(x, which = c("pos", "tag"), ...)
{
    which <- match.arg(which)
    lapply(split(x, x$sentence_id),
           function(e) Tagged_Token(e$token, e[[which]]))
}    

Try the NLP package in your browser

Any scripts or data that you put into this service are public.

NLP documentation built on Oct. 23, 2020, 6:18 p.m.