doc2bow: Create a dictionary

Description Usage Arguments Details Value Examples

View source: R/corpora.R

Description

Create a dictionary from a list of documents.

Usage

1
doc2bow(dictionary, docs)

Arguments

dictionary

A dictionary as returned by corpora_dictionary.

docs

A list of documents as returned by prepare_documents.

Details

Counts the number of occurrences of each distinct word, converts the word to its integer word id and returns the result as a sparse vector.

Value

A sparse matrix in the form, tuple.

Examples

1
2
3
docs <- prepare_documents(corpus)
dict <- corpora_dictionary(docs)
(corpora <- doc2bow(dict, docs))

news-r/gensimr documentation built on Jan. 9, 2021, 5:55 a.m.