NAME
Lingua::AtD::Results - Encapsulate conversion of XML from /checkDocument or /checkGrammar call to Error objects.
VERSION
version 1.112970
SYNOPSIS
use Lingua::AtD;
# Create a new service proxy
my $atd = Lingua::AtD->new( {
host => 'service.afterthedeadline.com',
port => 80
});
# Run spelling and grammar checks. Returns a Lingua::AtD::Response object.
my $atd_response = $atd->check_document('Text to check.');
# Loop through reported document errors.
foreach my $atd_error ($atd_response->get_errors()) {
# Do something with...
print "Error string: ", $atd_error->get_string(), "\n";
}
# Run only grammar checks. Essentially the same as
# check_document(), sans spell-check.
my $atd_response = $atd->check_grammar('Text to check.');
# Loop through reported document errors.
foreach my $atd_error ($atd_response->get_errors()) {
# Do something with...
print "Error string: ", $atd_error->get_string(), "\n";
}
# Get statistics on a document. Returns a Lingua::AtD::Scores object.
my $atd_scores = $atd->stats('Text to check.');
# Loop through reported document errors.
foreach my $atd_metric ($atd_scores->get_metrics()) {
# Do something with...
print $atd_metric->get_type(), "/", $atd_metric->get_key(),
" = ", $atd_metric->get_value(), "\n";
}
DESCRIPTION
Encapsulates conversion of the XML response from the AtD server into a list of spelling/grammar/style error objects (Lingua::AtD::Error).
METHODS
new
# Possible, but not likely
my $atd_results = Lingua::AtD::Results->new($xml_response);
foreach my $atd_error ($atd_results->get_errors()) {
# Do something really fun...
}
Lingua::AtD::Results objects should only ever be created from method calls to Lingua::AtD. However, if you have saved XML responses from prior calls to AtD, you can use this object to convert those responses into PERL objects. I won't stop you.
See the DESCRIPTION for typical usage.
has_server_exception
Convenience method to see if the AtD server returned an error message.
get_server_exception
Exception message from the server.
has_errors
Convenience method to see if the XML response from AtD actually contained any spelling/grammar/style errors. These are not exceptions (see get_server_exception). These are expected, and in fact are what you've asked for.
get_errors
Returns a list of spelling/grammar/style errors as Lingua::AtD::Error objects.
get_xml
Returns a string containing the raw XML response from the AtD service call.
SEE ALSO
See the API Documentation at After the Deadline's website.
AUTHOR
David L. Day <dday376@gmail.com>
COPYRIGHT AND LICENSE
This software is copyright (c) 2011 by David L. Day.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.