-
Notifications
You must be signed in to change notification settings - Fork 200
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
fix(predictions): TABLE, CELL & KEY_VALUE_SET blocks are not properly processed #660
Conversation
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...Plugins/Predictions/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift
Outdated
Show resolved
Hide resolved
...Plugins/Predictions/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.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.
Please rename the file testImageTextAll.jpg
to employmentapp.jpg
. textAll
is ambiguous -- for example, the image does not have a celebrity, and does not address all cases that we currently support.
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
...yPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyTextResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
AmplifyPlugins/Predictions/AWSPredictionsPlugin/Support/Utils/IdentifyResultTransformers.swift
Outdated
Show resolved
Hide resolved
] | ||
] | ||
) | ||
Amplify.reset() |
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 don't think you understood my comment -I noticed that there is a call to Amplify.reset()
in the two functions:
setUp()
and tearDown()
-- I do not think it should be in both places. I think it makes sense to have it only in tearDown()
// Set up Amplify predictions configuration | ||
let predictionsConfig = PredictionsCategoryConfiguration( | ||
plugins: [ | ||
"awsPredictionsPlugin": [ | ||
"defaultRegion": region, | ||
"identify": [ | ||
"identifyEntities": [ | ||
"maxFaces": 50, | ||
"collectionId": "", //no collectionid | ||
"region": region | ||
] | ||
], | ||
"convert": [ | ||
"transcription": [ | ||
"language": "en", | ||
"region": region, | ||
"defaultNetworkPolicy": "auto" | ||
] | ||
] | ||
] | ||
] | ||
) | ||
Amplify.reset() | ||
|
||
let amplifyConfig = AmplifyConfiguration(predictions: predictionsConfig) |
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.
It looks like we were configuring our integration tests through code (versus a file)... Was there a discussion among the team that we want to adopt this approach? Was there a problem with the approach we had before?
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.
According to Jithin, there is no specific reason why not using one over the other. Since the other categories use file way of configuring, then I would also adopt that way and it's more convenient.
...Plugins/Predictions/AWSPredictionsPluginIntegrationTests/IdentifyBasicIntegrationTests.swift
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.
Please fix the code with regards to removing the processSelectionElement
function. After that, feel free to adopt additional comments, or just push.
Also, you will want to update the Changelog
.
@@ -47,7 +47,6 @@ class IdentifyResultTransformers { | |||
points.append(point) | |||
} | |||
return Polygon(points: points) | |||
|
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.
You can revert changes in this file.
static func processSelectionElement(_ selectionItemFoundOld: Bool, | ||
selectionStatus: AWSTextractSelectionStatus) -> (Bool, Bool) { | ||
var selectionItemFound = selectionItemFoundOld | ||
var isSelected = false | ||
if !selectionItemFound { | ||
selectionItemFound = true | ||
//TODO: Support multiple selection items found in a single cell | ||
isSelected = selectionStatus == .selected | ||
} else { | ||
Amplify.log.error("Multiple selection items found in single cell") | ||
} | ||
return (isSelected, selectionItemFound) | ||
} |
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 understand trying to re-use code here, but in this case, I think it actually adds complexity. Lets remove this function.
let result = processSelectionElement(selectionItemFound, selectionStatus: selectionStatus) | ||
isSelected = result.0 | ||
selectionItemFound = result.1 |
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.
Replace with:
if (!selectionItemFound) {
selectionItemFound = true
//TODO: http://www.github.com/aws-amplify/amplify-ios/issues/<fill in issue number here>
// Support multiple selection items found in a KeyValueSet
isSelected = selectionStatus == .selected
} else {
Amplify.log.error("Multiple selection items found in KeyValueSet")
}
let result = processSelectionElement(selectionItemFound, selectionStatus: selectionStatus) | ||
isSelected = result.0 | ||
selectionItemFound = result.1 |
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.
replace with:
if (!selectionItemFound) {
selectionItemFound = true
//TODO: <link>
//Support multiple selection items found in a cell
isSelected = selectionStatus == .selected
} else {
Amplify.log.error("Multiple selection items found in a Cell")
}
@@ -10,6 +10,7 @@ import AWSRekognition | |||
import Amplify | |||
import AWSTextract | |||
|
|||
// swiftlint:disable type_body_length |
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.
If you want to avoid this, you can create a file like:
IdentifyTextResultTransformers+Tables.swift
(and similarly with key value)
and then put:
extension IdentifyTextResultTransformers {
static func processTables(...
static func processTable(_ tableBlock: AWSText...
static func constructTableCell(_....
}
…ultTransformers.swift
Description of changes:
Bug fix according to: #641
Refactored
processText(_ textractTextBlocks: [AWSTextractBlock])
Fixed the bug where
TABLE
,CELL
blocks are not properly processedFixed the bug where
KEY_VALUE_SET
blocks are not properly processedUpdated integration tests
Update
README.md
Replaced
AWSMobileClient
withAmplify.Auth
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.