"""Builds corpus based on the alignment.""" import polars as pl with open("raw/europarl-v7.da-en.da") as in_file: danish_texts = pl.Series(list(in_file)) with open("raw/europarl-v7.da-en.en") as in_file: english_texts = pl.Series(list(in_file)) with open("raw/europarl-v7.sv-en.sv") as in_file: swedish_texts = pl.Series(list(in_file)) alignment = pl.read_parquet("filtered_alignment.parquet") corpus = pl.DataFrame( dict( da=danish_texts.take(alignment["da_id"]), en=english_texts.take(alignment["da_id"]), sv=swedish_texts.take(alignment["sv_id"]), ) ) corpus.write_parquet("corpus.parquet")