otsoft_bias_to_df: Converts an OTSoft bias file to a data frame

View source: R/read-data.R

otsoft_bias_to_dfR Documentation

Converts an OTSoft bias file to a data frame

Description

Loads an OTSoft bias file and converts it to the data frame format used by the maxent.ot functions.

Usage

otsoft_bias_to_df(input, output_path = NA)

Arguments

input

The path to the input bias file. This should contain more OT tableaux consisting of mappings between underlying and surface forms with observed frequency and violation profiles. Constraint violations must be numeric.

The file should be in OTSoft format. For examples of OTSoft format, see inst/extdata/sample_bias_file_otsoft.txt.

output_path

(optional) A string specifying the path to a file to which the data frame will be saved in CSV format. If the file exists it will be overwritten. If this argument isn't provided, the output will not be written to a file.

Value

A data frame corresponding to the input OTSoft bias file, containing the columns

  • Constraint: The constraint name.

  • Mu: The mu value for the regularization term.

  • Sigma: The sigma value for the regularization term.

Examples

  # Convert OTSoft bias file to data frame format
  otsoft_file <- system.file(
      "extdata", "sample_bias_file_otsoft.txt", package = "maxent.ot"
  )
  df_output <- otsoft_bias_to_df(otsoft_file)

  # Save data frame to a file
  tmp_output <- tempfile()
  otsoft_bias_to_df(otsoft_file, tmp_output)

connormayer/maxent.ot documentation built on Nov. 24, 2024, 1:21 p.m.