-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support encoding and decoding JSONL datasets (#176)
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
11 changed files
with
285 additions
and
27 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
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
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
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,45 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/document.jsonl" | ||
{ "count": 1 } | ||
{ "count": 2 } | ||
{ "count": 3 } | ||
{ "count": 4 } | ||
{ "count": 5 } | ||
EOF | ||
|
||
"$1" encode "$TMP/document.jsonl" "$TMP/output.binpack" | ||
"$1" decode "$TMP/output.binpack" "$TMP/result.jsonl" > "$TMP/output.txt" 2>&1 | ||
|
||
cat "$TMP/result.jsonl" | ||
|
||
cat << EOF > "$TMP/expected.jsonl" | ||
{ | ||
"count": 1 | ||
} | ||
{ | ||
"count": 2 | ||
} | ||
{ | ||
"count": 3 | ||
} | ||
{ | ||
"count": 4 | ||
} | ||
{ | ||
"count": 5 | ||
} | ||
EOF | ||
|
||
cat << EOF > "$TMP/expected-output.txt" | ||
EOF | ||
|
||
diff "$TMP/expected.jsonl" "$TMP/result.jsonl" | ||
diff "$TMP/output.txt" "$TMP/expected-output.txt" |
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,51 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/document.jsonl" | ||
{ "count": 1 } | ||
{ "count": 2 } | ||
{ "count": 3 } | ||
{ "count": 4 } | ||
{ "count": 5 } | ||
EOF | ||
|
||
"$1" encode "$TMP/document.jsonl" "$TMP/output.binpack" | ||
"$1" decode "$TMP/output.binpack" "$TMP/result.jsonl" --verbose > "$TMP/output.txt" 2>&1 | ||
|
||
cat "$TMP/result.jsonl" | ||
|
||
cat << EOF > "$TMP/expected.jsonl" | ||
{ | ||
"count": 1 | ||
} | ||
{ | ||
"count": 2 | ||
} | ||
{ | ||
"count": 3 | ||
} | ||
{ | ||
"count": 4 | ||
} | ||
{ | ||
"count": 5 | ||
} | ||
EOF | ||
|
||
cat << EOF > "$TMP/expected-output.txt" | ||
Interpreting input as JSONL: $(realpath "$TMP")/output.binpack | ||
Decoding entry #0 | ||
Decoding entry #1 | ||
Decoding entry #2 | ||
Decoding entry #3 | ||
Decoding entry #4 | ||
EOF | ||
|
||
diff "$TMP/expected.jsonl" "$TMP/result.jsonl" | ||
diff "$TMP/output.txt" "$TMP/expected-output.txt" |
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,33 @@ | ||
#!/bin/sh | ||
|
||
set -o errexit | ||
set -o nounset | ||
|
||
TMP="$(mktemp -d)" | ||
clean() { rm -rf "$TMP"; } | ||
trap clean EXIT | ||
|
||
cat << 'EOF' > "$TMP/document.jsonl" | ||
{ "count": 1 } | ||
{ "count": 2 } | ||
{ "count": 3 } | ||
{ "count": 4 } | ||
{ "count": 5 } | ||
EOF | ||
|
||
"$1" encode "$TMP/document.jsonl" "$TMP/output.binpack" > "$TMP/output.txt" 2>&1 | ||
xxd "$TMP/output.binpack" > "$TMP/output.hex" | ||
|
||
cat << 'EOF' > "$TMP/expected.txt" | ||
00000000: 1306 636f 756e 7415 1300 091d 1300 0525 ..count........% | ||
00000010: 1300 052d 1300 0535 ...-...5 | ||
EOF | ||
|
||
cat << 'EOF' > "$TMP/expected-output.txt" | ||
original file size: 75 bytes | ||
encoded file size: 24 bytes | ||
compression ratio: 32% | ||
EOF | ||
|
||
diff "$TMP/expected.txt" "$TMP/output.hex" | ||
diff "$TMP/output.txt" "$TMP/expected-output.txt" |
Oops, something went wrong.