File: spacyr.R

package info (click to toggle)
r-cran-nlp 0.3-2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 456 kB
  • sloc: makefile: 2
file content (30 lines) | stat: -rw-r--r-- 583 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
## 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]]))
}