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

autobuild_linkFromTimes() succeeds on error when level is of type ITEM #226

Closed kirbyj closed 3 years ago

kirbyj commented 4 years ago
library(emuR)
create_emuRdemoData(dir = tempdir())
path2directory = file.path(tempdir(), 
                           "emuR_demoData", 
                           "ae_emuDB")
ae = load_emuDB(path2directory)

> add_levelDefinition(ae, "MAS", type = "SEGMENT")
  INFO: Rewriting 7 _annot.json files to file system...

> autobuild_linkFromTimes(ae,
+                         superlevelName = "Word",
+                         sublevelName = "MAS",
+                         convertSuperlevel = FALSE,
+                         newLinkDefType = "ONE_TO_MANY") 
Error in autobuild_linkFromTimes(ae, superlevelName = "Word", sublevelName = "MAS",  : 
  The super level type and sub level type can not be of type 'ITEM'. The super level type is: 'ITEM' and the sub level type is 'SEGMENT'.

However, the link seems to be added anyways?

> list_linkDefinitions(ae)
           type superlevelName sublevelName
1   ONE_TO_MANY      Utterance Intonational
2   ONE_TO_MANY   Intonational Intermediate
3   ONE_TO_MANY   Intermediate         Word
4   ONE_TO_MANY           Word     Syllable
5   ONE_TO_MANY       Syllable      Phoneme
6  MANY_TO_MANY        Phoneme     Phonetic
7   ONE_TO_MANY       Syllable         Tone
8   ONE_TO_MANY   Intonational         Foot
9   ONE_TO_MANY           Foot     Syllable
10  ONE_TO_MANY           Word          MAS
raphywink commented 4 years ago

Yes this is sort of intentional. The newLinkDefType parameter is basically just a short hand for:

add_linkDefinition(ae, 
                   type = "ONE_TO_MANY", 
                   superlevelName = "Word",
                   sublevelName = "MAS")
autobuild_linkFromTimes(ae,
                        superlevelName = "Word",
                        sublevelName = "MAS",
                        convertSuperlevel = FALSE,
                        newLinkDefType = "ONE_TO_MANY") 

right at the start of the function it calls the add_linkDef. function. If it then fails the original add_linkDef. call isn't undone... could think of try-catching it. Will have to think about it some more...