partition() re-classifies a .txt file as CSV or JSON from its content
メンテナーはふだん 6 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 78/100
調査の方向性
unstructured/file_utils/filetype.py、特に _TextFileDifferentiator.file_type を読み、.txt ファイルに対して partition() が detect_filetype() をどのように使うかを追ってください。.txt ファイル内のカンマ区切りコンテンツと JSON コンテンツに関するテストを追加または確認し、そのうえで、名前のあるテキストファイルは引き続きプレーンテキストとして処理され、拡張子のないファイルは引き続きコンテンツに基づいて判定されることを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Describe the bug
partition() and detect_filetype() re-classify a file named *.txt from its content. A plain text file whose lines all contain the same number of commas is detected as CSV, so the commas are dropped and the lines are fused into a single Table.
notes.txt: "Dear Ann,\nThank you for the gift,\nSee you soon,\n"
names.txt: "Smith, John\nDoe, Jane\nRoe, Richard\n"
from unstructured.partition.auto import partition
partition("names.txt")
# [('Table', 'Smith John Doe Jane Roe Richard')] metadata.filetype == "text/csv"
partition("notes.txt")
# [('Table', 'Dear Ann Thank you for the gift See you soon')]
partition_text("names.txt") gives three Title elements, so only the type detection is affected. A .txt file that contains a JSON object is likewise routed to the JSON partitioner and its text is rewritten.
Cause
In _TextFileDifferentiator.file_type (unstructured/file_utils/filetype.py), .csv, .json, .md, .eml, ... are trusted by extension first, but the .txt/.text check comes after _is_json, _is_csv and _is_eml.
Expected
A file the user named .txt is plain text. The content sniffs stay for files without an extension.
Proposed fix
Return FileType.TXT for .txt/.text before the content sniffs. I have a small PR with tests ready; happy to adjust if you want to keep the sniffing for some case I missed.
Version: main at d9c80bdb, Python 3.12, Windows 11.
- 主要言語
- HTML
- スター
- 15.8k
- フォーク
- 1.4k
- 平均マージ
- 8日 4時間
- マージ済み PR(30日)
- 40
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Unstructured-IO/unstructured のほかの issue
-
bug: partition_email() raises io.UnsupportedOperation on a file-like object that cannot seek対応中かも @Bensonluo が 5 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Unstructured-IO/unstructured#4864 ·
メンテナーはふだん 6 日以内に返信
-
fix(nlp): match single-letter bullets in the enumerated bullet pattern対応中かも @Eapp1e が 33 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Unstructured-IO/unstructured#4635 ·
メンテナーはふだん 6 日以内に返信
-
bug(cleaners): translate_text passes text instead of chunk in attention window loop対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
Unstructured-IO/unstructured#4558 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
-
extract_text_before/extract_text_after raise UnboundLocalError when the pattern is absent対応中かも @ayam04 が 103 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Unstructured-IO/unstructured#4427 · コメント 3 件 ·
メンテナーはふだん 6 日以内に返信
-
Large HTML documents cannot be partitioned using the partition_html function.対応中かも @CrepuscularIRIS が 229 日前に担当しました。 オープンbug
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
Unstructured-IO/unstructured#4289 · コメント 1 件 ·
メンテナーはふだん 6 日以内に返信
Unstructured-IO/unstructured の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
TigreGotico/orthography2ipa#2950 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
🐛 bug 👩💻 équipe CE
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
betagouv/conseillers-entreprises#4835 ·
メンテナーはふだん 1 日以内に返信
-
area: integrations documentation priority: P2 size: XS
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
eddiejaoude/StackDash#798 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ThinkR-open/mordew#88 ·