Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add markdowns per pages #792

Merged
merged 8 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ coverage:

.PHONY: test
test:
# Ideally, it should be ok to run without installing tparse locally.
# However, there may be some issues that arise from running the tests
# in the container. If you encounter any issues, please install tparse
# locally via `go install github.com/mfridman/tparse/cmd/tparse@latest`
# and run the tests locally.
@if [ "${OCR}" = "true" ]; then \
docker run --rm \
-v $(PWD):/${SERVICE_NAME} \
Expand Down
1 change: 1 addition & 0 deletions pkg/component/operator/document/v0/README.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Convert document to text in Markdown format.
| Images (optional) | `images` | array[string] | Images extracted from the document |
| Error (optional) | `error` | string | Error message if any during the conversion process |
| All Page Images (optional) | `all-page-images` | array[string] | The image contains all the pages in the document if we detect there could be images in the page. It will only support DOCX/DOC/PPTX/PPT/PDF. |
| Markdowns (optional) | `markdowns` | array[string] | Markdown text converted from the PDF document, separated by page. |
</div>

### Convert to Text
Expand Down
10 changes: 10 additions & 0 deletions pkg/component/operator/document/v0/config/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,16 @@
},
"title": "All Page Images",
"type": "array"
},
"markdowns": {
"description": "Markdown text converted from the PDF document, separated by page.",
"instillFormat": "array:string",
"instillUIOrder": 5,
"items": {
"type": "string"
},
"title": "Markdowns",
"type": "array"
}
},
"required": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ func (e *execution) convertDocumentToMarkdown(ctx context.Context, job *base.Job
}
return images
}(),
Markdowns: transformerOutputStruct.Markdowns,
}

err = job.Output.WriteData(ctx, outputStruct)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestConvertDocumentToMarkdown(t *testing.T) {
Body: "# This is test file for markdown\n",
Images: []format.Image{},
AllPageImages: []format.Image{},
Markdowns: []string{"# This is test file for markdown\n"},
},
},
{
Expand All @@ -39,6 +40,7 @@ func TestConvertDocumentToMarkdown(t *testing.T) {
Body: "# This is test file for markdown\n",
Images: []format.Image{},
AllPageImages: []format.Image{},
Markdowns: []string{"# This is test file for markdown\n"},
},
},
{
Expand All @@ -57,6 +59,7 @@ func TestConvertDocumentToMarkdown(t *testing.T) {
Body: "# This is test file for markdown\n",
Images: []format.Image{},
AllPageImages: []format.Image{},
Markdowns: []string{"# This is test file for markdown\n"},
},
},
{
Expand Down
23 changes: 0 additions & 23 deletions pkg/component/operator/document/v0/execution/pdf_checker.py

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 1 addition & 0 deletions pkg/component/operator/document/v0/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ConvertDocumentToMarkdownOutput struct {
Images []format.Image `instill:"images"`
Error string `instill:"error"`
AllPageImages []format.Image `instill:"all-page-images"`
Markdowns []string `instill:"markdowns"`
}

type ConvertDocumentToImagesInput struct {
Expand Down

This file was deleted.

Loading
Loading