Learn R Programming

bdpar (version 1.0.1)

ContractionPipe: Class to find and/or replace the contractions on the data field of a Instance

Description

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

Usage

ContractionPipe

Arguments

Constructor

ContractionsPipe$new(propertyName = "contractions",
                     propertyLanguageName = "language",
                     alwaysBeforeDeps = list("GuessLanguagePipe"),
                     notAfterDeps = list())
  • Arguments:

    • propertyName: (character) name of the property associated with the Pipe.

    • propertyLanguageName: (character) name of the language property.

    • alwaysBeforeDeps: (list) the dependences alwaysBefore (Pipes that must be executed before this one).

    • notAfterDeps: (list) the dependences notAfter (Pipes that cannot be executed after this one).

Inherit

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

Methods

  • pipe: preprocesses the Instance to obtain/replace the contractions. The contractions found in the Pipe are added to the list of properties of the Instance If the replaceContractions parameter is TRUE, the Instance data will be modified by replacing the contractions found.

    • Usage: pipe(instance, replaceContractions = TRUE)

    • Value: the Instance with the modifications that have occurred in the Pipe.

    • Arguments:

      • instance: (Instance) Instance to preproccess.

      • replaceContractions: (logical) indicates if the contractions are replace or not.

  • findContraction: checks if the contractions is in the data.

    • Usage: findContraction(data, contraction)

    • Value: boolean, depending on whether the contraction is on the data.

    • Arguments:

      • data: (character) text where contraction will be searched.

      • contraction: (character) indicates the contraction to find.

  • replaceContraction: replaces the contraction in the data for the extendedContraction.

    • Usage: replaceContraction(contraction, extendedContraction, data)

    • Value: the data with the contractions replaced.

    • Arguments:

      • contraction: (character) indicates the contraction to remove.

      • extendedContraction: (character) indicates the string to replace for the contraction found.

      • data: (character) text where contraction will be replaced.

  • getPropertyLanguageName:. gets of name of property language.

    • Usage: getPropertyLanguageName()

    • Value: value of name of property language.

  • getResourcesContractionsPath: gets of path of contractions resources.

    • Usage: getResourcesContractionsPath()

    • Value: value of path of contractions resources.

  • setResourcesContractionsPath: sets the path of contractions resources.

    • Usage: setResourcesContractionsPath(path)

    • Arguments:

      • path: (character) the new value of the path of contractions resources.

Private fields

  • propertyLanguageName: (character) the name of property about language.

  • resourcesContractionsPath: (character) the path where are the resources.

Details

ContractionPipe class requires the resource files (in json format) containing the correspondence between contractions and meaning. To this end, the language of the text indicated in the propertyLanguageName should be contained in the resource file name (ie. contr.xxx.json where xxx is the value defined in the propertyLanguageName ). The location of the resources should defined in the resourcesPath section of the configuration file.

[resourcesPath]

resourcesContractionsPath = <<resources_contractions_path>>

See Also

AbbreviationPipe, File2Pipe, FindEmojiPipe, FindEmoticonPipe, FindHashtagPipe, FindUrlPipe, FindUserNamePipe, GuessDatePipe, GuessLanguagePipe, Instance, InterjectionPipe, MeasureLengthPipe, PipeGeneric, ResourceHandler, SlangPipe, StopWordPipe, StoreFileExtPipe, TargetAssigningPipe, TeeCSVPipe, ToLowerCasePipe