pub struct Builder { /* private fields */ }Expand description
A builder for ClassifyDocumentOutput.
Implementations§
source§impl Builder
impl Builder
sourcepub fn classes(self, input: DocumentClass) -> Self
pub fn classes(self, input: DocumentClass) -> Self
Appends an item to classes.
To override the contents of this collection use set_classes.
The classes used by the document being analyzed. These are used for multi-class trained models. Individual classes are mutually exclusive and each document is expected to have only a single class assigned to it. For example, an animal can be a dog or a cat, but not both at the same time.
sourcepub fn set_classes(self, input: Option<Vec<DocumentClass>>) -> Self
pub fn set_classes(self, input: Option<Vec<DocumentClass>>) -> Self
The classes used by the document being analyzed. These are used for multi-class trained models. Individual classes are mutually exclusive and each document is expected to have only a single class assigned to it. For example, an animal can be a dog or a cat, but not both at the same time.
Examples found in repository?
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
pub(crate) fn deser_operation_crate_operation_classify_document(
value: &[u8],
mut builder: crate::output::classify_document_output::Builder,
) -> Result<
crate::output::classify_document_output::Builder,
aws_smithy_json::deserialize::error::DeserializeError,
> {
let mut tokens_owned =
aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
.peekable();
let tokens = &mut tokens_owned;
aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Classes" => {
builder = builder.set_classes(
crate::json_deser::deser_list_com_amazonaws_comprehend_list_of_classes(
tokens,
)?,
);
}
"Labels" => {
builder = builder.set_labels(
crate::json_deser::deser_list_com_amazonaws_comprehend_list_of_labels(
tokens,
)?,
);
}
_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
}
}
other => {
return Err(
aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
"expected object key or end object, found: {:?}",
other
)),
)
}
}
}
if tokens.next().is_some() {
return Err(
aws_smithy_json::deserialize::error::DeserializeError::custom(
"found more JSON tokens after completing parsing",
),
);
}
Ok(builder)
}sourcepub fn labels(self, input: DocumentLabel) -> Self
pub fn labels(self, input: DocumentLabel) -> Self
Appends an item to labels.
To override the contents of this collection use set_labels.
The labels used the document being analyzed. These are used for multi-label trained models. Individual labels represent different categories that are related in some manner and are not mutually exclusive. For example, a movie can be just an action movie, or it can be an action movie, a science fiction movie, and a comedy, all at the same time.
sourcepub fn set_labels(self, input: Option<Vec<DocumentLabel>>) -> Self
pub fn set_labels(self, input: Option<Vec<DocumentLabel>>) -> Self
The labels used the document being analyzed. These are used for multi-label trained models. Individual labels represent different categories that are related in some manner and are not mutually exclusive. For example, a movie can be just an action movie, or it can be an action movie, a science fiction movie, and a comedy, all at the same time.
Examples found in repository?
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654
pub(crate) fn deser_operation_crate_operation_classify_document(
value: &[u8],
mut builder: crate::output::classify_document_output::Builder,
) -> Result<
crate::output::classify_document_output::Builder,
aws_smithy_json::deserialize::error::DeserializeError,
> {
let mut tokens_owned =
aws_smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(value))
.peekable();
let tokens = &mut tokens_owned;
aws_smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(aws_smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(aws_smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Classes" => {
builder = builder.set_classes(
crate::json_deser::deser_list_com_amazonaws_comprehend_list_of_classes(
tokens,
)?,
);
}
"Labels" => {
builder = builder.set_labels(
crate::json_deser::deser_list_com_amazonaws_comprehend_list_of_labels(
tokens,
)?,
);
}
_ => aws_smithy_json::deserialize::token::skip_value(tokens)?,
}
}
other => {
return Err(
aws_smithy_json::deserialize::error::DeserializeError::custom(format!(
"expected object key or end object, found: {:?}",
other
)),
)
}
}
}
if tokens.next().is_some() {
return Err(
aws_smithy_json::deserialize::error::DeserializeError::custom(
"found more JSON tokens after completing parsing",
),
);
}
Ok(builder)
}sourcepub fn build(self) -> ClassifyDocumentOutput
pub fn build(self) -> ClassifyDocumentOutput
Consumes the builder and constructs a ClassifyDocumentOutput.
Examples found in repository?
864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879
pub fn parse_classify_document_response(
response: &http::Response<bytes::Bytes>,
) -> std::result::Result<crate::output::ClassifyDocumentOutput, crate::error::ClassifyDocumentError>
{
Ok({
#[allow(unused_mut)]
let mut output = crate::output::classify_document_output::Builder::default();
let _ = response;
output = crate::json_deser::deser_operation_crate_operation_classify_document(
response.body().as_ref(),
output,
)
.map_err(crate::error::ClassifyDocumentError::unhandled)?;
output.build()
})
}