Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 157 lines (94 sloc) 5.421 kb
e365f61 @davidlday Added README.pod for github.
authored
1
2 =head1 SYNOPSIS
3
4 use Lingua::AtD;
5
6 # Create a new service proxy
7 my $atd = Lingua::AtD->new( {
8 host => 'service.afterthedeadline.com',
9 port => 80,
0e88a65 @davidlday Increased default throttle to 2 and updated documentation.
authored
10 throttle => 2,
e365f61 @davidlday Added README.pod for github.
authored
11 });
12
13 # Run spelling and grammar checks. Returns a Lingua::AtD::Response object.
14 my $doc_check = $atd->check_document('Text to check.');
15 # Loop through reported document errors.
16 foreach my $atd_error ($doc_check->get_errors()) {
17 # Do something with...
18 print "Error string: ", $atd_error->get_string(), "\n";
19 }
20
21 # Run only grammar checks. Essentially the same as
22 # check_document(), sans spell-check.
23 my $grmr_check = $atd->check_grammar('Text to check.');
24 # Loop through reported document errors.
25 foreach my $atd_error ($grmr_check->get_errors()) {
26 # Do something with...
27 print "Error string: ", $atd_error->get_string(), "\n";
28 }
29
30 # Get statistics on a document. Returns a Lingua::AtD::Scores object.
31 my $atd_scores = $atd->stats('Text to check.');
32 # Loop through reported document errors.
33 foreach my $atd_metric ($atd_scores->get_metrics()) {
34 # Do something with...
35 print $atd_metric->get_type(), "/", $atd_metric->get_key(),
36 " = ", $atd_metric->get_value(), "\n";
37 }
38
39 =head1 DESCRIPTION
40
41 Lingua::AtD provides an OO-style interface for After the Deadline's grammar and spell checking services.
42
39524dc @davidlday Minor documentation fixes.
authored
43 =head1 METHODS
44
cb34520 @davidlday More minor documentation fixes.
authored
45 =over 4
46
39524dc @davidlday Minor documentation fixes.
authored
47 =item new
e365f61 @davidlday Added README.pod for github.
authored
48
49 This constructor takes four arguments, all optional. The sample below shows the defaults.
50
51 $atd = Lingua::AtD->new({
52 api_key => 'Lingua-AtD',
53 host => 'service.afterthedeadline.com',
54 port => 80,
55 throttle => 2,
56 });
57
58 =over 4
59
60 =item api_key
61
0e88a65 @davidlday Increased default throttle to 2 and updated documentation.
authored
62 API key used to access the service. Defaults to this package's name plus 32 hex digits (i.e. I<Lingua-AtD>-7b8391f59fd9fa4246b2c69cd8793b88). See the L<API Documentation|http://www.afterthedeadline.com/api.slp> for requirements. The default will work, and so far as I know will cause no problems.
e365f61 @davidlday Added README.pod for github.
authored
63
64 =item host
65
66 Host for the AtD service. Defaults to the public host: I<service.afterthedeadline.com>. AtD's software is open source, and it's entirely possible to download and set up your own private AtD service. See the L<AtD Project website|http://open.afterthedeadline.com/> for details.
67
68 =item port
69
70 Port for the AtD service. Defaults to the standard http port: I<80>. AtD's software is open source, and it's entirely possible to download and set up your own private AtD service. See the L<AtD Project website|http://open.afterthedeadline.com/> for details.
71
72 =item throttle
73
0e88a65 @davidlday Increased default throttle to 2 and updated documentation.
authored
74 There's no API documentation stating such, but testing has shown that AtD service throws a 503 error if called too quickly. This specifies the number of seconds to wait between calls. The default is 2 and seems to work find.
e365f61 @davidlday Added README.pod for github.
authored
75
76 =back
77
39524dc @davidlday Minor documentation fixes.
authored
78 =item get_api_key
e365f61 @davidlday Added README.pod for github.
authored
79
80 $atd->get_api_key();
81
82 Returns the API Key used to access the AtD service.
83
39524dc @davidlday Minor documentation fixes.
authored
84 =item get_host
e365f61 @davidlday Added README.pod for github.
authored
85
86 $atd->get_host();
87
88 Returns the host of the AtD service.
89
39524dc @davidlday Minor documentation fixes.
authored
90 =item get_port
e365f61 @davidlday Added README.pod for github.
authored
91
92 $atd->get_port();
93
94 Returns the port of the AtD service.
95
39524dc @davidlday Minor documentation fixes.
authored
96 =item get_service_url
e365f61 @davidlday Added README.pod for github.
authored
97
98 $atd->get_service();
99
100 Returns a formatted URL for the AtD service.
101
39524dc @davidlday Minor documentation fixes.
authored
102 =item get_throttle
e365f61 @davidlday Added README.pod for github.
authored
103
104 $atd->get_throttle();
105
106 Returns the number of seconds that must pass between calls to the AtD service.
107
39524dc @davidlday Minor documentation fixes.
authored
108 =item set_throttle
e365f61 @davidlday Added README.pod for github.
authored
109
110 $atd->set_throttle(3);
111
112 Sets the number of seconds that must pass between calls to the AtD service.
113
39524dc @davidlday Minor documentation fixes.
authored
114 =item check_document
e365f61 @davidlday Added README.pod for github.
authored
115
116 $atd_results = $atd->check_document('Some text stringg in badd nneed of prufreding.');
117
118 Invokes the document check service for some string of text and return a L<Lingua::AtD::Results> object.
119
120 From the L<API Documentation|http://www.afterthedeadline.com/api.slp>: I<Checks a document and returns errors and suggestions>
121
39524dc @davidlday Minor documentation fixes.
authored
122 =item check_grammar
e365f61 @davidlday Added README.pod for github.
authored
123
124 $atd_results = $atd->check_grammar('Some text stringg in badd nneed of prufreding.');
125
126 Invokes the grammar check service for some string of text and return a L<Lingua::AtD::Results> object. This differs from I<check_document> in that it only checks grammar and style, not spelling.
127
128 From the L<API Documentation|http://www.afterthedeadline.com/api.slp>: I<Checks a document (sans spelling) returns errors and suggestions>
129
39524dc @davidlday Minor documentation fixes.
authored
130 =item stats
e365f61 @davidlday Added README.pod for github.
authored
131
132 $atd_scores = $atd->stats('Some text stringg in badd nneed of prufreding.');
133
134 Invokes the stats service for some string of text and return a L<Lingua::AtD::Scores> object. This differs from I<check_document> in that it only checks grammar and style, not spelling.
135
136 From the L<API Documentation|http://www.afterthedeadline.com/api.slp>: I<Returns statistics about the writing quality of a document>
137
cb34520 @davidlday More minor documentation fixes.
authored
138 =back
139
e365f61 @davidlday Added README.pod for github.
authored
140 =head1 BUGS
141
142 No known bugs.
143
144 =head1 IRONY
145
146 Wouldn't it be kind of funny if I had a ton of spelling/grammar/style errors in my documentation? Yeah, it would. And I bet there are. Shame on me for not running my documentation through my own module.
147
148 =head1 SEE ALSO
149
150 =for :list
151 * L<Your::Module>
152 * L<Your::Package>
153
154 See the L<API Documentation|http://www.afterthedeadline.com/api.slp> at After the Deadline's website.
155
156 B<NB:> In the L<API Documentation|http://www.afterthedeadline.com/api.slp>, there is a fourth service called B</info.slp>. I do not plan to implement this. Each Lingua::AtD::Error supplies an informative URL when one is available. I see no reason to call this independently, but feel free to submit a patch if you find a reason.
Something went wrong with that request. Please try again.