getters: ngram Getters

Description Usage Arguments Details See Also Examples

Description

Some simple "getters" for ngram objects. Necessary since the internal representation is not a native R object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
ng_order(ng, decreasing = FALSE)

## S4 method for signature 'ngram'
ng_order(ng, decreasing = FALSE)

get.ngrams(ng)

## S4 method for signature 'ngram'
get.ngrams(ng)

get.string(ng)

## S4 method for signature 'ngram'
get.string(ng)

get.nextwords(ng)

## S4 method for signature 'ngram'
get.nextwords(ng)

Arguments

ng

An ngram object.

decreasing

Should the sorted order be in descending order?

Details

ngram.order returns an R vector with the original corpus order of the ngrams.

get.ngrams() returns an R vector of all n-grams.

get.nextwords() does nothing at the moment; it will be implemented in future releases.

getnstring() recovers the input string as an R string.

See Also

ngram-class, ngram

Examples

1
2
3
4
5
library(ngram)

str = "A B A C A B B"
ng = ngram(str)
get.ngrams(ng)[ng_order(ng)]

ngram documentation built on Oct. 31, 2021, 5:06 p.m.