blib/lib/Lingua/EN/Gender.pm untested

filter: Statementstmt 0.0% 0 / 41 Branchbran 0.0% 0 / 6 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 58 CC 4 SCAR 14.8
CC
4
Cov
0%
pronoun
6.0
is_valid_gender
6.0
gender_index
6.0
CRAP 4.4
1 package Lingua::EN::Gender;
2 #
3 # Does nifty things with inflecting pronouns for gender
4 #
5 # Last updated by gossamer on Wed Jan 6 21:56:31 EST 1999
6 #
7  
8 use strict;
9 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK @genders %pronoun);
10  
11 require Exporter;
12  
13 @ISA = qw(Exporter);
14 @EXPORT = qw( pronoun genders is_valid_gender);
15 @EXPORT_OK = qw();
16 $VERSION = "0.02";
17  
18 =head1 NAME
19  
20 Lingua::EN::Gender - Inflect pronouns for gender
21  
22 =head1 SYNOPSIS
23  
24 use Lingua::EN::Gender;
25  
26 print &genders();
27  
28 if (&is_valid_gender("male")) { ...
29  
30 =head1 DESCRIPTION
31  
32 Small module for inflecting pronouns for a bunch of different
33 genders.
34  
35 Genders currently supported are:
36 neuter
37 male
38 female
39 either
40 spivak
41 splat
42 plural
43 egotistical
44 royal
45 2nd
46 sie/hir
47 zie/zir
48  
49 =cut
50  
51 ###################################################################
52 # Some constants #
53 ###################################################################
54  
55 @genders = ("neuter", "male", "female", "either", "spivak", "splat", "plural", "egotistical", "royal", "2nd", "sie/hir", "zie/zir");
56  
57 $pronoun{"subjective"} = ["it", "he", "she", "s/he", "e", "*e", "they", "I", "we", "you", "sie", "zie"];
58 $pronoun{"objective"} = ["it", "him", "her", "him/her", "em", "h*", "them", "me", "us", "you", "hir", "zir"];
59 $pronoun{"posessive-subjective"} = ["its", "his", "her", "his/her", "eir", "h*", "their", "my", "our", "your", "hirs", "har", "zir"];
60 $pronoun{"posessive-objective"} = ["its", "his", "hers", "his/hers", "eirs", "h*s", "theirs", "mine", "ours", "yours", "hars", "zirs"];
61 $pronoun{"reflexive"} = ["itself", "himself", "herself", "(him/herself", "emself", "h*self", "themselves", "myself", "ourselves", "yourself", "hirself", "zirself"];
62  
63 =head1 FUNCTIONS
64  
65 =item pronoun ( TYPE, GENDER )
66  
67 Returns the appropriate pronoun word for that pronoun type and gender.
68  
69 The types (examples for the male gender in brackets) are:
70 subjective ("he")
71 objective ("him")
72 posessive-subjective ("his")
73 posessive-objective ("his")
74 reflexive ("himself")
75  
76 =cut
77  
78 sub pronoun {
79 my $pro_type = shift;
80 my $pro_gender = shift;
81  
82 my $index = &gender_index(lc($pro_gender));
83  
84 return undef unless defined($index);
85  
86 return $pronoun{$pro_type}[$index];
87  
88 }
89  
90  
91 =pod
92 =item genders ( )
93  
94 Simply returns an array containing all the valid genders.
95  
96 =cut
97  
98 sub genders {
99  
100 return @genders;
101  
102 }
103  
104 =pod
105 =item is_valid_gender ( TEXT )
106  
107 Returns true/false depending if the argument is a gender we know
108 about. Case is not significant.
109  
110 =cut
111  
112 sub is_valid_gender {
113 my $gender = shift;
114  
115 foreach (@genders) {
116 # NB case-insensitive match
117 return 1 if lc($gender) eq $_;
118 }
119 return 0;
120 }
121  
122  
123 sub gender_index {
124 my $gender = shift;
125  
126 foreach (my $i = 0; $i < @genders; $i++) {
127 return $i if $gender eq $genders[$i];
128 }
129  
130 return undef;
131 }
132  
133 =head1 AUTHOR
134  
135 Bek Oberin <bekj@netizen.com.au>
136  
137 =head1 COPYRIGHT
138  
139 Copyright (c) 1999 Bek Oberin. All rights reserved.
140  
141 This program is free software; you can redistribute it and/or modify
142 it under the same terms as Perl itself.
143  
144 =cut
145  
146 #
147 # End.
148 #
149 1;