| 1 | # | ||
| 2 | # This file is part of Lingua-AtD | ||
| 3 | # | ||
| 4 | # This software is copyright (c) 2011 by David L. Day. | ||
| 5 | # | ||
| 6 | # This is free software; you can redistribute it and/or modify it under | ||
| 7 | # the same terms as the Perl 5 programming language system itself. | ||
| 8 | # | ||
| 9 | package Lingua::AtD::Metric; | ||
| 10 | { | ||
| 11 | 6 | $Lingua::AtD::Metric::VERSION = '1.121570'; | |
| 12 | } | ||
| 13 | 6 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 6 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 6 | ▶ | use Carp; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 6 | ▶ | use Class::Std; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | |||
| 18 | # ABSTRACT: Encapsulates the grammar/spelling/style/statistical Metrics contained in Scores. | ||
| 19 | |||
| 20 | { | ||
| 21 | |||
| 22 | # Attributes | ||
| 23 | 6 | my %type_of : ATTR( :init_arg<type> :get<type> ); | |
| 24 | 6 | my %key_of : ATTR( :init_arg<key> :get<key> ); | |
| 25 | 6 | my %value_of : ATTR( :init_arg<value> :get<value>); | |
| 26 | |||
| 27 | } | ||
| 28 | |||
| 29 | 6 | 1; # Magic true value required at end of module | |
| 30 | |||
| 31 | |||
| 32 | =pod | ||
| 33 | |||
| 34 | =head1 NAME | ||
| 35 | |||
| 36 | Lingua::AtD::Metric - Encapsulates the grammar/spelling/style/statistical Metrics contained in Scores. | ||
| 37 | |||
| 38 | =head1 VERSION | ||
| 39 | |||
| 40 | version 1.121570 | ||
| 41 | |||
| 42 | =head1 SYNOPSIS | ||
| 43 | |||
| 44 | use Lingua::AtD; | ||
| 45 | |||
| 46 | # Create a new service proxy | ||
| 47 | my $atd = Lingua::AtD->new( { | ||
| 48 | host => 'service.afterthedeadline.com', | ||
| 49 | port => 80 | ||
| 50 | throttle => 2, | ||
| 51 | }); | ||
| 52 | |||
| 53 | # Run spelling and grammar checks. Returns a Lingua::AtD::Response object. | ||
| 54 | my $doc_check = $atd->check_document('Text to check.'); | ||
| 55 | # Loop through reported document errors. | ||
| 56 | foreach my $atd_error ($doc_check->get_errors()) { | ||
| 57 | # Do something with... | ||
| 58 | print "Error string: ", $atd_error->get_string(), "\n"; | ||
| 59 | } | ||
| 60 | |||
| 61 | # Run only grammar checks. Essentially the same as | ||
| 62 | # check_document(), sans spell-check. | ||
| 63 | my $grmr_check = $atd->check_grammar('Text to check.'); | ||
| 64 | # Loop through reported document errors. | ||
| 65 | foreach my $atd_error ($grmr_check->get_errors()) { | ||
| 66 | # Do something with... | ||
| 67 | print "Error string: ", $atd_error->get_string(), "\n"; | ||
| 68 | } | ||
| 69 | |||
| 70 | # Get statistics on a document. Returns a Lingua::AtD::Scores object. | ||
| 71 | my $atd_scores = $atd->stats('Text to check.'); | ||
| 72 | # Loop through reported document errors. | ||
| 73 | foreach my $atd_metric ($atd_scores->get_metrics()) { | ||
| 74 | # Do something with... | ||
| 75 | print $atd_metric->get_type(), "/", $atd_metric->get_key(), | ||
| 76 | " = ", $atd_metric->get_value(), "\n"; | ||
| 77 | } | ||
| 78 | |||
| 79 | =head1 DESCRIPTION | ||
| 80 | |||
| 81 | Encapsulates the grammar/spelling/style/statistical Metrics contained in Scores. | ||
| 82 | |||
| 83 | =head1 METHODS | ||
| 84 | |||
| 85 | =head2 get_type | ||
| 86 | |||
| 87 | $atd_metric->get_type(); | ||
| 88 | |||
| 89 | Returns a string indicating the type of metric. One of I<grammar>, I<spell>, I<style>, or I<stats>. | ||
| 90 | |||
| 91 | =head2 get_key | ||
| 92 | |||
| 93 | $atd_metric->get_key(); | ||
| 94 | |||
| 95 | Returns a string indicating the metric key. From the L<API Documentation|http://www.afterthedeadline.com/api.slp>: I<The type is a category to add some organization to the information.> | ||
| 96 | |||
| 97 | =head2 get_value | ||
| 98 | |||
| 99 | $atd_metric-The type is a category to add some organization to the information.>get_value(); | ||
| 100 | |||
| 101 | Returns the numeric value of the metric. | ||
| 102 | |||
| 103 | =head1 METHODS | ||
| 104 | |||
| 105 | =head1 SEE ALSO | ||
| 106 | |||
| 107 | See the L<API Documentation|http://www.afterthedeadline.com/api.slp> at After the Deadline's website. | ||
| 108 | |||
| 109 | =head1 AUTHOR | ||
| 110 | |||
| 111 | David L. Day <dday376@gmail.com> | ||
| 112 | |||
| 113 | =head1 COPYRIGHT AND LICENSE | ||
| 114 | |||
| 115 | This software is copyright (c) 2011 by David L. Day. | ||
| 116 | |||
| 117 | This is free software; you can redistribute it and/or modify it under | ||
| 118 | the same terms as the Perl 5 programming language system itself. | ||
| 119 | |||
| 120 | =cut | ||
| 121 | |||
| 122 | |||
| 123 | __END__ | ||