as_pos: Extract Parts of Speech or Tokens from a 'tag_pos' Object

Description Usage Arguments Value Examples

Description

Extract parts of speech or corresponding tokens from a tag_pos object. This is useful for extracting part of speech based text features for modeling.

Usage

1
2
3
as_pos(x, collapse = TRUE, ...)

as_tokens(x, collapse = TRUE, ...)

Arguments

x

A tag_pos object.

collapse

logical. If TRUE the pos/tokens will be collapsed into a vector of paste collapsed strings. If FALSE the pos/tokens will be returned as a list of vectors.

...

ignored.

Value

Returns a vector of strings or a list of pos/tokens.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
library(dplyr)
presidential_debates_2012_pos %>%
    select_tags(c("NN", "NNP", "NNPS", "NNS")) %>%
    as_pos()

presidential_debates_2012_pos %>%
    select_tags(c("NN", "NNP", "NNPS", "NNS")) %>%
    as_pos(collapse = FALSE)


presidential_debates_2012_pos %>%
    select_tags(c("NN", "NNP", "NNPS", "NNS")) %>%
    as_tokens()

presidential_debates_2012_pos %>%
    select_tags(c("NN", "NNP", "NNPS", "NNS")) %>%
    as_tokens(collapse = FALSE)

trinker/tagger documentation built on May 31, 2019, 10:42 p.m.