Akron | 1622dd9 | 2015-12-09 22:34:26 +0100 | [diff] [blame] | 1 | use strict; |
| 2 | use warnings; |
| 3 | use utf8; |
| 4 | use Test::More; |
| 5 | use Benchmark ':hireswallclock'; |
| 6 | use lib 'lib', '../lib'; |
| 7 | |
Akron | afb81ad | 2016-08-01 20:28:31 +0200 | [diff] [blame] | 8 | use_ok('KorAP::XML::Index::MultiTerm'); |
Akron | 1622dd9 | 2015-12-09 22:34:26 +0100 | [diff] [blame] | 9 | |
Akron | afb81ad | 2016-08-01 20:28:31 +0200 | [diff] [blame] | 10 | ok(my $term = KorAP::XML::Index::MultiTerm->new( |
Akron | 1622dd9 | 2015-12-09 22:34:26 +0100 | [diff] [blame] | 11 | term => 'Baum', |
| 12 | p_start => 0, |
| 13 | p_end => 56, |
| 14 | payload => '<i>56', |
| 15 | o_start => 34, |
| 16 | o_end => 120 |
| 17 | ), 'Create new object'); |
| 18 | |
| 19 | is($term->term, 'Baum'); |
| 20 | is($term->p_start, 0); |
| 21 | is($term->p_end, 56); |
| 22 | is($term->o_start, 34); |
| 23 | is($term->o_end, 120); |
| 24 | is($term->payload, '<i>56'); |
Akron | 9c0488f | 2016-01-28 14:17:15 +0100 | [diff] [blame] | 25 | is($term->to_string, 'Baum$<i>34<i>120<i>56<i>56'); |
Akron | 1622dd9 | 2015-12-09 22:34:26 +0100 | [diff] [blame] | 26 | |
Akron | afb81ad | 2016-08-01 20:28:31 +0200 | [diff] [blame] | 27 | ok($term = KorAP::XML::Index::MultiTerm->new( |
Akron | 1622dd9 | 2015-12-09 22:34:26 +0100 | [diff] [blame] | 28 | term => 'Baum' |
| 29 | ), 'Create new object'); |
| 30 | |
| 31 | is($term->term, 'Baum'); |
| 32 | is($term->p_start, 0); |
| 33 | is($term->p_end, 0); |
| 34 | is($term->o_start, 0); |
| 35 | is($term->o_end, 0); |
| 36 | is($term->payload, undef); |
| 37 | is($term->to_string, 'Baum'); |
| 38 | |
Akron | afb81ad | 2016-08-01 20:28:31 +0200 | [diff] [blame] | 39 | ok($term = KorAP::XML::Index::MultiTerm->new( |
Akron | 1622dd9 | 2015-12-09 22:34:26 +0100 | [diff] [blame] | 40 | term => 'Ba#um' |
| 41 | ), 'Create new object'); |
| 42 | |
| 43 | is($term->term, 'Ba#um'); |
| 44 | is($term->p_start, 0); |
| 45 | is($term->p_end, 0); |
| 46 | is($term->o_start, 0); |
| 47 | is($term->o_end, 0); |
| 48 | is($term->payload, undef); |
| 49 | is($term->to_string, 'Ba\#um'); |
| 50 | |
Akron | afb81ad | 2016-08-01 20:28:31 +0200 | [diff] [blame] | 51 | ok($term = KorAP::XML::Index::MultiTerm->new( |
Akron | 1622dd9 | 2015-12-09 22:34:26 +0100 | [diff] [blame] | 52 | term => 'Ba#u$m', |
| 53 | payload => '<i>45' |
| 54 | ), 'Create new object'); |
| 55 | |
| 56 | is($term->term, 'Ba#u$m'); |
| 57 | is($term->p_start, 0); |
| 58 | is($term->p_end, 0); |
| 59 | is($term->o_start, 0); |
| 60 | is($term->o_end, 0); |
| 61 | is($term->payload, '<i>45'); |
| 62 | is($term->to_string, 'Ba\#u\$m$<i>45'); |
| 63 | |
Akron | 55778f0 | 2017-03-14 20:47:26 +0100 | [diff] [blame] | 64 | use_ok('KorAP::XML::Tokenizer'); |
| 65 | |
| 66 | use utf8; |
| 67 | sub remove_diacritics { KorAP::XML::Tokenizer::remove_diacritics(@_) }; |
| 68 | |
| 69 | is(remove_diacritics('äöü'), 'aou', 'Remove diacritics'); |
| 70 | |
| 71 | is(remove_diacritics('Česká'), 'Ceska', 'Removed diacritics'); |
| 72 | is(remove_diacritics('Äößa'), 'Aoßa', 'Removed diacritics'); |
| 73 | |
| 74 | # From comment in http://archives.miloush.net/michkap/archive/2007/05/14/2629747.html |
| 75 | is(remove_diacritics('ÅåÄäÖö'), 'AaAaOo', 'Check swedish'); |
| 76 | # Krawfish::Util::String::_list_props('Łł'); |
| 77 | is(remove_diacritics('ĄąĆćĘꣳŃńÓ󌜏źŻż'), 'AaCcEeLlNnOoSsZzZz', 'Check polish'); |
| 78 | is(remove_diacritics('ľščťžýáíéúäôň*ȍŽÝÁÍÉÚÄÔŇĎ'), 'lsctzyaieuaondLSCTZYAIEUAOND', 'Check slowakish'); |
| 79 | is(remove_diacritics('ëőüűŐÜŰ'), 'eouuOUU', 'Check hungarian'); |
| 80 | is(remove_diacritics('Ññ¿'), 'Nn¿', 'Check spanish'); |
| 81 | is(remove_diacritics('àèòçï'), 'aeoci', 'Check CA?'); |
| 82 | is(remove_diacritics('ı'), 'i', 'Check turkish'); |
| 83 | |
| 84 | # From http://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net#249126 |
| 85 | is(remove_diacritics('äáčďěéíľľňôóřŕšťúůýž'), 'aacdeeillnoorrstuuyz'); |
| 86 | is(remove_diacritics('ÄÁČĎĚÉÍĽĽŇÔÓŘŔŠŤÚŮÝŽ'), 'AACDEEILLNOORRSTUUYZ'); |
| 87 | is(remove_diacritics('ÖÜË'), 'OUE'); |
| 88 | is(remove_diacritics('łŁđĐ'), 'lLdD'); |
| 89 | is(remove_diacritics('ţŢşŞçÇ'), 'tTsScC'); |
| 90 | is(remove_diacritics('øı'), 'oi'); |
| 91 | |
| 92 | is(remove_diacritics( |
| 93 | q{Bonjour ça va? C'est l'été! Ich möchte ä Ä á à â ê é è ë Ë É ï Ï î í ì ó ò ô ö Ö Ü ü ù ú û Û ý Ý ç Ç ñ Ñ}), |
| 94 | q{Bonjour ca va? C'est l'ete! Ich mochte a A a a a e e e e E E i I i i i o o o o O U u u u u U y Y c C n N}); |
| 95 | |
| 96 | # https://docs.seneca.nl/Smartsite-Docs/Features-Modules/Add-On_Modules/Faceted_Search/FS_Reference/FTS_and_iFTS_technical_background_information/Diacritics_and_Unicode.html |
| 97 | is(remove_diacritics( |
| 98 | q/!"#$'()*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` abcdefghijklmnoprstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿−ÀÁ ÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ/), |
| 99 | q/!"#$'()*+,-.0123456789:;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_` abcdefghijklmnoprstuvwxyz{|}~¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿−AAA AAAÆCEEEEIIIIDNOOOOO×OUUUUYÞßaaaaaaæceeeeiiiiðnooooo÷ouuuuyþy/); |
| 100 | |
| 101 | no utf8; |
| 102 | |
Akron | 1622dd9 | 2015-12-09 22:34:26 +0100 | [diff] [blame] | 103 | done_testing; |
| 104 | __END__ |