Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 167 lines (129 sloc) 5.846 kB
aa98786 @doherty Initial version
authored
1 NAME
fae537a @doherty Released 0.008
authored
2 Lingua::Boolean - DEPRECATED module to comprehensively parse boolean
3 response strings
aa98786 @doherty Initial version
authored
4
5 VERSION
fae537a @doherty Released 0.008
authored
6 version 0.008
aa98786 @doherty Initial version
authored
7
8 SYNOPSIS
fae537a @doherty Released 0.008
authored
9 use Lingua::Boolean; # NO! Don't use it - use Lingua::Boolean::Tiny
ad2af58 @doherty Add a functional interface in addition to OO
authored
10
11 # Use functional/procedural interface
aa98786 @doherty Initial version
authored
12 print "Do it? ";
13 chomp(my $response = <>);
14 if ( boolean $response ) { # YES, y, OK, 1...
15 print "OK, doing it.\n";
16 }
17 else { # no, N, 0...
18 print "OK, not doing it.\n";
19 }
20
21 # Once more, with feeling
22 print "Fait-le? ";
bce89cf @doherty Split language data into individual files
authored
23 chomp($response = <>);
aa98786 @doherty Initial version
authored
24 if ( boolean $response, 'fr' ) { # OUI
25 print "OK, on le fait.\n";
26 }
27 else { # non
28 print "OK, on ne le fait pas.\n";
29 }
30
ad2af58 @doherty Add a functional interface in addition to OO
authored
31 # Or, use OO interface
32 my $bool = Lingua::Boolean->new('en');
33 print "Do it? ";
34 chomp($response = <>);
35 if ($bool->boolean($response)) {
36 print "OK, doing it!\n";
37 }
38 else {
39 print "OK, not doing it.\n";
40 }
41
aa98786 @doherty Initial version
authored
42 DESCRIPTION
fae537a @doherty Released 0.008
authored
43 This module is deprecated. It began as an experiment with the concept,
44 as well as API design. The experiment worked -- we proved that this
45 module has a bad interface. If you are still interested in the
46 conceptual experiment, give Lingua::Boolean::Tiny a try.
47
aa98786 @doherty Initial version
authored
48 Does that string look like they said "true" or "false"? To know, you
22a3ce6 @doherty Doc cleanup
authored
49 have to check a lot of things. "Lingua::Boolean" attempts to do that in
50 a single module, and do so for multiple languages.
51
52 METHODS
c55f2d9 @doherty Update meta files
authored
53 "Lingua::Boolean" provides both functional/procedural and
22a3ce6 @doherty Doc cleanup
authored
54 object-oriented interfaces. Everything described below is an object
55 method, but can also be called as a function. "boolean()" is exported by
56 default, and can be called that way - everything else requires the
57 fully-qualified name.
58
59 use Lingua::Boolean;
60 my @languages = Lingua::Boolean::languages();
61 print boolean('yes') . "\n"; # boolean is exported by default
aa98786 @doherty Initial version
authored
62
63 import
64 Calling "import()" will, obviously, import subs into your namespace. By
22a3ce6 @doherty Doc cleanup
authored
65 default, "Lingua::Boolean" imports the sub "boolean()". All other subs
66 should be accessed with the object-oriented interface, or use the fully
67 qualified name.
aa98786 @doherty Initial version
authored
68
ad2af58 @doherty Add a functional interface in addition to OO
authored
69 new
70 "new()" creates a new "Lingua::Boolean" object. You can optionally give
71 it the code for the language you'll be working with, and only that
72 language will be loaded. If you do so, you needn't pass the language to
73 every call to "boolean()":
74
75 use Lingua::Boolean qw();
76 my $bool = Lingua::Boolean->new('fr');
77 print ($bool->boolean('oui') ? "TRUE\n" : "FALSE\n");
78
79 Otherwise, "boolean()" accept the language code as the second parameter:
80
81 use Lingua::Boolean qw();
82 my $bool = Lingua::Boolean->new();
83 print ($bool->boolean('oui', 'fr') ? "TRUE\n" : "FALSE\n");
84
22a3ce6 @doherty Doc cleanup
authored
85 boolean
86 "boolean()" tries to determine if the string *looks* true or *looks*
87 false, and returns true or false accordingly. If both tests fail, dies.
88 By default, uses *en*; pass a language code as the second parameter to
89 check another language. Croaks if the language is unknown to
90 "Lingua::Boolean" (or the "Lingua::Boolean" object, if used as an object
91 method).
aa98786 @doherty Initial version
authored
92
22a3ce6 @doherty Doc cleanup
authored
93 use Lingua::Boolean qw();
94 my $bool = Lingua::Boolean->new();
95 print ($bool->boolean('yes') ? "TRUE\n" : "FALSE\n");
ad2af58 @doherty Add a functional interface in addition to OO
authored
96
22a3ce6 @doherty Doc cleanup
authored
97 If you specify the language in the constructor, you needn't specify it
98 in the call to "boolean()":
ad2af58 @doherty Add a functional interface in addition to OO
authored
99
100 use Lingua::Boolean qw();
101 my $bool = Lingua::Boolean->new('fr');
22a3ce6 @doherty Doc cleanup
authored
102 print ($bool->boolean('OUI') ? "TRUE\n" : "FALSE\n");
ad2af58 @doherty Add a functional interface in addition to OO
authored
103
22a3ce6 @doherty Doc cleanup
authored
104 This sub is exported by default, and can be used functionally:
105
106 use Lingua::Boolean;
107 print (boolean('yes') ? "TRUE\n" : "FALSE\n");
108
109 languages
110 "languages()" returns the list of languages that "Lingua::Boolean" knows
bce89cf @doherty Split language data into individual files
authored
111 about.
112
ad2af58 @doherty Add a functional interface in addition to OO
authored
113 use Lingua::Boolean;
22a3ce6 @doherty Doc cleanup
authored
114 my @languages = Lingua::Boolean::languages(); # qw(English Français ...)
ad2af58 @doherty Add a functional interface in addition to OO
authored
115
22a3ce6 @doherty Doc cleanup
authored
116 When called as an object method, returns the languages that that object
117 knows about:
aa98786 @doherty Initial version
authored
118
ad2af58 @doherty Add a functional interface in addition to OO
authored
119 use Lingua::Boolean qw();
120 my $bool = Lingua::Boolean->new('fr');
22a3ce6 @doherty Doc cleanup
authored
121 my @languages = $bool->languages(); # qw(Français)
ad2af58 @doherty Add a functional interface in addition to OO
authored
122
22a3ce6 @doherty Doc cleanup
authored
123 langs
124 "langs()" returns the list of language *codes* that "Lingua::Boolean"
125 knows about.
ad2af58 @doherty Add a functional interface in addition to OO
authored
126
127 use Lingua::Boolean;
22a3ce6 @doherty Doc cleanup
authored
128 my @lang_codes = Lingua::Boolean::langs(); # qw(en fr ...)
ad2af58 @doherty Add a functional interface in addition to OO
authored
129
22a3ce6 @doherty Doc cleanup
authored
130 When called as an object method, returns the languages that that object
131 knows about:
ad2af58 @doherty Add a functional interface in addition to OO
authored
132
133 use Lingua::Boolean qw();
134 my $bool = Lingua::Boolean->new('fr');
22a3ce6 @doherty Doc cleanup
authored
135 my @lang_codes = $bool->langs(); # qw(fr)
aa98786 @doherty Initial version
authored
136
137 EXPORTS
22a3ce6 @doherty Doc cleanup
authored
138 By default, "Lingua::Boolean" exports "boolean()". All other methods
139 must be fully qualified - or use the object-oriented interface.
aa98786 @doherty Initial version
authored
140
141 AVAILABILITY
fae537a @doherty Released 0.008
authored
142 The project homepage is <http://metacpan.org/release/Lingua-Boolean/>.
c55f2d9 @doherty Update meta files
authored
143
aa98786 @doherty Initial version
authored
144 The latest version of this module is available from the Comprehensive
145 Perl Archive Network (CPAN). Visit <http://www.perl.com/CPAN/> to find a
146 CPAN site near you, or see
c55f2d9 @doherty Update meta files
authored
147 <https://metacpan.org/module/Lingua::Boolean/>.
aa98786 @doherty Initial version
authored
148
eccbb7b @doherty Released 0.006
authored
149 SOURCE
150 The development version is on github at
151 <http://github.com/doherty/Lingua-Boolean> and may be cloned from
152 <git://github.com/doherty/Lingua-Boolean.git>
153
aa98786 @doherty Initial version
authored
154 BUGS AND LIMITATIONS
c55f2d9 @doherty Update meta files
authored
155 You can make new bug reports, and view existing ones, through the web
156 interface at <https://github.com/doherty/Lingua-Boolean/issues>.
aa98786 @doherty Initial version
authored
157
158 AUTHOR
2d160c5 @doherty Change contact email address
authored
159 Mike Doherty <doherty@cpan.org>
aa98786 @doherty Initial version
authored
160
161 COPYRIGHT AND LICENSE
7e1f2f8 @doherty use Perl_5 license
authored
162 This software is copyright (c) 2010 by Mike Doherty.
aa98786 @doherty Initial version
authored
163
7e1f2f8 @doherty use Perl_5 license
authored
164 This is free software; you can redistribute it and/or modify it under
165 the same terms as the Perl 5 programming language system itself.
aa98786 @doherty Initial version
authored
166
Something went wrong with that request. Please try again.