import_dictionary: Import dictionary from common formats

View source: R/dictionary.r

import_dictionaryR Documentation

Import dictionary from common formats

Description

To use a dictionary in this package, it needs to be a data.frame with a 'string' column. Also, if a string in the dictionary is a multitoken string, it needs to be wrapped in quotes ("like this") or angle brackets (<like this>). Otherwise, spaces will be considered as OR operators (see query_syntax). This function helps prepare dictionaries as such. It can take either a quanteda dictionary2 class, or any data.frame type dictionary where each row holds a dictionary term.

Usage

import_dictionary(
  dict,
  auto_quote = T,
  string_alias = c("query", "word", "term", "text")
)

Arguments

dict

A data.frame where each row is a dictionary term or a quanteda dictionary2 class object.

auto_quote

If TRUE (default), ensures multitoken terms are quoted

string_alias

If dict is a data.frame and doesn't have a column called "string", check these aliases to rename a column to "string". (If your dict doesn't have a column with any of these column names, just specify the name here)

Value

A dictionary in data.frame form, ready to be used in the dict_ functions.

Examples

d = data.frame(term = c('good','not good'), label=c('positive','negative'))
import_dictionary(d)

kasperwelbers/textquery documentation built on Dec. 24, 2024, 12:47 a.m.