def main():
    tot_morph_count = 0
    tot_length = 0

    for line in fileinput.input():
        word, segm = line.strip().split(None, 1)
        segmentations = segm.split(',')
        num_morphs = [len([x for x in s.split(None) if x.strip().strip("~") != ""]) for s in segmentations]

        tot_morph_count += sum(num_morphs) - len(num_morphs)
        tot_length += len(word)

    print(tot_length / tot_morph_count)
dataset/ETHPy150Open aalto-speech/morfessor/scripts/tools/morphlength_from_annotations.py/main/operator `/` -> `-`