[docs]def__init__(self,file_path:Union[str,Path]):"""Initialize with a file path."""self.file_path=file_path
[docs]defload(self)->List[Document]:"""Load from a file path."""withopen(self.file_path,encoding="utf8")asf:tsv=list(csv.reader(f,delimiter="\t"))# If len(line) > 1, the line is not a commentlines=[lineforlineintsviflen(line)>1]text=""fori,lineinenumerate(lines):# Do not add a space after a punctuation mark or at the end of the sentenceifline[9]=="SpaceAfter=No"ori==len(lines)-1:text+=line[1]else:text+=line[1]+" "metadata={"source":str(self.file_path)}return[Document(page_content=text,metadata=metadata)]