Exemplo n.º 1
0
 def test_clear(self):
     xc = XigtCorpus()
     xc.extend([Igt(id='i1'), Igt(id='i2'), Igt(id='i3')])
     self.assertEqual(len(xc), 3)
     xc.clear()
     self.assertEqual(len(xc), 0)
     self.assertIs(xc.get(0), None)
     self.assertIs(xc.get('i1'), None)
Exemplo n.º 2
0
 def test_clear(self):
     xc = XigtCorpus()
     xc.extend([Igt(id='i1'), Igt(id='i2'), Igt(id='i3')])
     assert len(xc) == 3
     xc.clear()
     assert len(xc) == 0
     assert xc.get(0) is None
     assert xc.get('i1') is None
Exemplo n.º 3
0
def write(out_fn, fn_idx):
    xc = XigtCorpus()
    for fn, igt_indices in fn_idx.items():
        # if possible, try to decode needed igts only and skip the rest
        in_xc = xigtxml.load(fn, mode='transient')
        # ignoring corpus-level metadata
        xc.extend(igt for i, igt in enumerate(in_xc) if i in igt_indices)
    # assume the nsmap of the first igt is the same for all
    if xc.igts: xc.nsmap = xc[0].nsmap
    xigtxml.dump(out_fn, xc)
Exemplo n.º 4
0
 def test_extend(self):
     xc = XigtCorpus()
     self.assertEqual(len(xc), 0)
     xc.extend([Igt(id='i1')])
     self.assertEqual(len(xc), 1)
     xc.extend([])
     self.assertEqual(len(xc), 1)
     xc.extend([Igt(id='i2'), Igt(id='i3')])
     self.assertEqual(len(xc), 3)
     self.assertEqual(xc[0].id, 'i1')
     self.assertEqual(xc[1].id, 'i2')
     self.assertEqual(xc[2].id, 'i3')
Exemplo n.º 5
0
 def test_extend(self):
     xc = XigtCorpus()
     assert len(xc) == 0
     xc.extend([Igt(id='i1')])
     assert len(xc) == 1
     xc.extend([])
     assert len(xc) == 1
     xc.extend([Igt(id='i2'), Igt(id='i3')])
     assert len(xc) == 3
     assert xc[0].id == 'i1'
     assert xc[1].id == 'i2'
     assert xc[2].id == 'i3'