Exemplo n.º 1
0
def getWrongTiers(source):
    """Takes list of TextGrids, returns text file list of tiers in each"""
    for line in source.readlines():
        f = line.rstrip('\n')
        tg = TextGridFromFile(f)
        tiers = tg.getNames()
        print tiers
Exemplo n.º 2
0
def getWrongTiers(source):
    """Takes list of TextGrids, returns text file list of tiers in each"""
    for line in source.readlines():
        f = line.rstrip('\n')
        tg = TextGridFromFile(f)
        tiers = tg.getNames()
        print tiers
Exemplo n.º 3
0
def fixTiers(source, tierlist, outfile):
    """Takes list of TextGrids, file with new tier orders, list of output file
    names, returns TextGrids with new tier order"""
    for line, tier, out in zip(source.readlines(), tierlist, outfile.readlines()):
            f = line.rstrip('\n')
            oldtg = TextGridFromFile(f)
            list_from_file = eval(tier)
            output = out.rstrip('\n')
            newtg = TextGrid('newtg')
            for n in list_from_file:
                ntier = oldtg.getFirst(n)
                newtg.append(ntier) 
            newtg.write(output)
Exemplo n.º 4
0
def fixTiers(source, tierlist, outfile):
    """Takes list of TextGrids, file with new tier orders, list of output file
    names, returns TextGrids with new tier order"""
    for line, tier, out in zip(source.readlines(), tierlist,
                               outfile.readlines()):
        f = line.rstrip('\n')
        oldtg = TextGridFromFile(f)
        list_from_file = eval(tier)
        output = out.rstrip('\n')
        newtg = TextGrid('newtg')
        for n in list_from_file:
            ntier = oldtg.getFirst(n)
            newtg.append(ntier)
        newtg.write(output)
Exemplo n.º 5
0
 if len(args) != 2:
     print >> stderr, USAGE
     exit("Not enough TextGrids provided")
 try:
     for (opt, val) in opts:
         if opt == '-s':
             close_enough = int(val) / 1000
         elif opt == '-t':
             tier_name = val
         else:
             raise GetoptError
 except (TypeError, GetoptError) as err:
     print >> stderr, USAGE
     exit(str(err))
 # get boundaries
 first = boundaries(TextGridFromFile(args[0]), tier_name)
 secnd = boundaries(TextGridFromFile(args[1]), tier_name)
 # count
 if len(first) != len(secnd):
     exit("Tiers lengths do not match.")
 concordant = 0
 discordant = 0
 for (boundary1, boundary2) in zip(first, secnd):
     if boundary1.transition != boundary2.transition:
         exit("Tier labels do not match.")
     if is_close_enough(boundary1.time, boundary2.time, close_enough):
         concordant += 1
     else:
         discordant += 1
 # print out
 agreement = concordant / (concordant + discordant)