IPS-LMU / emuR

The main R package for the EMU Speech Database Management System (EMU-SDMS)
http://ips-lmu.github.io/EMU.html
23 stars 15 forks source link

create_itemsInLevel cannot be used on levels with multiple attributes #257

Open FredrikKarlssonSpeech opened 2 years ago

FredrikKarlssonSpeech commented 2 years ago

There are I think several issues with this function.

First, the description on how the function is supposed to be used needs some attention.

What is stated clearly in the help for the function is, however, that if you want to insert an ITEM/SEGMENT/EVENT onto a level with multiple attribute definitions, then you need to specify a label for each attribute. If I try, however, I get these errors:

> rlang::last_error()
<error/tibble_error_incompatible_size>
Tibble columns must have compatible sizes.
* Size 0: Existing data.
* Size 3: Column `attribute`.
ℹ Only values of size one are recycled.
Backtrace:
  [.... my function's calls removed to avoid confusion...]

  8. dplyr::tibble(...)
  9. tibble:::tibble_quos(xs, .rows, .name_repair)
 10. tibble:::vectbl_recycle_rows(res, first_size, j, given_col_names[[j]])

If I have multiple attributes defined for a level I cannot insert them individually, so there seem to be checks in place Error: Error in item 0000:msajc003:Intsint:1. The provided attributes (Intsint) do not match the attributes required (Intsint, Momel, IntsintMomel) for the level (Intsint).

indicating that the case of multiple attributes has been considered also in the code. Inserting labels into a level with just a single attribute defined works fine.

Looking at the code I also see checks that I think make little sense:

https://github.com/IPS-LMU/emuR/blob/e1c0bc1b6ab2dd9d030bedd793084ff7e05d0fa3/R/emuR-annotations_crud.R#L78-L81

I dont see why the function should check if the number of levels is> 0 again here. It is not just a simple error of variable checked since the number of unique attributes should actually be more than one if required by the attribute definition.