code: def iter_alignments(dataset, cognate_sets, column='Segments', method='library'):
      
      if not isinstance(dataset, lingpy.basic.parser.QLCParser):
          wordlist = _cldf2wordlist(dataset)
          cognates = {r['Form_ID']: r for r in cognate_sets}
          wordlist.add_entries(
              'cogid',
              'lid',
              lambda x: cognates[x]['Cognateset_ID'] if x in cognates else 0)
          alm = lingpy.Alignments(
              wordlist,
              ref='cogid',
              row='parameter_id',
              col='language_id',
              segments=column.lower())
          alm.align(method=method)
          for k in alm:
              if alm[k, 'lid'] in cognates:
                  cognate = cognates[alm[k, 'lid']]
                  cognate['Alignment'] = alm[k, 'alignment']
                  cognate['Alignment_Method'] = method
      else:
          alm = lingpy.Alignments(dataset, ref='cogid')
          alm.align(method=method)
  
          for cognate in cognate_sets:
              idx = cognate['ID'] or cognate['Form_ID']
              cognate['Alignment'] = alm[int(idx), 'alignment']
              cognate['Alignment_Method'] = 'SCA-' + method
docs: Function computes automatic alignments and writes them to file.