marl / jams

A JSON Annotated Music Specification for Reproducible MIR Research
ISC License
185 stars 26 forks source link

load jams mapping error? #196

Closed irisyupingren closed 5 years ago

irisyupingren commented 5 years ago

setup: Python 3.6.6 (default, Sep 12 2018, 18:26:19) Type 'copyright', 'credits' or 'license' for more information IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.

command: jam = jams.load("1.jams")

error:

~/.local/lib/python3.6/site-packages/jams/core.py in load(path_or_file, validate, strict, fmt)
    211 
    212     with _open(path_or_file, mode='r', fmt=fmt) as fdesc:
--> 213         jam = JAMS(**json.load(fdesc))
    214 
    215     if validate:

~/.local/lib/python3.6/site-packages/jams/core.py in __init__(self, annotations, file_metadata, sandbox)
   1657             sandbox = Sandbox()
   1658 
-> 1659         self.annotations = AnnotationArray(annotations=annotations)
   1660 
   1661         self.file_metadata = FileMetadata(**file_metadata)

~/.local/lib/python3.6/site-packages/jams/core.py in __init__(self, annotations)
   1500             annotations = list()
   1501 
-> 1502         self.extend([Annotation(**obj) for obj in annotations])
   1503 
   1504     def search(self, **kwargs):

~/.local/lib/python3.6/site-packages/jams/core.py in <listcomp>(.0)
   1500             annotations = list()
   1501 
-> 1502         self.extend([Annotation(**obj) for obj in annotations])
   1503 
   1504     def search(self, **kwargs):

~/.local/lib/python3.6/site-packages/jams/core.py in __init__(self, namespace, data, annotation_metadata, sandbox, time, duration)
    645             annotation_metadata = AnnotationMetadata()
    646 
--> 647         self.annotation_metadata = AnnotationMetadata(**annotation_metadata)
    648 
    649         self.namespace = namespace

~/.local/lib/python3.6/site-packages/jams/core.py in __init__(self, curator, version, corpus, annotator, annotation_tools, annotation_rules, validation, data_source)
   1381             annotator = JObject()
   1382 
-> 1383         self.curator = Curator(**curator)
   1384         self.annotator = JObject(**annotator)
   1385 

TypeError: type object argument after ** must be a mapping, not str
justinsalamon commented 5 years ago

Which version of jams are you using, and do you know which version of jams was used to create the file you're trying to load? Can you post a link to the jams file?

irisyupingren commented 5 years ago

pip3 freeze | grep jams jams==0.3.2

And the files are here: https://github.com/irisyupingren/HEMANanalysis/tree/master/data_jams

Thanks for looking into it :)

bmcfee commented 5 years ago

The problem here is that your curator fields do not conform to the schema. Curator fields are structured (name and email), not plain strings.

I think JAMS should not have let you save these files without a warning / error to that effect -- did that happen, or did you write these by hand using json?

irisyupingren commented 5 years ago

Oh thanks! I used this script for parsing to jams https://github.com/urinieto/jams-data/blob/master/parsers/heman_parser.py Will do a pull request there :D

urinieto commented 5 years ago

I'm late to the party, but I'll take the mea culpa for having written that Heman script. Apologies!