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