def describe(f, glottolog): audio = get_audio(f.data.get('Audio')) return { "FullLanguage": f.language, "Language": remove_accents(f.language), "Label": safe_name(remove_accents(f.language)), "Family": remove_accents(glottolog.get(f.language)), "InventoryLength": '%d' % len(f.inventory), "Tokens": '%d' % len(f.tokens), "TranscriptLength": '%d' % len(f.transcript), "AudioLength": 'NA' if audio is None else '%d' % audio, "Unobserved": '%d' % len(f.unobserved), "Errors": '%d' % len(f.errors), "DistinctErrors": '%d' % len(set(f.errors)), }
def test_invalid(self): with self.assertRaises(ValueError): assert get_audio(['1.a'])
def test_time_float(self): assert get_audio(["11.1"]) == 11.1
def test_time(self): assert get_audio(["111"]) == 111
def test_NA(self): assert get_audio(["NA"]) == None
def test_nothing(self): assert get_audio([]) == None assert get_audio(['', '']) == None assert get_audio(None) == None