| 1 | package Text::Hyphen::TR; | ||
| 2 | 2 | ▶ | use 5.008001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 2 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 2 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 2 | ▶ | use utf8; # source contains turkish letters |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 2 | our $VERSION = "0.01"; | |
| 8 | |||
| 9 | 2 | ▶ | use base 'Text::Hyphen'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | =encoding utf-8 | ||
| 12 | |||
| 13 | =head1 NAME | ||
| 14 | |||
| 15 | Text::Hyphen::TR - determine positions for hyphens inside Turkish words | ||
| 16 | |||
| 17 | =head1 SYNOPSIS | ||
| 18 | |||
| 19 | This module is an implementation of Knuth-Liang hyphenation algorithm | ||
| 20 | for Turkish text using patterns from hyph-utf8 TeX package. | ||
| 21 | |||
| 22 | use Text::Hyphen::TR; | ||
| 23 | my $hyphenator = new Text::Hyphen::TR; | ||
| 24 | |||
| 25 | print $hyphenator->hyphenate($turkish_word_in_Unicode, '-'); | ||
| 26 | # prints hyphenated with dashes | ||
| 27 | |||
| 28 | =head1 EXPORT | ||
| 29 | |||
| 30 | See L<Text::Hyphen> for the interface documentation. | ||
| 31 | |||
| 32 | This module only provides Turkish patterns. | ||
| 33 | |||
| 34 | =cut | ||
| 35 | |||
| 36 | 1 | ▶ | sub _PATTERNS { |
|
Subroutine
_PATTERNS: called CC=1 SCAR=0.0
| |||
| 37 | 1 | return [qw( | |
| 38 | 2a1 2â1 2e1 2ı1 2i1 2î1 2o1 2ö1 2u1 2ü1 2û1 1b1 1c1 1ç1 1d1 1f1 1g1 | ||
| 39 | 1ğ1 1h1 1j1 1k1 1l1 1m1 1n1 1p1 1r1 1s1 1ş1 1t1 1v1 1y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| 66 | a3â2 a3e2 a3ı2 a3i2 a3î2 a3o2 a3ö2 a3u2 a3ü2 a3û2 â3a2 â3â2 â3e2 â3ı2 | ||
| 67 | â3i2 â3î2 â3o2 â3ö2 â3u2 â3ü2 â3û2 e3a2 e3â2 e3e2 e3ı2 e3i2 e3î2 e3o2 | ||
| 68 | e3ö2 e3u2 e3ü2 e3û2 ı3a2 ı3â2 ı3e2 ı3ı2 ı3i2 ı3î2 ı3o2 ı3ö2 ı3u2 ı3ü2 | ||
| 69 | ı3û2 i3a2 i3â2 i3e2 i3ı2 i3i2 i3î2 i3o2 i3ö2 i3u2 i3ü2 i3û2 î3a2 î3â2 | ||
| 70 | î3e2 î3ı2 î3i2 î3î2 î3o2 î3ö2 î3u2 î3ü2 î3û2 o3a2 o3â2 o3e2 o3ı2 o3i2 | ||
| 71 | o3î2 o3o2 o3ö2 o3u2 o3ü2 o3û2 ö3a2 ö3â2 ö3e2 ö3ı2 ö3i2 ö3î2 ö3o2 ö3ö2 | ||
| 72 | ö3u2 ö3ü2 ö3û2 u3a2 u3â2 u3e2 u3ı2 u3i2 u3î2 u3o2 u3ö2 u3u2 u3ü2 u3û2 | ||
| 73 | ü3a2 ü3â2 ü3e2 ü3ı2 ü3i2 ü3î2 ü3o2 ü3ö2 ü3u2 ü3ü2 ü3û2 û3a2 û3â2 û3e2 | ||
| 74 | û3ı2 û3i2 û3î2 û3o2 û3ö2 û3u2 û3ü2 û3û2 tu4r4k m1t4rak | ||
| 75 | 2a2cak. | ||
| 76 | )]; | ||
| 77 | } | ||
| 78 | |||
| 79 | =head1 ACKNOWLEDGEMENTS | ||
| 80 | |||
| 81 | Donald Knuth and Frank Liang for the algorithm. | ||
| 82 | |||
| 83 | Alexander Lebedev for all his valuable work on russian ispell | ||
| 84 | dictionaries and russian hyphenation patterns. See his archive | ||
| 85 | at L<ftp://scon155.phys.msu.ru/pub/russian/> or his hyphenation page | ||
| 86 | at L<http://scon155.phys.msu.su/~swan/hyphenation.html>. | ||
| 87 | |||
| 88 | Patterns used in this module are generated by | ||
| 89 | generate_patterns_tr.rb script which is available at | ||
| 90 | L<http://www.ctan.org/tex-archive/language/hyph-utf8/source/generic/hyph-utf8/languages/tr>. | ||
| 91 | |||
| 92 | The only change is one extra pattern that will not split "-acak" future tense suffix as "a-cak" at the very end of the word. | ||
| 93 | The original pattern list contains the same pattern for the "-ecek" suffix and those two are actually variants | ||
| 94 | of the same suffix so it makes no sense to have patterns for one and not the other. | ||
| 95 | |||
| 96 | Algorithm for pattern generation developed by P. A. MacKay for the Ottoman Texts Project in 1987. | ||
| 97 | Rules adapted for modern Turkish by H. Turgut Uyar <uyar at itu.edu.tr>. | ||
| 98 | Initiative to improve Turkish patterns by S. Ekin Kocabas <kocabas at stanford.edu>. | ||
| 99 | Pattern generation script written by Mojca Miklavec <mojca.miklavec.lists at gmail.com> in June 2008. | ||
| 100 | |||
| 101 | =head1 SEE ALSO | ||
| 102 | |||
| 103 | L<Lingua::TR::Hyphenate> is a completely different implementation. It has at least one bug acknowledged by its author | ||
| 104 | which this module does not have. Try hyphenating "antrparantez". | ||
| 105 | |||
| 106 | L<http://mirror.ctan.org/language/turkish/hyphen/turk_hyf.c>, L<http://www.tug.org/TUGboat/Articles/tb09-1/tb20mackay.pdf>, | ||
| 107 | L<http://www.ctan.org/tex-archive/language/hyph-utf8/source/generic/hyph-utf8/languages/tr>. | ||
| 108 | |||
| 109 | =head1 BUGS AND SUPPORT | ||
| 110 | |||
| 111 | This code is hosted on Github, please see L<https://github.com/kappa/Text-Hyphen-TR>. | ||
| 112 | |||
| 113 | Please report any bugs or feature requests to GitHub issues. | ||
| 114 | |||
| 115 | =head1 LICENSE | ||
| 116 | |||
| 117 | Copyright (C) Alex Kapranoff. | ||
| 118 | |||
| 119 | This is free software; you can redistribute it and/or modify it under | ||
| 120 | the terms GNU General Public License version 3. | ||
| 121 | |||
| 122 | The patterns that are used inside this module may also be obtained from CTAN under LPPL license. | ||
| 123 | See L<http://www.ctan.org/tex-archive/language/hyph-utf8/> and specifically | ||
| 124 | L<http://mirrors.ctan.org/language/hyph-utf8/tex/generic/hyph-utf8/patterns/tex/hyph-tr.tex>. | ||
| 125 | |||
| 126 | =head1 AUTHOR | ||
| 127 | |||
| 128 | Alex Kapranoff E<lt>alex@kapranoff.ruE<gt> | ||
| 129 | |||
| 130 | =cut | ||
| 131 | |||
| 132 | 2 | 1; | |