-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
776b35b
commit af4e720
Showing
9 changed files
with
713 additions
and
283 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,40 @@ | ||
/** | ||
* (C) Copyright IBM Corp. 2020. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
**/ | ||
|
||
import Foundation | ||
|
||
/** | ||
An object containing the converted document and any identified enrichments. | ||
*/ | ||
public struct AnalyzedDocument: Codable, Equatable { | ||
|
||
/** | ||
Array of document results that match the query. | ||
*/ | ||
public var notices: [Notice]? | ||
|
||
/** | ||
Result of the document analysis. | ||
*/ | ||
public var result: AnalyzedResult? | ||
|
||
// Map each property name to the key that shall be used for encoding/decoding. | ||
private enum CodingKeys: String, CodingKey { | ||
case notices = "notices" | ||
case result = "result" | ||
} | ||
|
||
} |
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,53 @@ | ||
/** | ||
* (C) Copyright IBM Corp. 2020. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
**/ | ||
|
||
import Foundation | ||
import IBMSwiftSDKCore | ||
|
||
/** | ||
Result of the document analysis. | ||
*/ | ||
public struct AnalyzedResult: Codable, Equatable { | ||
|
||
/** | ||
Metadata of the document. | ||
*/ | ||
public var metadata: [String: JSON]? | ||
|
||
/// Additional properties associated with this model. | ||
public var additionalProperties: [String: JSON] | ||
|
||
// Map each property name to the key that shall be used for encoding/decoding. | ||
private enum CodingKeys: String, CodingKey { | ||
case metadata = "metadata" | ||
static let allValues = [metadata] | ||
} | ||
|
||
public init(from decoder: Decoder) throws { | ||
let container = try decoder.container(keyedBy: CodingKeys.self) | ||
metadata = try container.decodeIfPresent([String: JSON].self, forKey: .metadata) | ||
let dynamicContainer = try decoder.container(keyedBy: DynamicKeys.self) | ||
additionalProperties = try dynamicContainer.decode([String: JSON].self, excluding: CodingKeys.allValues) | ||
} | ||
|
||
public func encode(to encoder: Encoder) throws { | ||
var container = encoder.container(keyedBy: CodingKeys.self) | ||
try container.encodeIfPresent(metadata, forKey: .metadata) | ||
var dynamicContainer = encoder.container(keyedBy: DynamicKeys.self) | ||
try dynamicContainer.encodeIfPresent(additionalProperties) | ||
} | ||
|
||
} |
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
Oops, something went wrong.