-
Notifications
You must be signed in to change notification settings - Fork 743
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add encoding param to ingest (#955)
* Add encoding param to ingest
- Loading branch information
Jason Scheirer
authored
Jul 24, 2023
1 parent
676c50a
commit 196efa0
Showing
8 changed files
with
234 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<body> | ||
|
||
<h1>My First Heading</h1> | ||
<p>My first paragraph.</p> | ||
<p>Some CP1252-specific characters:</p> | ||
|
||
<pre> | ||
¡ ¢ £ ¤ ¥ ¦ § ¨ © ª « ¬ SHY ® ¯ | ||
° ± ² ³ ´ µ ¶ · ¸ ¹ º » ¼ ½ ¾ ¿ | ||
À Á Â Ã Ä Å Æ Ç È É Ê Ë Ì Í Î Ï | ||
Ð Ñ Ò Ó Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß | ||
à á â ã ä å æ ç è é ê ë ì í î ï | ||
ð ñ ò ó ô õ ö ÷ ø ù ú û ü ý þ ÿ | ||
</pre> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...est/expected-structured-output/local-single-file-with-encoding/fake-html-cp1252.html.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
[ | ||
{ | ||
"type": "Title", | ||
"element_id": "0540311f6c077fe8f797080918b8d74b", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 1 | ||
}, | ||
"text": "My First Heading" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "399af454cb1368b8257ed406b430de84", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 1 | ||
}, | ||
"text": "My first paragraph." | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "b4cf0d13edfa976816649971bd640a66", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 1 | ||
}, | ||
"text": "Some CP1252-specific characters:" | ||
}, | ||
{ | ||
"type": "UncategorizedText", | ||
"element_id": "ada7c3084f437d31d297f85da3941a55", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 2 | ||
}, | ||
"text": "¡\t¢\t£\t¤\t¥\t¦\t§\t¨\t©\tª\t«\t¬\tSHY\t®\t¯" | ||
}, | ||
{ | ||
"type": "UncategorizedText", | ||
"element_id": "dda5e8c4d245c1954ecb64e5dfea598d", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 3 | ||
}, | ||
"text": "°\t±\t²\t³\t´\tµ\t¶\t·\t¸\t¹\tº\t»\t¼\t½\t¾\t¿" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "85df09b375e5813aefa3b5f30c8ddff8", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 4 | ||
}, | ||
"text": "À\tÁ\tÂ\tÃ\tÄ\tÅ\tÆ\tÇ\tÈ\tÉ\tÊ\tË\tÌ\tÍ\tÎ\tÏ" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "2726d2569cd7a6cecb79a6e46bb0b2b3", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 5 | ||
}, | ||
"text": "Ð\tÑ\tÒ\tÓ\tÔ\tÕ\tÖ\t×\tØ\tÙ\tÚ\tÛ\tÜ\tÝ\tÞ\tß" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "2b01f3e428520f6e47d8513292688cf6", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 6 | ||
}, | ||
"text": "à\tá\tâ\tã\tä\tå\tæ\tç\tè\té\tê\të\tì\tí\tî\tï" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "5ed256e41bfb169af5f50524b9593a16", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 7 | ||
}, | ||
"text": "ð\tñ\tò\tó\tô\tõ\tö\t÷\tø\tù\tú\tû\tü\tý\tþ\tÿ" | ||
} | ||
] |
92 changes: 92 additions & 0 deletions
92
...tured_ingest/structured-output/local-single-file-with-encoding/fake-html-cp1252.html.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
[ | ||
{ | ||
"type": "Title", | ||
"element_id": "0540311f6c077fe8f797080918b8d74b", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 1 | ||
}, | ||
"text": "My First Heading" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "399af454cb1368b8257ed406b430de84", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 1 | ||
}, | ||
"text": "My first paragraph." | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "b4cf0d13edfa976816649971bd640a66", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 1 | ||
}, | ||
"text": "Some CP1252-specific characters:" | ||
}, | ||
{ | ||
"type": "UncategorizedText", | ||
"element_id": "ada7c3084f437d31d297f85da3941a55", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 2 | ||
}, | ||
"text": "¡\t¢\t£\t¤\t¥\t¦\t§\t¨\t©\tª\t«\t¬\tSHY\t®\t¯" | ||
}, | ||
{ | ||
"type": "UncategorizedText", | ||
"element_id": "dda5e8c4d245c1954ecb64e5dfea598d", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 3 | ||
}, | ||
"text": "°\t±\t²\t³\t´\tµ\t¶\t·\t¸\t¹\tº\t»\t¼\t½\t¾\t¿" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "85df09b375e5813aefa3b5f30c8ddff8", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 4 | ||
}, | ||
"text": "À\tÁ\tÂ\tÃ\tÄ\tÅ\tÆ\tÇ\tÈ\tÉ\tÊ\tË\tÌ\tÍ\tÎ\tÏ" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "2726d2569cd7a6cecb79a6e46bb0b2b3", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 5 | ||
}, | ||
"text": "Ð\tÑ\tÒ\tÓ\tÔ\tÕ\tÖ\t×\tØ\tÙ\tÚ\tÛ\tÜ\tÝ\tÞ\tß" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "2b01f3e428520f6e47d8513292688cf6", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 6 | ||
}, | ||
"text": "à\tá\tâ\tã\tä\tå\tæ\tç\tè\té\tê\të\tì\tí\tî\tï" | ||
}, | ||
{ | ||
"type": "Title", | ||
"element_id": "5ed256e41bfb169af5f50524b9593a16", | ||
"metadata": { | ||
"data_source": {}, | ||
"filetype": "text/html", | ||
"page_number": 7 | ||
}, | ||
"text": "ð\tñ\tò\tó\tô\tõ\tö\t÷\tø\tù\tú\tû\tü\tý\tþ\tÿ" | ||
} | ||
] |
20 changes: 20 additions & 0 deletions
20
test_unstructured_ingest/test-ingest-local-single-file-with-encoding.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SCRIPT_DIR=$(dirname "$(realpath "$0")") | ||
cd "$SCRIPT_DIR"/.. || exit 1 | ||
OUTPUT_FOLDER_NAME=local-single-file-with-encoding | ||
OUTPUT_DIR=$SCRIPT_DIR/structured-output/$OUTPUT_FOLDER_NAME | ||
|
||
PYTHONPATH=. ./unstructured/ingest/main.py \ | ||
--metadata-exclude filename,file_directory,metadata.data_source.date_processed \ | ||
--local-input-path example-docs/fake-html-cp1252.html \ | ||
--structured-output-dir "$OUTPUT_DIR" \ | ||
--encoding cp1252 \ | ||
--verbose \ | ||
--reprocess | ||
|
||
set +e | ||
|
||
sh "$SCRIPT_DIR"/check-diff-expected-output.sh $OUTPUT_FOLDER_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters