File Coverage

blib/lib/Lingua/IT/Ita2heb.pm
Criterion Covered Total %
statement 22 24 91.6
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 30 32 93.7


line stmt bran cond sub pod time code
1             package Lingua::IT::Ita2heb;
2              
3 1     1   23957 use 5.010;
  1         4  
  1         40  
4              
5 1     1   5 use strict;
  1         2  
  1         35  
6 1     1   5 use warnings;
  1         7  
  1         30  
7 1     1   1273 use utf8;
  1         13  
  1         6  
8 1     1   2423 use charnames ':full';
  1         64719  
  1         7  
9              
10 1     1   1863 use Readonly;
  1         3290  
  1         63  
11              
12 1     1   1735 use List::MoreUtils ();
  1         2885  
  1         36  
13              
14 1     1   1616 use Lingua::IT::Ita2heb::LettersSeq::IT::ToHeb;
  0            
  0            
15              
16             our $VERSION = '0.01';
17              
18             sub ita_to_heb {
19             my ($ita, %option) = @_;
20              
21             my @ita_letters = split qr//xms, lc $ita;
22              
23             my $seq = Lingua::IT::Ita2heb::LettersSeq::IT::ToHeb->new(
24             {
25             ita_letters => \@ita_letters,
26             %option,
27             }
28             );
29              
30             # Recursion on punctuation marks.
31             #<<<
32             foreach my $punctuation (
33             [ qr/[ ]/xms, q{ }, ], # space
34             [ qr{-}xms, $seq->maqaf, ], # hyphen
35             [ qr{'}xms, q{'}, ]) # apostrophe
36             {
37             my ($re, $replacement) = @{$punctuation};
38             if ($ita =~ $re) {
39             return join $replacement, map { ita_to_heb($_) } split $re, $ita;
40             }
41             }
42             #>>>
43              
44             $seq->main_loop;
45              
46             return $seq->total_text;
47             }
48              
49             sub closed_syllable {
50             my ($letters_ref, $letter_index) = @_;
51              
52             my $seq = Lingua::IT::Ita2heb::LettersSeq::IT::ToHeb->new(
53             {
54             ita_letters => $letters_ref,
55             idx => $letter_index,
56             },
57             );
58              
59             return $seq->closed_syllable();
60             }
61              
62             1; # End of Lingua::IT::Ita2heb
63              
64             __END__
65              
66             =head1 NAME
67              
68             Lingua::IT::Ita2heb - transliterate Italian words into vocalized Hebrew.
69              
70             =head1 DESCRIPTION
71              
72             Transliterate words in Italian into vocalized Hebrew.
73              
74             =head1 VERSION
75              
76             Version 0.01
77              
78             =head1 SYNOPSIS
79              
80             use Lingua::IT::Ita2heb;
81              
82             my $hebrew_word = Lingua::IT::Ita2heb::ita_to_heb('Castelmezzano');
83              
84             =head1 SUBROUTINES/METHODS
85              
86             =head2 ita_to_heb
87              
88             Given an Italian word, returns a vocalized Hebrew string.
89              
90             Additional options:
91              
92             =over
93              
94             =item * disable_rafe
95              
96             By default, the rafe sign will be added to the initial petter pe
97             if it represents an [f] sound. If you don't want it, run it like this:
98              
99             my $hebrew_word = Lingua::IT::Ita2heb::ita_to_heb('Firenze', disable_rafe => 1);
100              
101             =item * disable_dagesh
102              
103             By default, dagesh will be used wherever possible to
104             represent consonant gemination. If you don't want it, run it like this:
105              
106             my $hebrew_word = Lingua::IT::Ita2heb::ita_to_heb('Palazzo', disable_dagesh => 1);
107              
108             =item * ascii_geresh
109              
110             By default, Unicode HEBREW PUNCTUATION GERESH is used to indicate
111             the sounds of ci and gi. If you want to use the ASCII apostrophe, run it like this:
112              
113             my $hebrew_word = Lingua::IT::Ita2heb::ita_to_heb('Cicerone', ascii_geresh => 1);
114              
115             =item * ascii_maqaf
116              
117             By default, Unicode HEBREW PUNCTUATION MAQAF is used to indicate
118             the hyphen. This is the true Hebrew hyphen at the top of the line.
119             If you prefer to use the ASCII hyphen (minus), run it like this:
120              
121             my $hebrew_word = Lingua::IT::Ita2heb::ita_to_heb('Emilia-Romagna', ascii_maqaf => 1);
122              
123             =back
124              
125             =head2 closed_syllable
126              
127             Checks that the vowel is in a closed syllable.
128              
129             Arguments: a reference to a list of characters and
130             the index of the vowel to check.
131              
132             =head1 DIAGNOSTICS
133              
134             =over
135              
136             =item * Unknown letter LETTER in the source
137              
138             The LETTER doesn't look like a part of the Italian orthography.
139              
140             =back
141              
142             =head1 BUGS AND LIMITATIONS
143              
144             This program has several known limitations because Italian pronunciation is
145             sometimes unpredictable and because of the quirks of Hebrew spelling. Do
146             not assume that transliterations that this program makes are correct
147             and always check a reliable dictionary to be sure. Look out especially for
148             the following cases:
149              
150             =over
151              
152             =item * Words with of z
153              
154             The letter z is assumed to have the sound of [dz] in the beginning of
155             the word and [ts] elsewhere. This is right most of the time, but there are
156             also many words where it is wrong.
157              
158             =item * Words with ia, ie, io, iu
159              
160             The letter i is assumed to be a semi-vowel before a vowel most of
161             the time, but there are also many words where it is wrong.
162              
163             =item * Words with accented vowels
164              
165             This program treats all accented vowels equally. Accents are usually
166             relevant only for indicating stress, which is hardly ever marked in Hebrew,
167             but in some words they may affect pronunciation.
168              
169             =item * Segol is always used for the sound of e
170              
171             One day this program may become more clever one day and use tsere and segol
172             in a way that is closer to standard Hebrew vocalization. Until then... well,
173             very few people will notice anyway :)
174              
175             =back
176              
177             Please report any words that this program transliterates incorrectly
178             as well as any other bugs or feature requests as issues at
179             L<https://github.com/amire80/ita2heb>.
180              
181             =head1 DEPENDENCIES
182              
183             =over
184              
185             =item * Readonly.pm.
186              
187             =item * List::MoreUtils
188              
189             =back
190              
191             =head1 CONFIGURATION AND ENVIRONMENT
192              
193             Nothing special.
194              
195             =head1 INCOMPATIBILITIES
196              
197             This program doesn't work with Perl earlier than 5.10 and with non-Unicode strings.
198              
199             =head1 SUPPORT
200              
201             You can find documentation for this module with the perldoc command.
202              
203             perldoc Lingua::IT::Ita2heb
204              
205             You can also look for information at:
206              
207             =over
208              
209             =item * RT: CPAN's request tracker
210              
211             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Lingua-IT-Ita2heb>
212              
213             =item * AnnoCPAN: Annotated CPAN documentation
214              
215             L<http://annocpan.org/dist/Lingua-IT-Ita2heb>
216              
217             =item * CPAN Ratings
218              
219             L<http://cpanratings.perl.org/d/Lingua-IT-Ita2heb>
220              
221             =item * Search CPAN
222              
223             L<http://search.cpan.org/dist/Lingua-IT-Ita2heb/>
224              
225             =back
226              
227             =head1 ACKNOWLEDGEMENTS
228              
229             I thank all my Italian and Hebrew teachers.
230              
231             I thank Shlomi Fish for important technical support
232             and refactoring.
233              
234             =head1 LICENSE AND COPYRIGHT
235              
236             Copyright 2011 Amir E. Aharoni.
237              
238             This program is free software; you can redistribute it and
239             modify it under the terms of either:
240              
241             =over
242              
243             =item * the GNU General Public License version 3 as published
244             by the Free Software Foundation.
245              
246             =item * or the Artistic License version 2.0.
247              
248             =back
249              
250             See http://dev.perl.org/licenses/ for more information.
251              
252             =head1 AUTHOR
253              
254             Amir E. Aharoni, C<< <amir.aharoni at mail.huji.ac.il> >>
255              
256             =cut