read_api.rst 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. read_api
  2. =========
  3. 从文件或目录读取内容以创建 Dataset。目前,我们提供了几个覆盖某些场景的函数。如果你有新的、大多数用户都会遇到的场景,可以在官方 GitHub 问题页面上发布详细描述。同时,实现你自己的读取相关函数也非常容易。
  4. 重要函数
  5. ---------
  6. read_jsonl
  7. ^^^^^^^^^^^^^^^^
  8. 从本地机器或远程 S3 上的 JSONL 文件读取内容。如果你想了解更多关于 JSONL 的信息,请参阅 :doc:`../../additional_notes/glossary`。
  9. .. code:: python
  10. # 从本地机器读取 JSONL
  11. datasets = read_jsonl("tt.jsonl", None)
  12. # 从远程 S3 读取 JSONL
  13. datasets = read_jsonl("s3://bucket_1/tt.jsonl", s3_reader)
  14. read_local_pdfs
  15. ^^^^^^^^^^^^^^^^
  16. 从路径或目录读取 PDF 文件。
  17. .. code:: python
  18. # 读取 PDF 路径
  19. datasets = read_local_pdfs("tt.pdf")
  20. # 读取目录下的 PDF 文件
  21. datasets = read_local_pdfs("pdfs/")
  22. read_local_images
  23. ^^^^^^^^^^^^^^^^^^^
  24. 从路径或目录读取图像。
  25. .. code:: python
  26. # 从图像路径读取
  27. datasets = read_local_images("tt.png")
  28. # 从目录读取以 suffixes 数组中指定后缀结尾的文件
  29. datasets = read_local_images("images/", suffixes=["png", "jpg"])