Learn R Programming

bdpar (version 3.1.0)

SlangPipe: Class to find and/or replace the slangs on the data field of an Instance

Description

SlangPipe class is responsible for detecting the existing slangs in the data field of each Instance. Identified slangs are stored inside the slang field of Instance class. Moreover if needed, is able to perform inline slangs replacement.

Arguments

Inherit

This class inherits from GenericPipe and implements the pipe abstract function.

Super class

bdpar::GenericPipe -> SlangPipe

Methods

Inherited methods


Method new()

Creates a SlangPipe object.

Usage

SlangPipe$new(
  propertyName = "langpropname",
  propertyLanguageName = "language",
  alwaysBeforeDeps = list("GuessLanguagePipe"),
  notAfterDeps = list(),
  replaceSlangs = TRUE,
  resourcesSlangsPath = NULL
)

Arguments

propertyName

A character value. Name of the property associated with the GenericPipe.

propertyLanguageName

A character value. Name of the language property.

alwaysBeforeDeps

A list value. The dependencies alwaysBefore (GenericPipes that must be executed before this one).

notAfterDeps

A list value. The dependencies notAfter (GenericPipes that cannot be executed after this one).

replaceSlangs

A logical value. Indicates if the slangs are replaced or not.

resourcesSlangsPath

A character value. Path of resource files (in json format) containing the correspondence between slangs and meaning.


Method pipe()

Preprocesses the Instance to obtain/replace the slangs. The slangs found in the data are added to the list of properties of the Instance.

Usage

SlangPipe$pipe(instance)

Arguments

instance

A Instance value. The Instance to preprocess.

Returns

The Instance with the modifications that have occurred in the pipe.


Method findSlang()

Checks if the slang is in the data.

Usage

SlangPipe$findSlang(data, slang)

Arguments

data

A character value. The text where slang will be searched.

slang

A character value. Indicates the slang to find.

Returns

A logical value depending on whether the slang is in the data.


Method replaceSlang()

Replaces the slang in the data for the extendedSlang.

Usage

SlangPipe$replaceSlang(slang, extendedSlang, data)

Arguments

slang

A character value. Indicates the slang to replace.

extendedSlang

A character value. Indicates the string to replace for the slangs found.

data

A character value. The text where slang will be replaced.

Returns

The data with the slangs replaced.


Method getPropertyLanguageName()

Gets the name of property language.

Usage

SlangPipe$getPropertyLanguageName()

Returns

Value of name of property language.


Method getResourcesSlangsPath()

Gets the path of slangs resources.

Usage

SlangPipe$getResourcesSlangsPath()

Returns

Value of path of slangs resources.


Method setResourcesSlangsPath()

Sets the path of slangs resources.

Usage

SlangPipe$setResourcesSlangsPath(path)

Arguments

path

A character value. The new value of the path of slangs resources.


Method clone()

The objects of this class are cloneable with this method.

Usage

SlangPipe$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

SlangPipe class requires the resource files (in json format) containing the correspondence between slangs and meaning. To this end, the language of the text indicated in the propertyLanguageName should be contained in the resource file name (ie. slang.xxx.json where xxx is the value defined in the propertyLanguageName ). The location of the resources should be defined in the "resources.slangs.path" field of bdpar.Options variable.

See Also

AbbreviationPipe, bdpar.Options, ContractionPipe, File2Pipe, FindEmojiPipe, FindEmoticonPipe, FindHashtagPipe, FindUrlPipe, FindUserNamePipe, GuessDatePipe, GuessLanguagePipe, Instance, InterjectionPipe, MeasureLengthPipe, GenericPipe, ResourceHandler, StopWordPipe, StoreFileExtPipe, TargetAssigningPipe, TeeCSVPipe, ToLowerCasePipe