-
Notifications
You must be signed in to change notification settings - Fork 33
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
Add PDF worker support #1071
base: master
Are you sure you want to change the base?
Add PDF worker support #1071
Conversation
0a6f159
to
64b65a1
Compare
@michalrentka @dstillman this is ready for a first review / user testing. I did a very simple UI iteration, where items that are retrieving metadata, are indicating this by an animating subtitle, as it is empty for attachment type. If functionality is as desired, we can improve the UI as we see fit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't go through everything yet, but there will probably be bigger changes, so I'll have to go through most of it again anyway.
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
Zotero/Controllers/Web View Handling/PDFWorkerWebViewHandler.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to submit now. Although ideally I'd like to see some changes in RecognizerController
, but they would require some further refactoring which might be unnecessary time kill at this point.
Anyway if I understand RecognizerController
correctly, the order of events there is one big chain, which could be summed up as: enqueue pdf worker
-> start remote recognition
-> lookup identifiers
-> process identified items
(create new items).
So theoretically it could be simply written as something like:
pdfWorkerController.queue(work: PDFWorkerController.PDFWork(file: task.file, kind: .recognizer))
.filter({
// filter out in-progress states
})
.flatMap({
// Report errors if failed/cancelled, continue with extracted data
})
.flatMap({
return apiClient.send(request: RecognizerRequest(parameters: data))
})
.flatMap({
// extract identifiers
})
.flatMap({
// This would require a new controller which would loop through all identifiers and report when they are all finished
// It could be `Observable` and report multiple `onNext` events so that each event is handled separately if needed, but I guess it would be even better to gather all data first and then have one database write with multiple items
identifierController.lookupIdentifiers()
})
.subscribe(
// Process lookup results - create/report items
// Report errors
)
.disposed(by: disposeBag)
It would be neater and much easier to understand quickly what's going on. Of course there would probably have to be some more filter
s/flatMap
s for special cases, but I think it would still be even less verbose than it is currently, where you have to subscribe to and process each individual step.
Anyway this is not required at this point, just a thought for the future.
Add PDFWorkerController Add support for PDF worker
PDFWorkerWebViewHandler
.PDFWorkerController
that exposes PDF worker for extracting recognizer data and full text.RecognizerController
that extracts recognizer data, performs remote recognizer request, and finally performs identifier lookup to produce an item response, for selected local PDF file. (Logic for remote recognizer response processing is coped from https://github.com/zotero/zotero/blob/7b7a0b9e4692a0ca32984b763f67b7b10edf96fd/chrome/content/zotero/xpcom/recognizeDocument.js#L411)RecognizerController
in share extension, to create parent item for a shared local PDF file.TODO:
Retrieve Metadata
action for standalone attachments.To be considered: