StrSplitter
- class fairseq2.data.text.StrSplitter(sep='\t', names=None, indices=None, exclude=False)[source]
Bases:
object
Split string on a given character.
- Parameters:
Example usage:
# read all columns: ["Go.", "Va !", "CC-BY 2.0 (France)"] dataloader = read_text("tatoeba.tsv").map(StrSplitter()).and_return() # keep only the second column and convert to string: "Va !" dataloader = read_text("tatoeba.tsv").map(StrSplitter(indices=[1])).map(lambda x: x[0]).and_return() # keep only the first and second column and convert to dict: {"en": "Go.", "fr": "Va !"} dataloader = read_text("tatoeba.tsv").map(StrSplitter(names=["en", "fr"], indices=[0, 1])).and_return()